37 #include "ompl/geometric/planners/est/EST.h"
38 #include "ompl/base/goals/GoalSampleableRegion.h"
39 #include "ompl/tools/config/SelfConfig.h"
55 ompl::geometric::EST::~EST(
void)
67 tree_.grid.setDimension(projectionEvaluator_->getDimension());
78 lastGoalMotion_ = NULL;
85 for (
unsigned int i = 0 ; i < it->second->data.size() ; ++i)
87 if (it->second->data[i]->state)
88 si_->freeState(it->second->data[i]->state);
89 delete it->second->data[i];
103 si_->copyState(motion->
state, st);
107 if (tree_.grid.size() == 0)
109 OMPL_ERROR(
"%s: There are no valid initial states!", getName().c_str());
114 sampler_ = si_->allocValidStateSampler();
116 OMPL_INFORM(
"%s: Starting with %u states", getName().c_str(), tree_.size);
120 double approxdif = std::numeric_limits<double>::infinity();
126 Motion *existing = selectMotion();
130 if (goal_s && rng_.uniform01() < goalBias_ && goal_s->
canSample())
133 if (!sampler_->sampleNear(xstate, existing->
state, maxDistance_))
136 if (si_->checkMotion(existing->
state, xstate))
140 si_->copyState(motion->
state, xstate);
141 motion->
parent = existing;
152 if (dist < approxdif)
161 bool approximate =
false;
162 if (solution == NULL)
164 solution = approxsol;
168 if (solution != NULL)
170 lastGoalMotion_ = solution;
173 std::vector<Motion*> mpath;
174 while (solution != NULL)
176 mpath.push_back(solution);
177 solution = solution->
parent;
182 for (
int i = mpath.size() - 1 ; i >= 0 ; --i)
183 path->
append(mpath[i]->state);
184 pdef_->addSolutionPath(
base::PathPtr(path), approximate, approxdif);
188 si_->freeState(xstate);
190 OMPL_INFORM(
"%s: Created %u states in %u cells", getName().c_str(), tree_.size, tree_.grid.size());
197 GridCell* cell = pdf_.sample(rng_.uniform01());
198 return cell && !cell->
data.empty() ? cell->
data[rng_.uniformInt(0, cell->
data.size() - 1)] : NULL;
204 projectionEvaluator_->computeCoordinates(motion->
state, coord);
205 GridCell* cell = tree_.grid.getCell(coord);
208 cell->
data.push_back(motion);
209 pdf_.update(cell->
data.elem_, 1.0/cell->
data.size());
213 cell = tree_.grid.createCell(coord);
214 cell->
data.push_back(motion);
215 tree_.grid.add(cell);
216 cell->
data.elem_ = pdf_.add(cell, 1.0);
223 Planner::getPlannerData(data);
225 std::vector<MotionInfo> motions;
226 tree_.grid.getContent(motions);
231 for (
unsigned int i = 0 ; i < motions.size() ; ++i)
232 for (
unsigned int j = 0 ; j < motions[i].size() ; ++j)
234 if (motions[i][j]->parent == NULL)
bool approximateSolutions
Flag indicating whether the planner is able to compute approximate solutions.
bool canSample(void) const
Return true if maxSampleCount() > 0, since in this case samples can certainly be produced.
Object containing planner generated vertex and edge data. It is assumed that all vertices are unique...
Motion * lastGoalMotion_
The most recent goal motion. Used for PlannerData computation.
std::vector< int > Coord
Definition of a coordinate within this grid.
double maxDistance_
The maximum length of a motion to be added to a tree.
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.
Encapsulate a termination condition for a motion planner. Planners will call operator() to decide whe...
_T data
The data we store in the cell.
void append(const base::State *state)
Append state to the end of this path. The memory for state is copied.
base::State * state
The state contained by the motion.
bool directed
Flag indicating whether the planner is able to account for the fact that the validity of a motion fro...
virtual void sampleGoal(State *st) const =0
Sample a state in the goal region.
The definition of a motion.
Base class for a vertex in the PlannerData structure. All derived classes must implement the clone an...
virtual void clear(void)
Clear all internal datastructures. Planner settings are not affected. Subsequent calls to solve() wil...
Invalid start state or no start state specified.
Abstract definition of a goal region that can be sampled.
double getRange(void) const
Get the range the planner is using.
#define OMPL_ERROR(fmt,...)
Log a formatted error string.
virtual void getPlannerData(base::PlannerData &data) const
Get information about the current run of the motion planner. Repeated calls to this function will upd...
double getGoalBias(void) const
Get the goal bias the planner is using.
A class to store the exit status of Planner::solve()
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...
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...
void freeMemory(void)
Free the memory allocated by this planner.
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.
virtual bool isSatisfied(const State *st) const =0
Return true if the state satisfies the goal constraints.
void setRange(double distance)
Set the range the planner is supposed to use.
PlannerSpecs specs_
The specifications of the planner (its capabilities)
Definition of a cell in this grid.
virtual void setup(void)
Perform extra configuration steps, if needed. This call will also issue a call to ompl::base::SpaceIn...
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.
EST(const base::SpaceInformationPtr &si)
Constructor.
Motion * parent
The parent motion in the exploration tree.
void addMotion(Motion *motion)
Add a motion to the exploration tree.
Motion * selectMotion(void)
Select a motion to continue the expansion of the tree from.
Definition of a geometric path.
double goalBias_
The fraction of time the goal is picked as the state to expand towards (if such a state is available)...
A boost shared pointer wrapper for ompl::base::Path.
CoordHash::const_iterator iterator
We only allow const iterators.
#define OMPL_INFORM(fmt,...)
Log a formatted information string.