KPIECE1.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_KPIECE1_
38 #define OMPL_GEOMETRIC_PLANNERS_KPIECE_KPIECE1_
39 
40 #include "ompl/geometric/planners/PlannerIncludes.h"
41 #include "ompl/geometric/planners/kpiece/Discretization.h"
42 
43 namespace ompl
44 {
45  namespace geometric
46  {
71  class KPIECE1 : public base::Planner
72  {
73  public:
75  KPIECE1(const base::SpaceInformationPtr &si);
76 
77  ~KPIECE1() override;
78 
79  base::PlannerStatus solve(const base::PlannerTerminationCondition &ptc) override;
80 
81  void clear() override;
82 
92  void setGoalBias(double goalBias)
93  {
94  goalBias_ = goalBias;
95  }
96 
98  double getGoalBias() const
99  {
100  return goalBias_;
101  }
102 
108  void setRange(double distance)
109  {
110  maxDistance_ = distance;
111  }
112 
114  double getRange() const
115  {
116  return maxDistance_;
117  }
118 
125  void setBorderFraction(double bp)
126  {
127  disc_.setBorderFraction(bp);
128  }
129 
132  double getBorderFraction() const
133  {
134  return disc_.getBorderFraction();
135  }
136 
143  void setMinValidPathFraction(double fraction)
144  {
145  minValidPathFraction_ = fraction;
146  }
147 
149  double getMinValidPathFraction() const
150  {
151  return minValidPathFraction_;
152  }
153 
158  void setFailedExpansionCellScoreFactor(double factor)
159  {
161  }
162 
165  double getFailedExpansionCellScoreFactor() const
166  {
168  }
169 
172  void setProjectionEvaluator(const base::ProjectionEvaluatorPtr &projectionEvaluator)
173  {
174  projectionEvaluator_ = projectionEvaluator;
175  }
176 
179  void setProjectionEvaluator(const std::string &name)
180  {
181  projectionEvaluator_ = si_->getStateSpace()->getProjection(name);
182  }
183 
185  const base::ProjectionEvaluatorPtr &getProjectionEvaluator() const
186  {
187  return projectionEvaluator_;
188  }
189 
190  void setup() override;
191 
192  void getPlannerData(base::PlannerData &data) const override;
193 
194  protected:
196  class Motion
197  {
198  public:
199  Motion() = default;
200 
202  Motion(const base::SpaceInformationPtr &si) : state(si->allocState())
203  {
204  }
205 
206  ~Motion() = default;
207 
209  base::State *state{nullptr};
210 
212  Motion *parent{nullptr};
213  };
214 
216  void freeMotion(Motion *motion);
217 
219  base::StateSamplerPtr sampler_;
220 
222  Discretization<Motion> disc_;
223 
227  base::ProjectionEvaluatorPtr projectionEvaluator_;
228 
232  double failedExpansionScoreFactor_{0.5};
233 
236  double goalBias_{0.05};
237 
243  double minValidPathFraction_{0.2};
244 
246  double maxDistance_{0.};
247 
249  RNG rng_;
250 
252  Motion *lastGoalMotion_{nullptr};
253  };
254  }
255 }
256 
257 #endif
base::StateSamplerPtr sampler_
A state space sampler.
Definition: KPIECE1.h:315
double getBorderFraction() const
Get the fraction of time to focus exploration on boundary.
Definition: KPIECE1.h:228
double getFailedExpansionCellScoreFactor() const
Get the factor that is multiplied to a cell's score if extending a motion from that cell failed.
Definition: KPIECE1.h:261
base::State * state
The state contained by this motion.
Definition: KPIECE1.h:305
double goalBias_
The fraction of time the goal is picked as the state to expand towards (if such a state is available)
Definition: KPIECE1.h:332
void setFailedExpansionCellScoreFactor(double factor)
When extending a motion from a cell, the extension can be successful or it can fail....
Definition: KPIECE1.h:254
Motion * parent
The parent motion in the exploration tree.
Definition: KPIECE1.h:308
void setRange(double distance)
Set the range the planner is supposed to use.
Definition: KPIECE1.h:204
Discretization< Motion > disc_
The tree datastructure and the grid that covers it.
Definition: KPIECE1.h:318
double maxDistance_
The maximum length of a motion to be added to a tree.
Definition: KPIECE1.h:342
Definition of an abstract state.
Definition: State.h:113
void setGoalBias(double goalBias)
Set the goal bias.
Definition: KPIECE1.h:188
Motion * lastGoalMotion_
The most recent goal motion. Used for PlannerData computation.
Definition: KPIECE1.h:348
double getRange() const
Get the range the planner is using.
Definition: KPIECE1.h:210
KPIECE1(const base::SpaceInformationPtr &si)
Constructor.
Definition: KPIECE1.cpp:43
double minValidPathFraction_
When extending a motion, the planner can decide to keep the first valid part of it,...
Definition: KPIECE1.h:339
Object containing planner generated vertex and edge data. It is assumed that all vertices are unique,...
Definition: PlannerData.h:238
base::PlannerStatus solve(const base::PlannerTerminationCondition &ptc) override
Function that can solve the motion planning problem. This function can be called multiple times on th...
Definition: KPIECE1.cpp:91
double getMinValidPathFraction() const
Get the value of the fraction set by setMinValidPathFraction()
Definition: KPIECE1.h:245
Representation of a motion for this algorithm.
Definition: KPIECE1.h:292
const base::ProjectionEvaluatorPtr & getProjectionEvaluator() const
Get the projection evaluator.
Definition: KPIECE1.h:281
double getGoalBias() const
Get the goal bias the planner is using.
Definition: KPIECE1.h:194
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: KPIECE1.h:221
double failedExpansionScoreFactor_
When extending a motion from a cell, the extension can fail. If it is, the score of the cell is multi...
Definition: KPIECE1.h:328
void setMinValidPathFraction(double fraction)
When extending a motion, the planner can decide to keep the first valid part of it,...
Definition: KPIECE1.h:239
SpaceInformationPtr si_
The space information for which planning is done.
Definition: Planner.h:474
void setup() override
Perform extra configuration steps, if needed. This call will also issue a call to ompl::base::SpaceIn...
Definition: KPIECE1.cpp:61
void clear() override
Clear all internal datastructures. Planner settings are not affected. Subsequent calls to solve() wil...
Definition: KPIECE1.cpp:76
void setProjectionEvaluator(const base::ProjectionEvaluatorPtr &projectionEvaluator)
Set the projection evaluator. This class is able to compute the projection of a given state.
Definition: KPIECE1.h:268
void freeMotion(Motion *motion)
Free the memory for a motion.
Definition: KPIECE1.cpp:84
base::ProjectionEvaluatorPtr projectionEvaluator_
This algorithm uses a discretization (a grid) to guide the exploration. The exploration is imposed on...
Definition: KPIECE1.h:323
void getPlannerData(base::PlannerData &data) const override
Get information about the current run of the motion planner. Repeated calls to this function will upd...
Definition: KPIECE1.cpp:212
Main namespace. Contains everything in this library.
Definition: AppBase.h:21
RNG rng_
The random number generator.
Definition: KPIECE1.h:345