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  namespace geometric
46  {
73  class BKPIECE1 : public base::Planner
74  {
75  public:
77  BKPIECE1(const base::SpaceInformationPtr &si);
78 
79  ~BKPIECE1() override;
80 
83  void setProjectionEvaluator(const base::ProjectionEvaluatorPtr &projectionEvaluator)
84  {
85  projectionEvaluator_ = projectionEvaluator;
86  }
87 
90  void setProjectionEvaluator(const std::string &name)
91  {
92  projectionEvaluator_ = si_->getStateSpace()->getProjection(name);
93  }
94 
96  const base::ProjectionEvaluatorPtr &getProjectionEvaluator() const
97  {
98  return projectionEvaluator_;
99  }
100 
106  void setRange(double distance)
107  {
108  maxDistance_ = distance;
109  }
110 
112  double getRange() const
113  {
114  return maxDistance_;
115  }
116 
123  void setBorderFraction(double bp)
124  {
125  dStart_.setBorderFraction(bp);
126  dGoal_.setBorderFraction(bp);
127  }
128 
131  double getBorderFraction() const
132  {
133  return dStart_.getBorderFraction();
134  }
135 
140  void setFailedExpansionCellScoreFactor(double factor)
141  {
143  }
144 
147  double getFailedExpansionCellScoreFactor() const
148  {
150  }
151 
158  void setMinValidPathFraction(double fraction)
159  {
160  minValidPathFraction_ = fraction;
161  }
162 
164  double getMinValidPathFraction() const
165  {
166  return minValidPathFraction_;
167  }
168 
169  void setup() override;
170 
171  base::PlannerStatus solve(const base::PlannerTerminationCondition &ptc) override;
172  void clear() override;
173 
174  void getPlannerData(base::PlannerData &data) const override;
175 
176  protected:
178  class Motion
179  {
180  public:
181  Motion() = default;
182 
184  Motion(const base::SpaceInformationPtr &si) : state(si->allocState())
185  {
186  }
187 
188  ~Motion() = default;
189 
191  const base::State *root{nullptr};
192 
194  base::State *state{nullptr};
195 
197  Motion *parent{nullptr};
198  };
199 
201  void freeMotion(Motion *motion);
202 
204  base::ValidStateSamplerPtr sampler_;
205 
207  base::ProjectionEvaluatorPtr projectionEvaluator_;
208 
211 
214 
218  double failedExpansionScoreFactor_{.5};
219 
225  double minValidPathFraction_{.5};
226 
228  double maxDistance_{0.};
229 
231  RNG rng_;
232 
234  std::pair<base::State *, base::State *> connectionPoint_{nullptr, nullptr};
235  };
236  }
237 }
238 
239 #endif
Random number generation. An instance of this class cannot be used by multiple threads at once (membe...
Definition: RandomNumbers.h:89
const base::ProjectionEvaluatorPtr & getProjectionEvaluator() const
Get the projection evaluator.
Definition: BKPIECE1.h:192
const base::State * root
The root state (start state) that leads to this motion.
Definition: BKPIECE1.h:287
Representation of a motion for this algorithm.
Definition: BKPIECE1.h:274
void freeMotion(Motion *motion)
Free the memory for a motion.
Definition: BKPIECE1.cpp:235
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: BKPIECE1.cpp:76
Definition of an abstract state.
Definition: State.h:113
Motion * parent
The parent motion in the exploration tree.
Definition: BKPIECE1.h:293
double getMinValidPathFraction() const
Get the value of the fraction set by setMinValidPathFraction()
Definition: BKPIECE1.h:260
double getRange() const
Get the range the planner is using.
Definition: BKPIECE1.h:208
Discretization< Motion > dStart_
The start tree.
Definition: BKPIECE1.h:306
void setRange(double distance)
Set the range the planner is supposed to use.
Definition: BKPIECE1.h:202
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:179
BKPIECE1(const base::SpaceInformationPtr &si)
Constructor.
Definition: BKPIECE1.cpp:42
double getFailedExpansionCellScoreFactor() const
Get the factor that is multiplied to a cell's score if extending a motion from that cell failed.
Definition: BKPIECE1.h:243
void clear() override
Clear all internal datastructures. Planner settings are not affected. Subsequent calls to solve() wil...
Definition: BKPIECE1.cpp:242
double minValidPathFraction_
When extending a motion, the planner can decide to keep the first valid part of it,...
Definition: BKPIECE1.h:321
base::State * state
The state contained by this motion.
Definition: BKPIECE1.h:290
void setMinValidPathFraction(double fraction)
When extending a motion, the planner can decide to keep the first valid part of it,...
Definition: BKPIECE1.h:254
Discretization< Motion > dGoal_
The goal tree.
Definition: BKPIECE1.h:309
double maxDistance_
The maximum length of a motion to be added to a tree.
Definition: BKPIECE1.h:324
void setFailedExpansionCellScoreFactor(double factor)
When extending a motion from a cell, the extension can be successful or it can fail....
Definition: BKPIECE1.h:236
double getBorderFraction() const
Get the fraction of time to focus exploration on boundary.
Definition: BKPIECE1.h:227
std::pair< base::State *, base::State * > connectionPoint_
The pair of states in each tree connected during planning. Used for PlannerData computation.
Definition: BKPIECE1.h:330
SpaceInformationPtr si_
The space information for which planning is done.
Definition: Planner.h:474
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:314
base::ValidStateSamplerPtr sampler_
The employed state sampler.
Definition: BKPIECE1.h:300
RNG rng_
The random number generator.
Definition: BKPIECE1.h:327
void setup() override
Perform extra configuration steps, if needed. This call will also issue a call to ompl::base::SpaceIn...
Definition: BKPIECE1.cpp:60
One-level discretization used for KPIECE.
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: BKPIECE1.cpp:252
base::ProjectionEvaluatorPtr projectionEvaluator_
The employed projection evaluator.
Definition: BKPIECE1.h:303
Main namespace. Contains everything in this library.
Definition: AppBase.h:21
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:219