RandomGeometricGraph.cpp
54 RandomGeometricGraph::RandomGeometricGraph(const std::shared_ptr<ompl::base::SpaceInformation> &spaceInfo,
57 : samples_(8 /* degree */, 4 /* min degree */, 12 /* max degree */, 50 /* max num points per leaf */,
150 {
168 {
203 // First update the goals. We have to call inputStates->nextGoal(terminationCondition) at least once
204 // (regardless of the return value of inputStates->moreGoalStates()) in case the termination condition
210 // Get a new goal. If there are none, or the underlying state is invalid this will be a nullptr.
243 // If we added a new start and have previously pruned goals, we might want to add the goals back.
277 // If we added a new goal and have previously pruned starts, we might want to add the starts back.
291 heuristicCost, objective_->motionCostHeuristic(goal->raw(), (*it)->raw()));
327 // Compute the minimum possible cost for this problem given the start and goal states and an admissible
428 // Remove the edge from the caches (using the erase-remove idiom). Take this opportunity to remove
443 neighbor.lock()->getId() == edge.source->getId();
467 assert(objective_->isCostEquivalentTo(start->getLowerBoundCostToCome(), objective_->identityCost()));
468 assert(start->getLowerBoundEffortToCome() == 0u);
487 assert(objective_->isCostEquivalentTo(goal->getLowerBoundCostToGo(), objective_->identityCost()));
497 std::shared_ptr<State> RandomGeometricGraph::getNewSample(const ompl::base::PlannerTerminationCondition& terminationCondition)
498 {
515 {
522 {
544 }
591 // because all new states will be in the informed set, and its known how many of them will be added.
592 // If pruning is enabled, we can do this now. After pruning all remaining states are in the informed
646 {
731 state->neighbors_.first = tag_;
756 }
761 {
766 {
848 // Count the number of samples that can possibly improve the solution and subtract the start and goal
871 return objective_->isCostBetterThan(solutionCost_, objective_->combineCosts(costToCome, costToGo));
875 ompl::base::Cost RandomGeometricGraph::lowerBoundCostToCome(const std::shared_ptr<State> &state) const
888 unsigned int RandomGeometricGraph::lowerBoundEffortToCome(const std::shared_ptr<State> &state) const
891 // (it is possible to compute a better bound, but empirically, it is not worth the computational
899 // The minimum number of collision checks from any of the starts to the state we are checking for.
910 unsigned int RandomGeometricGraph::inadmissibleEffortToCome(const std::shared_ptr<State> &state) const
921 ompl::base::Cost RandomGeometricGraph::lowerBoundCostToGo(const std::shared_ptr<State> &state) const
967 std::size_t RandomGeometricGraph::computeNumberOfNeighbors(std::size_t numInformedSamples) const
PlannerTerminationCondition plannerAlwaysTerminatingCondition()
Simple termination condition that always returns true. The termination condition will always be met.
Definition: PlannerTerminationCondition.cpp:190
bool haveMoreStartStates() const
Check if there are more potential start states.
Definition: Planner.cpp:339
Helper class to extract valid start & goal states. Usually used internally by planners.
Definition: Planner.h:141
bool hasStartState() const
Returns whether a start state is available.
Definition: RandomGeometricGraph.cpp:493
void enableMultiquery(bool multiquery)
Enable multiquery usage of the graph.
Definition: RandomGeometricGraph.cpp:741
void setMaxNumberOfGoals(unsigned int maxNumberOfGoals)
Sets the maximum number of goals EIT* will sample from sampleable goal regions.
Definition: RandomGeometricGraph.cpp:761
void setUseKNearest(bool useKNearest)
Set whether to use a k-nearest connection model. If false, it uses an r-disc model.
Definition: RandomGeometricGraph.cpp:751
void updateStartAndGoalStates(const ompl::base::PlannerTerminationCondition &terminationCondition, ompl::base::PlannerInputStates *inputStates)
Adds new starts and goals to the graph if available and creates a new informed sampler if necessary.
Definition: RandomGeometricGraph.cpp:291
unsigned int getMaxNumberOfGoals() const
Returns the maximum number of goals EIT* will sample from sampleable goal regions.
Definition: RandomGeometricGraph.cpp:766
RandomGeometricGraph(const std::shared_ptr< ompl::base::SpaceInformation > &spaceInfo, const ompl::base::Cost &solutionCost)
Constructs a random geometric graph with the given space information and reference to the current sol...
Definition: RandomGeometricGraph.cpp:150
bool isMultiqueryEnabled() const
Returns Whether multiquery usage of the graph is enabled.
Definition: RandomGeometricGraph.cpp:746
bool getUseKNearest() const
Returns whether the graph uses a k-nearest connection model. If false, it uses an r-disc model.
Definition: RandomGeometricGraph.cpp:756
unsigned int inadmissibleEffortToCome(const std::shared_ptr< State > &state) const
Returns the inadmissible effort to come.
Definition: RandomGeometricGraph.cpp:1006
bool isGoal(const std::shared_ptr< State > &state) const
Returns whether the given state is a goal state.
Definition: RandomGeometricGraph.cpp:509
unsigned int getNumberOfValidSamples() const
Returns the number of valid samples.
Definition: RandomGeometricGraph.cpp:483
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
void setRadiusFactor(double factor)
Sets the radius factor (eta in the paper).
Definition: RandomGeometricGraph.cpp:448
Definition of a cost value. Can represent the cost of a motion or the cost of a state.
Definition: Cost.h:111
bool isStart(const std::shared_ptr< State > &state) const
Returns whether the given state is a start state.
Definition: RandomGeometricGraph.cpp:503
std::size_t getTag() const
Returns the tag of the current RGG.
Definition: RandomGeometricGraph.cpp:544
unsigned int getEffortThreshold() const
Gets the effort threshold.
Definition: RandomGeometricGraph.cpp:463
unsigned int getNumberOfSampledStates() const
Returns the number of sampled states.
Definition: RandomGeometricGraph.cpp:478
bool addStates(std::size_t numStates, const ompl::base::PlannerTerminationCondition &terminationCondition)
Samples random states and adds them to the graph.
Definition: RandomGeometricGraph.cpp:646
const std::vector< std::shared_ptr< State > > & getStartStates() const
Returns the start states.
Definition: RandomGeometricGraph.cpp:468
double unitNBallMeasure(unsigned int N)
The Lebesgue measure (i.e., "volume") of an n-dimensional ball with a unit radius.
Definition: GeometricEquations.cpp:55
const std::vector< std::shared_ptr< State > > & getGoalStates() const
Returns the goal states.
Definition: RandomGeometricGraph.cpp:473
Encapsulate a termination condition for a motion planner. Planners will call operator() to decide whe...
Definition: PlannerTerminationCondition.h:127
const State * nextStart()
Return the next valid start state or nullptr if no more valid start states are available.
Definition: Planner.cpp:228
void setup(const std::shared_ptr< ompl::base::ProblemDefinition > &problem, ompl::base::PlannerInputStates *inputStates)
Setup the graph with the given problem definition and planner input states.
Definition: RandomGeometricGraph.cpp:168
std::shared_ptr< State > registerStartState(const ompl::base::State *start)
Sets the start state.
Definition: RandomGeometricGraph.cpp:549
void prune()
Prunes the graph of states that can not improve the current solution.
Definition: RandomGeometricGraph.cpp:877
const State * nextGoal(const PlannerTerminationCondition &ptc)
Return the next valid goal state or nullptr if no more valid goal states are available....
Definition: Planner.cpp:265
void clearQuery()
Clears all query-specific structures, such as start and goal states.
Definition: RandomGeometricGraph.cpp:261
ompl::base::Cost minPossibleCost() const
Returns the minimum possible cost for the current problem, using admissible cost estimates to calcula...
Definition: RandomGeometricGraph.cpp:443
const OptimizationObjectivePtr & getOptimizationObjective() const
Get the optimization objective to be considered during planning.
Definition: ProblemDefinition.h:347
void clear()
Clears all internal planner structures but retains settings. Subsequent calls to solve() will start f...
Definition: RandomGeometricGraph.cpp:201
bool hasGoalState() const
Returns whether a goal state is available.
Definition: RandomGeometricGraph.cpp:498
unsigned int getNumberOfNearestNeighborCalls() const
Returns the number of nearest neighbor calls.
Definition: RandomGeometricGraph.cpp:488
void setEffortThreshold(const unsigned int threshold)
Sets the effort threshold.
Definition: RandomGeometricGraph.cpp:458
std::vector< std::weak_ptr< State > > getNeighbors(const std::shared_ptr< State > &state) const
Returns the neighbors of a state.
Definition: RandomGeometricGraph.cpp:772
std::shared_ptr< State > registerGoalState(const ompl::base::State *goal)
Sets the goal state.
Definition: RandomGeometricGraph.cpp:569
void registerWhitelistedState(const std::shared_ptr< State > &state) const
Registers a whitelisted state.
Definition: RandomGeometricGraph.cpp:588
bool haveMoreGoalStates() const
Check if there are more potential goal states.
Definition: Planner.cpp:346
std::vector< std::shared_ptr< State > > getStates() const
Returns all sampled states (that have not been pruned).
Definition: RandomGeometricGraph.cpp:515
void registerInvalidEdge(const Edge &edge) const
Registers an invalid edge.
Definition: RandomGeometricGraph.cpp:522
bool isPruningEnabled() const
Returns Whether pruning is enabled.
Definition: RandomGeometricGraph.cpp:736
double getRadiusFactor() const
Returns the radius factor (eta in the paper).
Definition: RandomGeometricGraph.cpp:453