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:
76 
77  ~KPIECE1() override;
78 
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 
159  {
161  }
162 
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 
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 
220 
223 
228 
233 
236  double goalBias_{0.05};
237 
244 
246  double maxDistance_{0.};
247 
250 
253  };
254  }
255 }
256 
257 #endif
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:232
Object containing planner generated vertex and edge data. It is assumed that all vertices are unique...
Definition: PlannerData.h:174
double getBorderFraction() const
Get the fraction of time to focus exploration on boundary.
Definition: KPIECE1.h:132
Motion * lastGoalMotion_
The most recent goal motion. Used for PlannerData computation.
Definition: KPIECE1.h:252
RNG rng_
The random number generator.
Definition: KPIECE1.h:249
base::State * state
The state contained by this motion.
Definition: KPIECE1.h:209
Representation of a motion for this algorithm.
Definition: KPIECE1.h:196
void freeMotion(Motion *motion)
Free the memory for a motion.
Definition: KPIECE1.cpp:88
A shared pointer wrapper for ompl::base::StateSampler.
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: KPIECE1.h:243
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:165
Encapsulate a termination condition for a motion planner. Planners will call operator() to decide whe...
double getMinValidPathFraction() const
Get the value of the fraction set by setMinValidPathFraction()
Definition: KPIECE1.h:149
Discretization< Motion > disc_
The tree datastructure and the grid that covers it.
Definition: KPIECE1.h:222
void setProjectionEvaluator(const std::string &name)
Set the projection evaluator (select one from the ones registered with the state space).
Definition: KPIECE1.h:179
void clear() override
Clear all internal datastructures. Planner settings are not affected. Subsequent calls to solve() wil...
Definition: KPIECE1.cpp:80
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:236
void setGoalBias(double goalBias)
Set the goal bias.
Definition: KPIECE1.h:92
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:172
double maxDistance_
The maximum length of a motion to be added to a tree.
Definition: KPIECE1.h:246
Main namespace. Contains everything in this library.
Definition: AppBase.h:21
Random number generation. An instance of this class cannot be used by multiple threads at once (membe...
Definition: RandomNumbers.h:58
One-level discretization used for KPIECE.
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:95
Kinematic Planning by Interior-Exterior Cell Exploration.
Definition: KPIECE1.h:71
Base class for a planner.
Definition: Planner.h:223
void setRange(double distance)
Set the range the planner is supposed to use.
Definition: KPIECE1.h:108
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:216
A 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: KPIECE1.h:202
A shared pointer wrapper for ompl::base::SpaceInformation.
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:125
KPIECE1(const base::SpaceInformationPtr &si)
Constructor.
Definition: KPIECE1.cpp:43
Definition of an abstract state.
Definition: State.h:49
Motion * parent
The parent motion in the exploration tree.
Definition: KPIECE1.h:212
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 (between 0 and 1).
Definition: KPIECE1.h:143
double getRange() const
Get the range the planner is using.
Definition: KPIECE1.h:114
void setup() override
Perform extra configuration steps, if needed. This call will also issue a call to ompl::base::SpaceIn...
Definition: KPIECE1.cpp:65
double getGoalBias() const
Get the goal bias the planner is using.
Definition: KPIECE1.h:98
const base::ProjectionEvaluatorPtr & getProjectionEvaluator() const
Get the projection evaluator.
Definition: KPIECE1.h:185
base::ProjectionEvaluatorPtr projectionEvaluator_
This algorithm uses a discretization (a grid) to guide the exploration. The exploration is imposed on...
Definition: KPIECE1.h:227
base::StateSamplerPtr sampler_
A state space sampler.
Definition: KPIECE1.h:219
SpaceInformationPtr si_
The space information for which planning is done.
Definition: Planner.h:406
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: KPIECE1.h:158