BKPIECE1.h
1 /*********************************************************************
2 * Software License Agreement (BSD License)
3 *
4 * Copyright (c) 2008, Rice University,
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
17 * * Neither the name of the Rice University nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 *********************************************************************/
34 
35 /* Author: Ioan Sucan */
36 
37 #ifndef OMPL_GEOMETRIC_PLANNERS_KPIECE_BKPIECE1_
38 #define OMPL_GEOMETRIC_PLANNERS_KPIECE_BKPIECE1_
39 
40 #include "ompl/geometric/planners/PlannerIncludes.h"
41 #include "ompl/geometric/planners/kpiece/Discretization.h"
42 
43 namespace ompl
44 {
45 
46  namespace geometric
47  {
48 
75  class BKPIECE1 : public base::Planner
76  {
77  public:
78 
81 
82  virtual ~BKPIECE1();
83 
86  void setProjectionEvaluator(const base::ProjectionEvaluatorPtr &projectionEvaluator)
87  {
88  projectionEvaluator_ = projectionEvaluator;
89  }
90 
93  void setProjectionEvaluator(const std::string &name)
94  {
95  projectionEvaluator_ = si_->getStateSpace()->getProjection(name);
96  }
97 
100  {
101  return projectionEvaluator_;
102  }
103 
109  void setRange(double distance)
110  {
111  maxDistance_ = distance;
112  }
113 
115  double getRange() const
116  {
117  return maxDistance_;
118  }
119 
126  void setBorderFraction(double bp)
127  {
128  dStart_.setBorderFraction(bp);
129  dGoal_.setBorderFraction(bp);
130  }
131 
134  double getBorderFraction() const
135  {
136  return dStart_.getBorderFraction();
137  }
138 
144  {
146  }
147 
151  {
153  }
154 
161  void setMinValidPathFraction(double fraction)
162  {
163  minValidPathFraction_ = fraction;
164  }
165 
167  double getMinValidPathFraction() const
168  {
169  return minValidPathFraction_;
170  }
171 
172  virtual void setup();
173 
175  virtual void clear();
176 
177  virtual void getPlannerData(base::PlannerData &data) const;
178 
179  protected:
180 
182  class Motion
183  {
184  public:
185 
186  Motion() : root(NULL), state(NULL), parent(NULL)
187  {
188  }
189 
191  Motion(const base::SpaceInformationPtr &si) : root(NULL), state(si->allocState()), parent(NULL)
192  {
193  }
194 
195  ~Motion()
196  {
197  }
198 
201 
204 
207  };
208 
210  void freeMotion(Motion *motion);
211 
214 
217 
220 
223 
228 
235 
237  double maxDistance_;
238 
241 
243  std::pair<base::State*, base::State*> connectionPoint_;
244  };
245 
246  }
247 }
248 
249 
250 #endif
const base::ProjectionEvaluatorPtr & getProjectionEvaluator() const
Get the projection evaluator.
Definition: BKPIECE1.h:99
void setRange(double distance)
Set the range the planner is supposed to use.
Definition: BKPIECE1.h:109
Object containing planner generated vertex and edge data. It is assumed that all vertices are unique...
Definition: PlannerData.h:164
Discretization< Motion > dGoal_
The goal tree.
Definition: BKPIECE1.h:222
const base::State * root
The root state (start state) that leads to this motion.
Definition: BKPIECE1.h:200
A boost shared pointer wrapper for ompl::base::ValidStateSampler.
Bi-directional KPIECE with one level of discretization.
Definition: BKPIECE1.h:75
void setProjectionEvaluator(const std::string &name)
Set the projection evaluator (select one from the ones registered with the state space).
Definition: BKPIECE1.h:93
void freeMotion(Motion *motion)
Free the memory for a motion.
Definition: BKPIECE1.cpp:236
base::ProjectionEvaluatorPtr projectionEvaluator_
The employed projection evaluator.
Definition: BKPIECE1.h:216
void setProjectionEvaluator(const base::ProjectionEvaluatorPtr &projectionEvaluator)
Set the projection evaluator. This class is able to compute the projection of a given state...
Definition: BKPIECE1.h:86
std::pair< base::State *, base::State * > connectionPoint_
The pair of states in each tree connected during planning. Used for PlannerData computation.
Definition: BKPIECE1.h:243
Encapsulate a termination condition for a motion planner. Planners will call operator() to decide whe...
virtual base::PlannerStatus solve(const base::PlannerTerminationCondition &ptc)
Function that can solve the motion planning problem. This function can be called multiple times on th...
Definition: BKPIECE1.cpp:79
double failedExpansionScoreFactor_
When extending a motion from a cell, the extension can fail. If it is, the score of the cell is multi...
Definition: BKPIECE1.h:227
Discretization< Motion > dStart_
The start tree.
Definition: BKPIECE1.h:219
RNG rng_
The random number generator.
Definition: BKPIECE1.h:240
virtual void getPlannerData(base::PlannerData &data) const
Get information about the current run of the motion planner. Repeated calls to this function will upd...
Definition: BKPIECE1.cpp:253
double getFailedExpansionCellScoreFactor() const
Get the factor that is multiplied to a cell&#39;s score if extending a motion from that cell failed...
Definition: BKPIECE1.h:150
double getRange() const
Get the range the planner is using.
Definition: BKPIECE1.h:115
Main namespace. Contains everything in this library.
Definition: Cost.h:42
Motion(const base::SpaceInformationPtr &si)
Constructor that allocates memory for the state.
Definition: BKPIECE1.h:191
Random number generation. An instance of this class cannot be used by multiple threads at once (membe...
Definition: RandomNumbers.h:54
double maxDistance_
The maximum length of a motion to be added to a tree.
Definition: BKPIECE1.h:237
One-level discretization used for KPIECE.
Base class for a planner.
Definition: Planner.h:232
Representation of a motion for this algorithm.
Definition: BKPIECE1.h:182
A boost shared pointer wrapper for ompl::base::ProjectionEvaluator.
A class to store the exit status of Planner::solve()
Definition: PlannerStatus.h:48
A boost shared pointer wrapper for ompl::base::SpaceInformation.
void setMinValidPathFraction(double fraction)
When extending a motion, the planner can decide to keep the first valid part of it, even if invalid states are found, as long as the valid part represents a sufficiently large fraction from the original motion. This function sets the minimum acceptable fraction.
Definition: BKPIECE1.h:161
Definition of an abstract state.
Definition: State.h:50
void setFailedExpansionCellScoreFactor(double factor)
When extending a motion from a cell, the extension can be successful or it can fail. If the extension fails, the score of the cell is multiplied by factor. These number should be in the range (0, 1].
Definition: BKPIECE1.h:143
base::State * state
The state contained by this motion.
Definition: BKPIECE1.h:203
Motion * parent
The parent motion in the exploration tree.
Definition: BKPIECE1.h:206
double getBorderFraction() const
Get the fraction of time to focus exploration on boundary.
Definition: BKPIECE1.h:134
double getMinValidPathFraction() const
Get the value of the fraction set by setMinValidPathFraction()
Definition: BKPIECE1.h:167
virtual void clear()
Clear all internal datastructures. Planner settings are not affected. Subsequent calls to solve() wil...
Definition: BKPIECE1.cpp:243
double minValidPathFraction_
When extending a motion, the planner can decide to keep the first valid part of it, even if invalid states are found, as long as the valid part represents a sufficiently large fraction from the original motion.
Definition: BKPIECE1.h:234
BKPIECE1(const base::SpaceInformationPtr &si)
Constructor.
Definition: BKPIECE1.cpp:42
SpaceInformationPtr si_
The space information for which planning is done.
Definition: Planner.h:397
void setBorderFraction(double bp)
Set the fraction of time for focusing on the border (between 0 and 1). This is the minimum fraction u...
Definition: BKPIECE1.h:126
base::ValidStateSamplerPtr sampler_
The employed state sampler.
Definition: BKPIECE1.h:213
virtual void setup()
Perform extra configuration steps, if needed. This call will also issue a call to ompl::base::SpaceIn...
Definition: BKPIECE1.cpp:63