Class KPIECE1
Defined in File KPIECE1.h
Nested Relationships
Nested Types
Inheritance Relationships
Base Type
public ompl::base::Planner
(Class Planner)
Class Documentation
-
class KPIECE1 : public ompl::base::Planner
Kinodynamic Planning by Interior-Exterior Cell Exploration.
- Short description
KPIECE is a tree-based planner that uses a discretization (multiple levels, in general) to guide the exploration of the continuous space. This implementation is a simplified one, using a single level of discretization: one grid. The grid is imposed on a projection of the state space. When exploring the space, preference is given to the boundary of this grid. The boundary is computed to be the set of grid cells that have less than 2n non-diagonal neighbors in an n-dimensional projection space. It is important to set the projection the algorithm uses (setProjectionEvaluator() function). If no projection is set, the planner will attempt to use the default projection associated to the state space. An exception is thrown if no default projection is available either. This implementation is intended for systems with differential constraints.
- External documentation
I.A. Şucan and L.E. Kavraki, Kinodynamic motion planning by interior-exterior cell exploration, in Workshop on the Algorithmic Foundations of Robotics, Dec. 2008.[PDF]
Public Functions
-
KPIECE1(const SpaceInformationPtr &si)
Constructor.
-
~KPIECE1() override
-
virtual base::PlannerStatus solve(const base::PlannerTerminationCondition &ptc) override
Function that can solve the motion planning problem. This function can be called multiple times on the same problem, without calling clear() in between. This allows the planner to continue work for more time on an unsolved problem, for example. If this option is used, it is assumed the problem definition is not changed (unpredictable results otherwise). The only change in the problem definition that is accounted for is the addition of starting or goal states (but not changing previously added start/goal states). If clearQuery() is called, the planner may retain prior datastructures generated from a previous query on a new problem definition. The function terminates if the call to ptc returns true.
-
virtual void clear() override
Clear all internal datastructures. Planner settings are not affected. Subsequent calls to solve() will ignore all previous work.
-
inline void setGoalBias(double goalBias)
In the process of randomly selecting states in the state space to attempt to go towards, the algorithm may in fact choose the actual goal state, if it knows it, with some probability. This probability is a real number between 0.0 and 1.0; its value should usually be around 0.05 and should not be too large. It is probably a good idea to use the default value.
-
inline double getGoalBias() const
Get the goal bias the planner is using
-
inline void setBorderFraction(double bp)
Set the fraction of time for focusing on the border (between 0 and 1). This is the minimum fraction used to select cells that are exterior (minimum because if 95% of cells are on the border, they will be selected with 95% chance, even if this fraction is set to 90%)
-
inline double getBorderFraction() const
Get the fraction of time to focus exploration on boundary.
-
inline void setCellScoreFactor(double good, double bad)
When extending a motion from a cell, the extension can be successful or it can fail. If the extension is successful, the score of the cell is multiplied by good. If the extension fails, the score of the cell is multiplied by bad. These numbers should be in the range (0, 1].
-
inline void setBadCellScoreFactor(double bad)
Set the factor that is to be applied to a cell’s score when an expansion from that cell fails.
-
inline void setGoodCellScoreFactor(double good)
Set the factor that is to be applied to a cell’s score when an expansion from that cell succeedes.
-
inline double getGoodCellScoreFactor() const
Get the factor that is multiplied to a cell’s score if extending a motion from that cell succeeded.
-
inline double getBadCellScoreFactor() const
Get the factor that is multiplied to a cell’s score if extending a motion from that cell failed.
-
inline void setMaxCloseSamplesCount(unsigned int nCloseSamples)
When motions reach close to the goal, they are stored in a separate queue to allow biasing towards the goal. This function sets the maximum size of that queue.
-
inline unsigned int getMaxCloseSamplesCount() const
Get the maximum number of samples to store in the queue of samples that are close to the goal.
-
inline void setProjectionEvaluator(const base::ProjectionEvaluatorPtr &projectionEvaluator)
Set the projection evaluator. This class is able to compute the projection of a given state.
-
inline void setProjectionEvaluator(const std::string &name)
Set the projection evaluator (select one from the ones registered with the state space).
-
inline const base::ProjectionEvaluatorPtr &getProjectionEvaluator() const
Get the projection evaluator.
-
virtual void setup() override
Perform extra configuration steps, if needed. This call will also issue a call to ompl::base::SpaceInformation::setup() if needed. This must be called before solving.
-
virtual void getPlannerData(base::PlannerData &data) const override
Get information about the current run of the motion planner. Repeated calls to this function will update data (only additions are made). This is useful to see what changed in the exploration datastructure, between calls to solve(), for example (without calling clear() in between).
Protected Types
-
using Grid = GridB<CellData*, OrderCellsByImportance>
The datatype for the maintained grid datastructure.
Protected Functions
-
void freeMemory()
Free all the memory allocated by this planner.
-
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 the state of the motion being added. The function Returns the number of cells created to accommodate the new motion (0 or 1).
-
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 given to cells on the boundary of the grid.
-
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, so they don’t cross cell boundaries. Given that a motion starts out in the cell origin and it crosses the cells in coords[index] through coords[last] (inclusively), return the index of the state to be used in the next part of the motion (that is within a cell). This will be a value between index and last.
Protected Attributes
-
ControlSamplerPtr controlSampler_
A control sampler.
-
const SpaceInformation *siC_
The base::SpaceInformation cast as control::SpaceInformation, for convenience.
-
base::ProjectionEvaluatorPtr projectionEvaluator_
This algorithm uses a discretization (a grid) to guide the exploration. The exploration is imposed on a projection of the state space.
-
double goodScoreFactor_ = {0.9}
When extending a motion from a cell, the extension can be successful. If it is, the score of the cell is multiplied by this factor.
-
double badScoreFactor_ = {0.45}
When extending a motion from a cell, the extension can fail. If it is, the score of the cell is multiplied by this factor.
-
unsigned int nCloseSamples_ = {30}
When motions reach close to the goal, they are stored in a separate queue to allow biasing towards the goal. This variable specifies the maximum number of samples to keep in that queue.
-
double selectBorderFraction_ = {0.8}
The fraction of time to focus exploration on the border of the grid.
-
double goalBias_ = {0.05}
The fraction of time the goal is picked as the state to expand towards (if such a state is available)
-
Motion *lastGoalMotion_ = {nullptr}
The most recent goal motion. Used for PlannerData computation.
Protected Static Functions
-
struct CellData
The data held by a cell in the grid of motions.
Public Members
-
double coverage = {0.0}
A measure of coverage for this cell. For this implementation, this is the sum of motion durations.
-
unsigned int selections = {1}
The number of times this cell has been selected for expansion.
-
double score = {1.0}
A heuristic score computed based on distance to goal (if available), successes and failures at expanding from this cell.
-
unsigned int iteration = {0}
The iteration at which this cell was created.
-
double importance = {0.0}
The computed importance (based on other class members)
-
double coverage = {0.0}
-
struct CloseSample
Information about a known good sample (closer to the goal than others)
Public Functions
-
inline CloseSample(Grid::Cell *c, Motion *m, double d)
Constructor fully initializes the content of this structure.
-
inline bool operator<(const CloseSample &other) const
Sort samples in accordance to their distance to the goal.
-
inline CloseSample(Grid::Cell *c, Motion *m, double d)
-
struct CloseSamples
Bounded set of good samples.
Public Functions
-
inline CloseSamples(unsigned int size)
Construct an object to maintain a set of at most size samples.
-
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 closest to the goal, given its distance to the goal is distance. If so, add it to the set and return true. Otherwise, return false.
-
bool selectMotion(Motion *&smotion, Grid::Cell *&scell)
Select the top sample (closest to the goal) and update its position in the set subsequently (pretend the distance to the goal is larger). Returns true if the sample selection is successful.
-
inline bool canSample() const
Return true if samples can be selected from this set.
Public Members
-
unsigned int maxSize
Maximum number of samples to maintain.
-
std::set<CloseSample> samples
The maintained samples.
-
inline CloseSamples(unsigned int size)
-
struct Motion
Representation of a motion for this algorithm.
Public Functions
-
Motion() = default
-
inline Motion(const SpaceInformation *si)
Constructor that allocates memory for the state and the control.
-
~Motion() = default
-
Motion() = default