LBKPIECE1.h
1 /*********************************************************************
2 * Software License Agreement (BSD License)
3 *
4 * Copyright (c) 2008, Willow Garage, Inc.
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 Willow Garage 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_LBKPIECE1_
38 #define OMPL_GEOMETRIC_PLANNERS_KPIECE_LBKPIECE1_
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 
78  class LBKPIECE1 : public base::Planner
79  {
80  public:
81 
84 
85  virtual ~LBKPIECE1();
86 
89  void setProjectionEvaluator(const base::ProjectionEvaluatorPtr &projectionEvaluator)
90  {
91  projectionEvaluator_ = projectionEvaluator;
92  }
93 
96  void setProjectionEvaluator(const std::string &name)
97  {
98  projectionEvaluator_ = si_->getStateSpace()->getProjection(name);
99  }
100 
103  {
104  return projectionEvaluator_;
105  }
106 
112  void setRange(double distance)
113  {
114  maxDistance_ = distance;
115  }
116 
118  double getRange() const
119  {
120  return maxDistance_;
121  }
128  void setBorderFraction(double bp)
129  {
130  dStart_.setBorderFraction(bp);
131  dGoal_.setBorderFraction(bp);
132  }
133 
136  double getBorderFraction() const
137  {
138  return dStart_.getBorderFraction();
139  }
140 
147  void setMinValidPathFraction(double fraction)
148  {
149  minValidPathFraction_ = fraction;
150  }
151 
153  double getMinValidPathFraction() const
154  {
155  return minValidPathFraction_;
156  }
157 
158  virtual void setup();
159 
161  virtual void clear();
162 
163  virtual void getPlannerData(base::PlannerData &data) const;
164 
165  protected:
166 
168  class Motion
169  {
170  public:
171 
172  Motion() : root(NULL), state(NULL), parent(NULL), valid(false)
173  {
174  }
175 
177  Motion(const base::SpaceInformationPtr &si) : root(NULL), state(si->allocState()), parent(NULL), valid(false)
178  {
179  }
180 
181  ~Motion()
182  {
183  }
184 
187 
190 
193 
195  bool valid;
196 
198  std::vector<Motion*> children;
199  };
200 
202  void freeMotion(Motion *motion);
203 
205  void removeMotion(Discretization<Motion> &disc, Motion *motion);
206 
212  bool isPathValid(Discretization<Motion> &disc, Motion *motion, base::State *temp);
213 
216 
219 
222 
225 
232 
234  double maxDistance_;
235 
238 
240  std::pair<base::State*, base::State*> connectionPoint_;
241  };
242 
243  }
244 }
245 
246 
247 #endif
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: LBKPIECE1.cpp:322
Object containing planner generated vertex and edge data. It is assumed that all vertices are unique...
Definition: PlannerData.h:164
base::ProjectionEvaluatorPtr projectionEvaluator_
The employed projection evaluator.
Definition: LBKPIECE1.h:218
Motion * parent
The parent motion in the exploration tree.
Definition: LBKPIECE1.h:192
Representation of a motion for this algorithm.
Definition: LBKPIECE1.h:168
virtual void clear()
Clear all internal datastructures. Planner settings are not affected. Subsequent calls to solve() wil...
Definition: LBKPIECE1.cpp:312
std::vector< Motion * > children
The set of motions descending from the current motion.
Definition: LBKPIECE1.h:198
base::State * state
The state contained by this motion.
Definition: LBKPIECE1.h:189
A boost shared pointer wrapper for ompl::base::StateSampler.
void setProjectionEvaluator(const base::ProjectionEvaluatorPtr &projectionEvaluator)
Set the projection evaluator. This class is able to compute the projection of a given state...
Definition: LBKPIECE1.h:89
void removeMotion(Discretization< Motion > &disc, Motion *motion)
Remove a motion from a tree of motions.
Definition: LBKPIECE1.cpp:274
Encapsulate a termination condition for a motion planner. Planners will call operator() to decide whe...
double maxDistance_
The maximum length of a motion to be added to a tree.
Definition: LBKPIECE1.h:234
void setProjectionEvaluator(const std::string &name)
Set the projection evaluator (select one from the ones registered with the state space).
Definition: LBKPIECE1.h:96
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: LBKPIECE1.h:231
Main namespace. Contains everything in this library.
Definition: Cost.h:42
Random number generation. An instance of this class cannot be used by multiple threads at once (membe...
Definition: RandomNumbers.h:54
One-level discretization used for KPIECE.
Base class for a planner.
Definition: Planner.h:232
void setRange(double distance)
Set the range the planner is supposed to use.
Definition: LBKPIECE1.h:112
const base::ProjectionEvaluatorPtr & getProjectionEvaluator() const
Get the projection evaluator.
Definition: LBKPIECE1.h:102
Discretization< Motion > dStart_
The start tree.
Definition: LBKPIECE1.h:221
Discretization< Motion > dGoal_
The goal tree.
Definition: LBKPIECE1.h:224
A boost shared pointer wrapper for ompl::base::ProjectionEvaluator.
A class to store the exit status of Planner::solve()
Definition: PlannerStatus.h:48
Motion(const base::SpaceInformationPtr &si)
Constructor that allocates memory for the state.
Definition: LBKPIECE1.h:177
A boost shared pointer wrapper for ompl::base::SpaceInformation.
bool isPathValid(Discretization< Motion > &disc, Motion *motion, base::State *temp)
Since solutions are computed in a lazy fashion, once trees are connected, the solution found needs to...
Definition: LBKPIECE1.cpp:229
base::StateSamplerPtr sampler_
The employed state sampler.
Definition: LBKPIECE1.h:215
Definition of an abstract state.
Definition: State.h:50
bool valid
Flag indicating whether this motion has been checked for validity.
Definition: LBKPIECE1.h:195
void freeMotion(Motion *motion)
Free the memory for a motion.
Definition: LBKPIECE1.cpp:305
Lazy Bi-directional KPIECE with one level of discretization.
Definition: LBKPIECE1.h:78
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: LBKPIECE1.cpp:75
double getMinValidPathFraction() const
Get the value of the fraction set by setMinValidPathFraction()
Definition: LBKPIECE1.h:153
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: LBKPIECE1.h:147
std::pair< base::State *, base::State * > connectionPoint_
The pair of states in each tree connected during planning. Used for PlannerData computation.
Definition: LBKPIECE1.h:240
virtual void setup()
Perform extra configuration steps, if needed. This call will also issue a call to ompl::base::SpaceIn...
Definition: LBKPIECE1.cpp:61
SpaceInformationPtr si_
The space information for which planning is done.
Definition: Planner.h:397
double getRange() const
Get the range the planner is using.
Definition: LBKPIECE1.h:118
double getBorderFraction() const
Get the fraction of time to focus exploration on boundary.
Definition: LBKPIECE1.h:136
RNG rng_
The random number generator.
Definition: LBKPIECE1.h:237
const base::State * root
The root state (start state) that leads to this motion.
Definition: LBKPIECE1.h:186
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: LBKPIECE1.h:128
LBKPIECE1(const base::SpaceInformationPtr &si)
Constructor.
Definition: LBKPIECE1.cpp:42