Loading...
Searching...
No Matches
TRRTstar.cpp
49ompl::geometric::TRRTstar::TRRTstar(const base::SpaceInformationPtr &si) : base::Planner(si, "TRRTstar")
55 Planner::declareParam<double>("range", this, &TRRTstar::setRange, &TRRTstar::getRange, "0.:1.:10000.");
56 Planner::declareParam<double>("goal_bias", this, &TRRTstar::setGoalBias, &TRRTstar::getGoalBias, "0.:.05:1.");
57 Planner::declareParam<double>("rewire_factor", this, &TRRTstar::setRewireFactor, &TRRTstar::getRewireFactor,
59 Planner::declareParam<bool>("use_k_nearest", this, &TRRTstar::setKNearest, &TRRTstar::getKNearest, "0,1");
60 Planner::declareParam<bool>("delay_collision_checking", this, &TRRTstar::setDelayCC, &TRRTstar::getDelayCC, "0,1");
61 Planner::declareParam<bool>("tree_pruning", this, &TRRTstar::setTreePruning, &TRRTstar::getTreePruning, "0,1");
62 Planner::declareParam<double>("prune_threshold", this, &TRRTstar::setPruneThreshold, &TRRTstar::getPruneThreshold,
64 Planner::declareParam<bool>("use_admissible_heuristic", this, &TRRTstar::setAdmissibleCostToCome,
66 Planner::declareParam<unsigned int>("number_sampling_attempts", this, &TRRTstar::setNumSamplingAttempts,
77 Planner::declareParam<double>("cost_threshold", this, &TRRTstar::setCostThreshold, &TRRTstar::getCostThreshold);
90 if (!si_->getStateSpace()->hasSymmetricDistance() || !si_->getStateSpace()->hasSymmetricInterpolate())
92 OMPL_WARN("%s requires a state space with symmetric distance and symmetric interpolation.", getName().c_str());
97 nn_->setDistanceFunction([this](const Motion *a, const Motion *b) { return distanceFunction(a, b); });
109 OMPL_INFORM("%s: No optimization objective specified. Defaulting to optimizing mechanical work "
120 OMPL_INFORM("%s: problem definition is not set, deferring setup completion...", getName().c_str());
157ompl::base::PlannerStatus ompl::geometric::TRRTstar::solve(const base::PlannerTerminationCondition &ptc)
205 OMPL_INFORM("%s: Started planning with %u states. Seeking a solution better than %.5f.", getName().c_str(),
209 OMPL_WARN("%s: The state space (%s) is not metric and as a result the optimization objective may not satisfy "
214 const base::ReportIntermediateSolutionFn intermediateSolutionCallback = pdef_->getIntermediateSolutionCallback();
234 OMPL_INFORM("%s: Starting planning with existing solution of cost %.5f", getName().c_str(), bestCost_.value());
242 std::min(maxDistance_, r_rrt_ * std::pow(log((double)(nn_->size() + 1u)) / ((double)(nn_->size() + 1u)),
255 // Goal samples are only sampled until maxSampleCount() goals are in the tree, to prohibit duplicate goal
257 if (goalMotions_.size() < goal_s->maxSampleCount() && rng_.uniform01() < goalBias_ && goal_s->canSample())
261 // Attempt to generate a sample, if we fail (e.g., too many rejection attempts), skip the remainder of this
598 OMPL_INFORM("%s: Created %u new states. Checked %u rewire options. %u goal states in tree. Final solution cost "
618 maxDistance_, r_rrt_ * std::pow(log(cardDbl) / cardDbl, 1 / static_cast<double>(si_->getStateDimension())));
675 data.addEdge(base::PlannerDataVertex(motion->parent->state), base::PlannerDataVertex(motion->state));
697 // We are only pruning motions if they, AND all descendents, have a estimated cost greater than pruneTreeCost
698 // The easiest way to do this is to find leaves that should be pruned and ascend up their ancestry until a
700 // To avoid making an intermediate copy of the NN structure, we process the tree by descending down from the
702 // In the first pass, all Motions with a cost below pruneTreeCost, or Motion's with children with costs below
704 // while all other Motions are stored as either a 'leaf' or 'chain' Motion. After all the leaves are
707 // This avoids (1) copying the NN structure into an intermediate variable and (2) the use of the expensive
809 goalMotions_.erase(std::remove(goalMotions_.begin(), goalMotions_.end(), leavesToPrune.front()),
865void ompl::geometric::TRRTstar::addChildrenToList(std::queue<Motion *, std::deque<Motion *>> *motionList,
874bool ompl::geometric::TRRTstar::keepCondition(const Motion *motion, const base::Cost &threshold) const
877 // if !(threshold < heuristic), as if b is not better than a, then a is better than, or equal to, b
920 OMPL_INFORM("%s: No cost-to-go heuristic set. Informed techniques will not work well.", getName().c_str());
948 k_rrt_ = rewireFactor_ * (std::pow(2, dimDbl + 1) * boost::math::constants::e<double>() * (1.0 + 1.0 / dimDbl));
951 // If we're not using the informed measure, prunedMeasure_ will be set to si_->getSpaceMeasure();
953 std::pow(2 * (1.0 + 1.0 / dimDbl) * (prunedMeasure_ / unitNBallMeasure(si_->getStateDimension())),
Definition of a cost value. Can represent the cost of a motion or the cost of a state.
Definition Cost.h:48
Abstract definition of a goal region that can be sampled.
Definition GoalSampleableRegion.h:48
virtual bool isSatisfied(const State *st) const =0
Return true if the state satisfies the goal constraints.
Base class for a vertex in the PlannerData structure. All derived classes must implement the clone an...
Definition PlannerData.h:59
Object containing planner generated vertex and edge data. It is assumed that all vertices are unique,...
Definition PlannerData.h:175
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 PlannerData.cpp:405
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...
Definition PlannerData.cpp:414
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...
Definition PlannerData.cpp:424
Encapsulate a termination condition for a motion planner. Planners will call operator() to decide whe...
Definition PlannerTerminationCondition.h:64
void terminate() const
Notify that the condition for termination should become true, regardless of what eval() returns....
Definition PlannerTerminationCondition.cpp:169
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:106
base::Cost incCost
The incremental cost of this motion's parent to this motion (this is stored to save distance computat...
Definition TRRTstar.h:337
std::vector< Motion * > children
The set of motions descending from the current motion.
Definition TRRTstar.h:340
base::Cost worstCost_
The least desirable (e.g., maximum) cost value in the search tree.
Definition TRRTstar.h:496
base::Cost solutionHeuristic(const Motion *motion) const
Computes the solution cost heuristically as the cost to come from start to the motion plus the cost t...
Definition TRRTstar.cpp:888
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 TRRTstar.cpp:659
std::shared_ptr< NearestNeighbors< Motion * > > nn_
A nearest-neighbors datastructure containing the tree of motions.
Definition TRRTstar.h:416
void calculateRewiringLowerBounds()
Calculate the k_RRG* and r_RRG* terms.
Definition TRRTstar.cpp:943
bool delayCC_
Option to delay and reduce collision checking within iterations.
Definition TRRTstar.h:442
double pruneThreshold_
The tree is pruned when the change in solution cost is greater than this fraction.
Definition TRRTstar.h:457
double goalBias_
The fraction of time the goal is picked as the state to expand towards (if such a state is available)...
Definition TRRTstar.h:420
std::vector< Motion * > goalMotions_
A list of states in the tree that satisfy the goal condition.
Definition TRRTstar.h:451
bool useAdmissibleCostToCome_
The admissibility of the new-state rejection heuristic.
Definition TRRTstar.h:460
void setup() override
Perform extra configuration steps, if needed. This call will also issue a call to ompl::base::SpaceIn...
Definition TRRTstar.cpp:85
void removeFromParent(Motion *m)
Removes the given motion from the parent's child list.
Definition TRRTstar.cpp:623
double rewireFactor_
The rewiring factor, s, so that r_rrt = s \times r_rrt* > r_rrt* (or k_rrt = s \times k_rrt* > k_rrt*...
Definition TRRTstar.h:433
double prunedMeasure_
The measure of the problem when we pruned it (if this isn't in use, it will be set to si_->getSpaceMe...
Definition TRRTstar.h:479
void getNeighbors(Motion *motion, std::vector< Motion * > &nbh) const
Gets the neighbours of a given motion, using either k-nearest of radius as appropriate.
Definition TRRTstar.cpp:606
bool keepCondition(const Motion *motion, const base::Cost &threshold) const
Check whether the given motion passes the specified cost threshold, meaning it will be kept during pr...
Definition TRRTstar.cpp:874
void clear() override
Clear all internal datastructures. Planner settings are not affected. Subsequent calls to solve() wil...
Definition TRRTstar.cpp:135
void addChildrenToList(std::queue< Motion *, std::deque< Motion * > > *motionList, Motion *motion)
Add the children of a vertex to the given list.
Definition TRRTstar.cpp:865
int pruneTree(const base::Cost &pruneTreeCost)
Prunes all those states which estimated total cost is higher than pruneTreeCost. Returns the number o...
Definition TRRTstar.cpp:679
double temp_
Temperature parameter used to control the difficulty level of transition tests. Low temperatures limi...
Definition TRRTstar.h:493
base::Cost costThreshold_
All motion costs must be better than this cost (default is infinity).
Definition TRRTstar.h:499
double distanceFunction(const Motion *a, const Motion *b) const
Compute distance between motions (actually distance between contained states).
Definition TRRTstar.h:368
void updateChildCosts(Motion *m)
Updates the cost of the children of this node if the cost up to this node has changed.
Definition TRRTstar.cpp:635
void setTreePruning(bool prune)
Controls whether the tree is pruned during the search. This pruning removes a vertex if and only if i...
Definition TRRTstar.cpp:914
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 TRRTstar.cpp:157
double tempChangeFactor_
The value of the expression exp^T_rate. The temperature is increased by this factor whenever the tran...
Definition TRRTstar.h:503
bool transitionTest(const base::Cost &motionCost)
Filter irrelevant configuration regarding the search of low-cost paths before inserting into tree.
Definition TRRTstar.cpp:957
This class contains methods that automatically configure various parameters for motion planning....
Definition SelfConfig.h:59
static NearestNeighbors< _T > * getDefaultNearestNeighbors(const base::Planner *planner)
Select a default nearest neighbor datastructure for the given space.
Definition SelfConfig.h:105
void configurePlannerRange(double &range)
Compute what a good length for motion segments is.
Definition SelfConfig.cpp:225
This namespace contains sampling based planning routines shared by both planning under geometric cons...
Definition ConstrainedSpaceInformation.h:55
std::function< void(const Planner *, const std::vector< const base::State * > &, const Cost)> ReportIntermediateSolutionFn
When a planner has an intermediate solution (e.g., optimizing planners), a function with this signatu...
Definition ProblemDefinition.h:143
double unitNBallMeasure(unsigned int N)
The Lebesgue measure (i.e., "volume") of an n-dimensional ball with a unit radius.
Definition GeometricEquations.cpp:55
Representation of a solution to a planning problem.
Definition ProblemDefinition.h:70
void setApproximate(double difference)
Specify that the solution is approximate and set the difference to the goal.
Definition ProblemDefinition.h:88
void setPlannerName(const std::string &name)
Set the name of the planner used to compute this solution.
Definition ProblemDefinition.h:104
void setOptimized(const OptimizationObjectivePtr &opt, Cost cost, bool meetsObjective)
Set the optimization objective used to optimize this solution, the cost of the solution and whether i...
Definition ProblemDefinition.h:96
A class to store the exit status of Planner::solve().
Definition PlannerStatus.h:49
@ UNRECOGNIZED_GOAL_TYPE
The goal is of a type that a planner does not recognize.
Definition PlannerStatus.h:60