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