KPIECE1.cpp
1 /*********************************************************************
2 * Software License Agreement (BSD License)
3 *
4 * Copyright (c) 2010, 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 #include "ompl/control/planners/kpiece/KPIECE1.h"
38 #include "ompl/base/goals/GoalSampleableRegion.h"
39 #include "ompl/tools/config/SelfConfig.h"
40 #include "ompl/util/Exception.h"
41 #include <limits>
42 #include <cassert>
43 
44 ompl::control::KPIECE1::KPIECE1(const SpaceInformationPtr &si) : base::Planner(si, "KPIECE1")
45 {
47 
48  siC_ = si.get();
49  nCloseSamples_ = 30;
50  goalBias_ = 0.05;
52  badScoreFactor_ = 0.45;
53  goodScoreFactor_ = 0.9;
55  lastGoalMotion_ = nullptr;
56 
57  Planner::declareParam<double>("goal_bias", this, &KPIECE1::setGoalBias, &KPIECE1::getGoalBias, "0.:.05:1.");
58  Planner::declareParam<double>("border_fraction", this, &KPIECE1::setBorderFraction, &KPIECE1::getBorderFraction,
59  "0.:0.05:1.");
60  Planner::declareParam<unsigned int>("max_close_samples", this, &KPIECE1::setMaxCloseSamplesCount,
62  Planner::declareParam<double>("bad_score_factor", this, &KPIECE1::setBadCellScoreFactor,
64  Planner::declareParam<double>("good_score_factor", this, &KPIECE1::setGoodCellScoreFactor,
66 }
67 
68 ompl::control::KPIECE1::~KPIECE1()
69 {
70  freeMemory();
71 }
72 
74 {
75  Planner::setup();
78 
79  if (badScoreFactor_ < std::numeric_limits<double>::epsilon() || badScoreFactor_ > 1.0)
80  throw Exception("Bad cell score factor must be in the range (0,1]");
81  if (goodScoreFactor_ < std::numeric_limits<double>::epsilon() || goodScoreFactor_ > 1.0)
82  throw Exception("Good cell score factor must be in the range (0,1]");
83  if (selectBorderFraction_ < std::numeric_limits<double>::epsilon() || selectBorderFraction_ > 1.0)
84  throw Exception("The fraction of time spent selecting border cells must be in the range (0,1]");
85 
87 }
88 
90 {
91  Planner::clear();
92  controlSampler_.reset();
93  freeMemory();
94  tree_.grid.clear();
95  tree_.size = 0;
96  tree_.iteration = 1;
97  lastGoalMotion_ = nullptr;
98 }
99 
101 {
103 }
104 
106 {
107  for (const auto &it : grid)
108  freeCellData(it.second->data);
109 }
110 
112 {
113  for (auto &motion : cdata->motions)
114  freeMotion(motion);
115  delete cdata;
116 }
117 
119 {
120  if (motion->state)
121  si_->freeState(motion->state);
122  if (motion->control)
123  siC_->freeControl(motion->control);
124  delete motion;
125 }
126 
128 {
129  if (samples.empty())
130  {
131  CloseSample cs(cell, motion, distance);
132  samples.insert(cs);
133  return true;
134  }
135  // if the sample we're considering is closer to the goal than the worst sample in the
136  // set of close samples, we include it
137  if (samples.rbegin()->distance > distance)
138  {
139  // if the inclusion would go above the maximum allowed size,
140  // remove the last element
141  if (samples.size() >= maxSize)
142  samples.erase(--samples.end());
143  CloseSample cs(cell, motion, distance);
144  samples.insert(cs);
145  return true;
146  }
147 
148  return false;
149 }
150 
152 // this is the factor by which distances are inflated when considered for addition to closest samples
153 static const double CLOSE_MOTION_DISTANCE_INFLATION_FACTOR = 1.1;
155 
157 {
158  if (samples.size() > 0)
159  {
160  scell = samples.begin()->cell;
161  smotion = samples.begin()->motion;
162  // average the highest & lowest distances and multiply by CLOSE_MOTION_DISTANCE_INFLATION_FACTOR
163  // (make the distance appear artificially longer)
164  double d =
165  (samples.begin()->distance + samples.rbegin()->distance) * (CLOSE_MOTION_DISTANCE_INFLATION_FACTOR / 2.0);
166  samples.erase(samples.begin());
167  consider(scell, smotion, d);
168  return true;
169  }
170  return false;
171 }
172 
173 unsigned int ompl::control::KPIECE1::findNextMotion(const std::vector<Grid::Coord> &coords, unsigned int index,
174  unsigned int count)
175 {
176  for (unsigned int i = index + 1; i < count; ++i)
177  if (coords[i] != coords[index])
178  return i - 1;
179 
180  return count - 1;
181 }
182 
184 {
185  checkValidity();
186  base::Goal *goal = pdef_->getGoal().get();
187 
188  while (const base::State *st = pis_.nextStart())
189  {
190  auto *motion = new Motion(siC_);
191  si_->copyState(motion->state, st);
192  siC_->nullControl(motion->control);
193  addMotion(motion, 1.0);
194  }
195 
196  if (tree_.grid.size() == 0)
197  {
198  OMPL_ERROR("%s: There are no valid initial states!", getName().c_str());
200  }
201 
202  if (!controlSampler_)
204 
205  OMPL_INFORM("%s: Starting planning with %u states already in datastructure", getName().c_str(), tree_.size);
206 
207  Motion *solution = nullptr;
208  Motion *approxsol = nullptr;
209  double approxdif = std::numeric_limits<double>::infinity();
210 
211  Control *rctrl = siC_->allocControl();
212 
213  std::vector<base::State *> states(siC_->getMaxControlDuration() + 1);
214  std::vector<Grid::Coord> coords(states.size());
215  std::vector<Grid::Cell *> cells(coords.size());
216 
217  for (auto &state : states)
218  state = si_->allocState();
219 
220  // samples that were found to be the best, so far
221  CloseSamples closeSamples(nCloseSamples_);
222 
223  while (ptc == false)
224  {
225  tree_.iteration++;
226 
227  /* Decide on a state to expand from */
228  Motion *existing = nullptr;
229  Grid::Cell *ecell = nullptr;
230 
231  if (closeSamples.canSample() && rng_.uniform01() < goalBias_)
232  {
233  if (!closeSamples.selectMotion(existing, ecell))
234  selectMotion(existing, ecell);
235  }
236  else
237  selectMotion(existing, ecell);
238  assert(existing);
239 
240  /* sample a random control */
241  controlSampler_->sampleNext(rctrl, existing->control, existing->state);
242 
243  /* propagate */
244  unsigned int cd =
246  cd = siC_->propagateWhileValid(existing->state, rctrl, cd, states, false);
247 
248  /* if we have enough steps */
249  if (cd >= siC_->getMinControlDuration())
250  {
251  std::size_t avgCov_two_thirds = (2 * tree_.size) / (3 * tree_.grid.size());
252  bool interestingMotion = false;
253 
254  // split the motion into smaller ones, so we do not cross cell boundaries
255  for (unsigned int i = 0; i < cd; ++i)
256  {
257  projectionEvaluator_->computeCoordinates(states[i], coords[i]);
258  cells[i] = tree_.grid.getCell(coords[i]);
259  if (!cells[i])
260  interestingMotion = true;
261  else
262  {
263  if (!interestingMotion && cells[i]->data->motions.size() <= avgCov_two_thirds)
264  interestingMotion = true;
265  }
266  }
267 
268  if (interestingMotion || rng_.uniform01() < 0.05)
269  {
270  unsigned int index = 0;
271  while (index < cd)
272  {
273  unsigned int nextIndex = findNextMotion(coords, index, cd);
274  auto *motion = new Motion(siC_);
275  si_->copyState(motion->state, states[nextIndex]);
276  siC_->copyControl(motion->control, rctrl);
277  motion->steps = nextIndex - index + 1;
278  motion->parent = existing;
279 
280  double dist = 0.0;
281  bool solv = goal->isSatisfied(motion->state, &dist);
282  Grid::Cell *toCell = addMotion(motion, dist);
283 
284  if (solv)
285  {
286  approxdif = dist;
287  solution = motion;
288  break;
289  }
290  if (dist < approxdif)
291  {
292  approxdif = dist;
293  approxsol = motion;
294  }
295 
296  closeSamples.consider(toCell, motion, dist);
297 
298  // new parent will be the newly created motion
299  existing = motion;
300  index = nextIndex + 1;
301  }
302 
303  if (solution)
304  break;
305  }
306 
307  // update cell score
308  ecell->data->score *= goodScoreFactor_;
309  }
310  else
311  ecell->data->score *= badScoreFactor_;
312 
313  tree_.grid.update(ecell);
314  }
315 
316  bool solved = false;
317  bool approximate = false;
318  if (solution == nullptr)
319  {
320  solution = approxsol;
321  approximate = true;
322  }
323 
324  if (solution != nullptr)
325  {
326  lastGoalMotion_ = solution;
327 
328  /* construct the solution path */
329  std::vector<Motion *> mpath;
330  while (solution != nullptr)
331  {
332  mpath.push_back(solution);
333  solution = solution->parent;
334  }
335 
336  /* set the solution path */
337  auto path(std::make_shared<PathControl>(si_));
338  for (int i = mpath.size() - 1; i >= 0; --i)
339  if (mpath[i]->parent)
340  path->append(mpath[i]->state, mpath[i]->control, mpath[i]->steps * siC_->getPropagationStepSize());
341  else
342  path->append(mpath[i]->state);
343 
344  pdef_->addSolutionPath(path, approximate, approxdif, getName());
345  solved = true;
346  }
347 
348  siC_->freeControl(rctrl);
349  for (auto &state : states)
350  si_->freeState(state);
351 
352  OMPL_INFORM("%s: Created %u states in %u cells (%u internal + %u external)", getName().c_str(), tree_.size,
354 
355  return base::PlannerStatus(solved, approximate);
356 }
357 
359 {
362 
363  // We are running on finite precision, so our update scheme will end up
364  // with 0 values for the score. This is where we fix the problem
365  if (scell->data->score < std::numeric_limits<double>::epsilon())
366  {
367  OMPL_DEBUG("%s: Numerical precision limit reached. Resetting costs.", getName().c_str());
368  std::vector<CellData *> content;
369  content.reserve(tree_.grid.size());
370  tree_.grid.getContent(content);
371  for (auto &it : content)
372  it->score += 1.0 + log((double)(it->iteration));
373  tree_.grid.updateAll();
374  }
375 
376  if (scell && !scell->data->motions.empty())
377  {
378  scell->data->selections++;
379  smotion = scell->data->motions[rng_.halfNormalInt(0, scell->data->motions.size() - 1)];
380  return true;
381  }
382  else
383  return false;
384 }
385 
387 // this is the offset added to estimated distances to the goal, so we avoid division by 0
388 static const double DISTANCE_TO_GOAL_OFFSET = 1e-3;
390 
392 {
393  Grid::Coord coord;
394  projectionEvaluator_->computeCoordinates(motion->state, coord);
395  Grid::Cell *cell = tree_.grid.getCell(coord);
396  if (cell)
397  {
398  cell->data->motions.push_back(motion);
399  cell->data->coverage += motion->steps;
400  tree_.grid.update(cell);
401  }
402  else
403  {
404  cell = tree_.grid.createCell(coord);
405  cell->data = new CellData();
406  cell->data->motions.push_back(motion);
407  cell->data->coverage = motion->steps;
408  cell->data->iteration = tree_.iteration;
409  cell->data->selections = 1;
410  cell->data->score = (1.0 + log((double)(tree_.iteration))) / (DISTANCE_TO_GOAL_OFFSET + dist);
411  tree_.grid.add(cell);
412  }
413  tree_.size++;
414  return cell;
415 }
416 
418 {
419  Planner::getPlannerData(data);
420 
421  Grid::CellArray cells;
422  tree_.grid.getCells(cells);
423 
424  double delta = siC_->getPropagationStepSize();
425 
426  if (lastGoalMotion_)
428 
429  for (auto &cell : cells)
430  {
431  for (const auto &m : cell->data->motions)
432  {
433  if (m->parent)
434  {
435  if (data.hasControls())
436  data.addEdge(base::PlannerDataVertex(m->parent->state),
437  base::PlannerDataVertex(m->state, cell->border ? 2 : 1),
438  control::PlannerDataEdgeControl(m->control, m->steps * delta));
439  else
440  data.addEdge(base::PlannerDataVertex(m->parent->state),
441  base::PlannerDataVertex(m->state, cell->border ? 2 : 1));
442  }
443  else
444  data.addStartVertex(base::PlannerDataVertex(m->state, cell->border ? 2 : 1));
445 
446  // A state created as a parent first may have an improper tag variable
447  data.tagState(m->state, cell->border ? 2 : 1);
448  }
449  }
450 }
bool approximateSolutions
Flag indicating whether the planner is able to compute approximate solutions.
Definition: Planner.h:212
void setBadCellScoreFactor(double bad)
Set the factor that is to be applied to a cell&#39;s score when an expansion from that cell fails...
Definition: KPIECE1.h:136
virtual void add(Cell *cell)
Add the cell to the grid.
Definition: GridB.h:205
typename GridN< CellData * >::CellArray CellArray
The datatype for arrays of cells.
Definition: GridB.h:55
Object containing planner generated vertex and edge data. It is assumed that all vertices are unique...
Definition: PlannerData.h:174
unsigned int countInternal() const
Return the number of internal cells.
Definition: GridB.h:115
void setGoodCellScoreFactor(double good)
Set the factor that is to be applied to a cell&#39;s score when an expansion from that cell succeedes...
Definition: KPIECE1.h:143
void updateAll()
Update all cells and reconstruct the heaps.
Definition: GridB.h:151
double getPropagationStepSize() const
Propagation is performed at integer multiples of a specified step size. This function returns the val...
Bounded set of good samples.
Definition: KPIECE1.h:299
unsigned int getMinControlDuration() const
Get the minimum number of steps a control is propagated for.
bool selectMotion(Motion *&smotion, Grid::Cell *&scell)
Select the top sample (closest to the goal) and update its position in the set subsequently (pretend ...
Definition: KPIECE1.cpp:156
double fracExternal() const
Return the fraction of external cells.
Definition: GridB.h:127
void log(const char *file, int line, LogLevel level, const char *m,...)
Root level logging function. This should not be invoked directly, but rather used via a logging macro...
Definition: Console.cpp:120
double selectBorderFraction_
The fraction of time to focus exploration on the border of the grid.
Definition: KPIECE1.h:424
double getBorderFraction() const
Get the fraction of time to focus exploration on boundary.
Definition: KPIECE1.h:118
void setGoalBias(double goalBias)
Definition: KPIECE1.h:94
bool canSample() const
Return true if samples can be selected from this set.
Definition: KPIECE1.h:321
unsigned int propagateWhileValid(const base::State *state, const Control *control, int steps, base::State *result) const
Propagate the model of the system forward, starting at a given state, with a given control...
void onCellUpdate(EventCellUpdate event, void *arg)
Definition: GridB.h:94
TreeData tree_
The tree datastructure.
Definition: KPIECE1.h:397
void nullControl(Control *control) const
Make the control have no effect if it were to be applied to a state for any amount of time...
Definition of an abstract control.
Definition: Control.h:47
double getBadCellScoreFactor() const
Get the factor that is multiplied to a cell&#39;s score if extending a motion from that cell failed...
Definition: KPIECE1.h:157
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:428
void clear() override
Clear all internal datastructures. Planner settings are not affected. Subsequent calls to solve() wil...
Definition: KPIECE1.cpp:89
typename GridN< CellData * >::Cell Cell
Definition of a cell in this grid.
Definition: GridB.h:52
unsigned int addGoalVertex(const PlannerDataVertex &v)
Adds the given vertex to the graph data, and marks it as a start vertex. The vertex index is returned...
Abstract definition of goals.
Definition: Goal.h:62
double getGoalBias() const
Definition: KPIECE1.h:100
Encapsulate a termination condition for a motion planner. Planners will call operator() to decide whe...
_T data
The data we store in the cell.
Definition: Grid.h:60
double badScoreFactor_
When extending a motion from a cell, the extension can fail. If it is, the score of the cell is multi...
Definition: KPIECE1.h:415
bool consider(Grid::Cell *cell, Motion *motion, double distance)
Evaluate whether motion motion, part of cell cell is good enough to be part of the set of samples clo...
Definition: KPIECE1.cpp:127
Representation of an edge in PlannerData for planning with controls. This structure encodes a specifi...
Definition: PlannerData.h:60
unsigned int findNextMotion(const std::vector< Grid::Coord > &coords, unsigned int index, unsigned int count)
When generated motions are to be added to the tree of motions, they often need to be split...
Definition: KPIECE1.cpp:173
ControlSamplerPtr allocControlSampler() const
Allocate a control sampler.
unsigned int size
The total number of motions (there can be multiple per cell) in the grid.
Definition: KPIECE1.h:346
Cell * getCell(const Coord &coord) const
Get the cell at a specified coordinate.
Definition: GridN.h:123
void getContent(std::vector< _T > &content) const
Get the data stored in the cells we are aware of.
Definition: Grid.h:255
static void computeImportance(Grid::Cell *cell, void *)
This function is provided as a calback to the grid datastructure to update the importance of a cell...
Definition: KPIECE1.h:355
void setMaxCloseSamplesCount(unsigned int nCloseSamples)
When motions reach close to the goal, they are stored in a separate queue to allow biasing towards th...
Definition: KPIECE1.h:164
Control * allocControl() const
Allocate memory for a control.
ProblemDefinitionPtr pdef_
The user set problem definition.
Definition: Planner.h:418
Grid::Cell * addMotion(Motion *motion, double dist)
Add a motion to the grid containing motions. As a hint, dist specifies the distance to the goal from ...
Definition: KPIECE1.cpp:391
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:183
std::vector< int > Coord
Definition of a coordinate within this grid.
Definition: Grid.h:54
void freeMotion(Motion *motion)
Free the memory for a motion.
Definition: KPIECE1.cpp:118
void freeMemory()
Free all the memory allocated by this planner.
Definition: KPIECE1.cpp:100
int halfNormalInt(int r_min, int r_max, double focus=3.0)
Generate a random integer using a half-normal distribution. The value is within specified bounds ([r_...
void update(Cell *cell)
Update the position in the heaps for a particular cell.
Definition: GridB.h:139
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:417
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:111
double uniform01()
Generate a random real between 0 and 1.
Definition: RandomNumbers.h:68
base::ProjectionEvaluatorPtr projectionEvaluator_
This algorithm uses a discretization (a grid) to guide the exploration. The exploration is imposed on...
Definition: KPIECE1.h:405
unsigned int getMaxCloseSamplesCount() const
Get the maximum number of samples to store in the queue of samples that are close to the goal...
Definition: KPIECE1.h:170
Base class for a vertex in the PlannerData structure. All derived classes must implement the clone an...
Definition: PlannerData.h:58
Invalid start state or no start state specified.
Definition: PlannerStatus.h:56
void setDimension(unsigned int dimension)
Definition: GridN.h:89
double goodScoreFactor_
When extending a motion from a cell, the extension can be successful. If it is, the score of the cell...
Definition: KPIECE1.h:410
void copyControl(Control *destination, const Control *source) const
Copy a control to another.
Representation of a motion for this algorithm.
Definition: KPIECE1.h:200
#define OMPL_ERROR(fmt,...)
Log a formatted error string.
Definition: Console.h:64
bool tagState(const State *st, int tag)
Set the integer tag associated with the given state. If the given state does not exist in a vertex...
Motion * parent
The parent motion in the exploration tree.
Definition: KPIECE1.h:224
unsigned int getMaxControlDuration() const
Get the maximum number of steps a control is propagated for.
Information about a known good sample (closer to the goal than others)
Definition: KPIECE1.h:274
void setup() override
Perform extra configuration steps, if needed. This call will also issue a call to ompl::base::SpaceIn...
Definition: KPIECE1.cpp:73
std::vector< Motion * > motions
The set of motions contained in this grid cell.
Definition: KPIECE1.h:237
Cell * topExternal() const
Return the cell that is at the top of the heap maintaining external cells.
Definition: GridB.h:108
A class to store the exit status of Planner::solve()
Definition: PlannerStatus.h:48
virtual bool addEdge(unsigned int v1, unsigned int v2, const PlannerDataEdge &edge=PlannerDataEdge(), Cost weight=Cost(1.0))
Adds a directed edge between the given vertex indexes. An optional edge structure and weight can be s...
void freeGridMotions(Grid &grid)
Free the memory for the motions contained in a grid.
Definition: KPIECE1.cpp:105
KPIECE1(const SpaceInformationPtr &si)
Constructor.
Definition: KPIECE1.cpp:44
unsigned int addStartVertex(const PlannerDataVertex &v)
Adds the given vertex to the graph data, and marks it as a start vertex. The vertex index is returned...
Definition of an abstract state.
Definition: State.h:49
virtual void checkValidity()
Check to see if the planner is in a working state (setup has been called, a goal was set...
Definition: Planner.cpp:101
ControlSamplerPtr controlSampler_
A control sampler.
Definition: KPIECE1.h:394
virtual bool isSatisfied(const State *st) const =0
Return true if the state satisfies the goal constraints.
PlannerInputStates pis_
Utility class to extract valid input states.
Definition: Planner.h:421
A shared pointer wrapper for ompl::control::SpaceInformation.
PlannerSpecs specs_
The specifications of the planner (its capabilities)
Definition: Planner.h:427
const State * nextStart()
Return the next valid start state or nullptr if no more valid start states are available.
Definition: Planner.cpp:230
Definition of a cell in this grid.
Definition: Grid.h:57
double getGoodCellScoreFactor() const
Get the factor that is multiplied to a cell&#39;s score if extending a motion from that cell succeeded...
Definition: KPIECE1.h:150
The exception type for ompl.
Definition: Exception.h:46
The data held by a cell in the grid of motions.
Definition: KPIECE1.h:228
unsigned int size() const
Check the size of the grid.
Definition: Grid.h:291
#define OMPL_DEBUG(fmt,...)
Log a formatted debugging string.
Definition: Console.h:70
void configureProjectionEvaluator(base::ProjectionEvaluatorPtr &proj)
If proj is undefined, it is set to the default projection reported by base::StateSpace::getDefaultPro...
Definition: SelfConfig.cpp:231
Grid grid
A grid containing motions, imposed on a projection of the state space.
Definition: KPIECE1.h:342
virtual bool hasControls() const
Indicate whether any information about controls (ompl::control::Control) is stored in this instance...
const std::string & getName() const
Get the name of the planner.
Definition: Planner.cpp:56
unsigned int countExternal() const
Return the number of external cells.
Definition: GridB.h:121
bool selectMotion(Motion *&smotion, Grid::Cell *&scell)
Select a motion and the cell it is part of from the grid of motions. This is where preference is give...
Definition: KPIECE1.cpp:358
unsigned int iteration
The number of iterations performed on this tree.
Definition: KPIECE1.h:349
RNG rng_
The random number generator.
Definition: KPIECE1.h:431
This class contains methods that automatically configure various parameters for motion planning...
Definition: SelfConfig.h:59
void getCells(CellArray &cells) const
Get the set of instantiated cells in the grid.
Definition: GridN.h:210
Control * control
The control contained by this motion.
Definition: KPIECE1.h:218
const SpaceInformation * siC_
The base::SpaceInformation cast as control::SpaceInformation, for convenience.
Definition: KPIECE1.h:400
void freeControl(Control *control) const
Free the memory of a control.
SpaceInformationPtr si_
The space information for which planning is done.
Definition: Planner.h:415
Cell * topInternal() const
Return the cell that is at the top of the heap maintaining internal cells.
Definition: GridB.h:101
Motion * lastGoalMotion_
The most recent goal motion. Used for PlannerData computation.
Definition: KPIECE1.h:434
base::State * state
The state contained by this motion.
Definition: KPIECE1.h:215
void clear() override
Clear all cells in the grid.
Definition: GridB.h:267
void freeCellData(CellData *cdata)
Free the memory for the data contained in a grid cell.
Definition: KPIECE1.cpp:111
unsigned int steps
The number of steps the control is applied for.
Definition: KPIECE1.h:221
unsigned int nCloseSamples_
When motions reach close to the goal, they are stored in a separate queue to allow biasing towards th...
Definition: KPIECE1.h:420
virtual Cell * createCell(const Coord &coord, CellArray *nbh=nullptr)
Create a cell but do not add it to the grid; update neighboring cells however.
Definition: GridB.h:162
#define OMPL_INFORM(fmt,...)
Log a formatted information string.
Definition: Console.h:68