BITstar.h
61 //The helper data classes, Vertex.h and IntegratedQueue.h are included *after* the declaration of the BITstar class as they are member classes of BITstar.
269 //Everything is only protected so we can create modifications without duplicating code by deriving from the class:
317 void addEdge(const VertexPtrPair& newEdge, const ompl::base::Cost& edgeCost, const bool& removeFromFree, const bool& updateDescendants);
320 void replaceParent(const VertexPtrPair& newEdge, const ompl::base::Cost& edgeCost, const bool& updateDescendants);
335 unsigned int nearestVertices(const VertexPtr& vertex, std::vector<VertexPtr>* neighbourVertices);
339 //Helper functions for sorting queues/nearest-neighbour structures and the related calculations.
383 bool isCostBetterThanOrEquivalentTo(const ompl::base::Cost& a, const ompl::base::Cost& b) const;
389 ompl::base::Cost combineCosts(const ompl::base::Cost& a, const ompl::base::Cost& b, const ompl::base::Cost& c) const;
392 ompl::base::Cost combineCosts(const ompl::base::Cost& a, const ompl::base::Cost& b, const ompl::base::Cost& c, const ompl::base::Cost& d) const;
395 double fractionalChange(const ompl::base::Cost& newCost, const ompl::base::Cost& oldCost) const;
398 double fractionalChange(const ompl::base::Cost& newCost, const ompl::base::Cost& oldCost, const ompl::base::Cost& refCost) const;
434 virtual void statusMessage(const ompl::msg::LogLevel& msgLevel, const std::string& status) const;
void publishSolution()
Publish the found solution to the ProblemDefinition.
Definition: BITstar.cpp:976
unsigned int numEdgeCollisionChecks_
The number of edge collision checks. Accessible via edgeCollisionCheckProgressProperty.
Definition: BITstar.h:631
VertexPtrNNPtr freeStateNN_
The unconnected samples as a nearest-neighbours datastructure. Sorted by nnDistance. Size accessible via currentFreeProgressProperty.
Definition: BITstar.h:543
double k_rgg_
The minimum k-nearest RGG connection term. Only a function of state dimension, so can be calculated o...
Definition: BITstar.h:564
unsigned int getSamplesPerBatch() const
Get the number of samplers per batch.
Definition: BITstar.cpp:2069
void updateSamples(const VertexConstPtr &vertex)
Update the list of free samples.
Definition: BITstar.cpp:811
unsigned int numVerticesDisconnected_
The number of graph vertices that get disconnected. These either return to being free samples or are ...
Definition: BITstar.h:622
std::list< VertexPtr > startVertices_
The start states of the problem as vertices.
Definition: BITstar.h:528
Object containing planner generated vertex and edge data. It is assumed that all vertices are unique...
Definition: PlannerData.h:163
ompl::base::OptimizationObjectivePtr opt_
Optimization objective copied from ProblemDefinition.
Definition: BITstar.h:525
std::string bestCostProgressProperty() const
Retrieve the best exact-solution cost found as a planner-progress property. (bestCost_) ...
Definition: BITstar.cpp:2280
void setNearestNeighbors()
Set a different nearest neighbours datastructure.
Definition: BITstar.cpp:587
ompl::base::Cost costToComeHeuristic(const VertexConstPtr &vertex) const
Calculate a heuristic estimate of the cost-to-come for a Vertex.
Definition: BITstar.cpp:1703
unsigned int numNearestNeighbours_
The number of nearest neighbour calls. Accessible via nearestNeighbourProgressProperty.
Definition: BITstar.h:634
void dropSample(VertexPtr oldSample)
Actually remove a sample from its NN struct.
Definition: BITstar.cpp:1377
ompl::base::Cost bestCost() const
Retrieve the best exact-solution cost found.
Definition: BITstar.cpp:2273
unsigned int numIterations() const
Get the number of iterations completed.
Definition: BITstar.cpp:2322
std::list< VertexPtr > prunedGoalVertices_
Any goal states of the problem that have been pruned.
Definition: BITstar.h:537
unsigned int numPrunings_
The number of times the graph/samples have been pruned. Accessible via pruningProgressProperty.
Definition: BITstar.h:610
ompl::base::Cost lowerBoundHeuristicEdge(const VertexConstPtrPair &edgePair) const
Calculates a heuristic estimate of the cost of a solution constrained to go through an edge...
Definition: BITstar.cpp:1682
unsigned int numIterations_
The number of iterations run. Accessible via iterationProgressProperty.
Definition: BITstar.h:604
std::string verticesConstructedProgressProperty() const
Retrieve the total number of vertices added to the graph as a planner-progress property. (numVertices_)
Definition: BITstar.cpp:2364
void setKNearest(bool useKNearest)
Enable a k-nearest search for instead of an r-disc search.
Definition: BITstar.cpp:2076
bool getStrictQueueOrdering() const
Get whether strict queue ordering is in use.
Definition: BITstar.cpp:2131
std::string verticesDisconnectedProgressProperty() const
Retrieve the number of graph vertices that are disconnected and either returned to the set of free sa...
Definition: BITstar.cpp:2378
IntegratedQueuePtr intQueue_
The integrated queue of vertices to expand and edges to process ordered on "f-value", i.e., estimated solution cost. Remaining vertex queue "size" and edge queue size are accessible via vertexQueueSizeProgressProperty and edgeQueueSizeProgressProperty, respectively.
Definition: BITstar.h:549
unsigned int nearestVertices(const VertexPtr &vertex, std::vector< VertexPtr > *neighbourVertices)
Get the nearest samples from the vertexNN_ using the appropriate "near" definition (i...
Definition: BITstar.cpp:1633
virtual bool prune()
Prune the problem. Returns true if pruning was done.
Definition: BITstar.cpp:890
Encapsulate a termination condition for a motion planner. Planners will call operator() to decide whe...
Definition: PlannerTerminationCondition.h:66
bool isCostWorseThanOrEquivalentTo(const ompl::base::Cost &a, const ompl::base::Cost &b) const
Compare whether cost a is worse or equivalent to cost b by checking that a is not better than b...
Definition: BITstar.cpp:1793
std::shared_ptr< NearestNeighbors< VertexPtr > > VertexPtrNNPtr
The OMPL::NearestNeighbors structure.
Definition: BITstar.h:137
bool getPruning() const
Get whether graph and sample pruning is in use.
Definition: BITstar.cpp:2150
virtual std::string totalStatesCreatedProgressProperty() const
Retrieve the total number of states generated as a planner-progress property. (numSamples_) ...
Definition: BITstar.cpp:2357
std::string edgeCollisionCheckProgressProperty() const
Retrieve the number of edge (or motion) collision checks (i.e., calls to SpaceInformation::checkMotio...
Definition: BITstar.cpp:2399
ompl::base::Cost costToGoHeuristic(const VertexConstPtr &vertex) const
Calculate a heuristic estimate of the cost-to-go for a Vertex.
Definition: BITstar.cpp:1729
bool checkEdge(const VertexConstPtrPair &edge)
Checks an edge for collision. A wrapper to SpaceInformation->checkMotion that tracks number of collis...
Definition: BITstar.cpp:1369
ompl::base::Cost minCost_
The minimum possible solution cost. I.e., the heuristic value of the goal.
Definition: BITstar.h:582
unsigned int nearestSamples(const VertexPtr &vertex, std::vector< VertexPtr > *neighbourSamples)
Get the nearest samples from the freeStateNN_ using the appropriate "near" definition (i...
Definition: BITstar.cpp:1611
double minimumRggR() const
Calculate the lower-bounding radius RGG term for asymptotic almost-sure convergence to the optimal pa...
Definition: BITstar.cpp:1919
std::string vertexQueueSizeProgressProperty() const
Retrieve the current number of vertices in the expansion queue as a planner-progress property...
Definition: BITstar.cpp:2308
void pruneStartsGoals()
Prune the starts and goals that have a solution heuristic that is not less than bestCost_.
Definition: BITstar.cpp:1238
std::string currentFreeProgressProperty() const
Retrieve the current number of free samples as a planner-progress property. (size of freeStateNN_) ...
Definition: BITstar.cpp:2294
bool isCostNotEquivalentTo(const ompl::base::Cost &a, const ompl::base::Cost &b) const
Compare whether cost a and cost b are not equivalent by checking if either a or b is better than the ...
Definition: BITstar.cpp:1777
unsigned int bestLength_
The number of vertices in the best solution found to date. Accessible via bestLengthProgressProperty...
Definition: BITstar.h:573
void updateStartAndGoalStates(const base::PlannerTerminationCondition &ptc)
Adds any new goals or starts that have appeared in the problem definition to the list of vertices and...
Definition: BITstar.cpp:1043
virtual void endSuccessMessage() const
The message printed when solve finishes successfully.
Definition: BITstar.cpp:1952
unsigned int numBatches() const
Retrieve the number of batches processed as the raw data. (numBatches_)
Definition: BITstar.cpp:2336
void setDelayRewiringUntilInitialSolution(bool delayRewiring)
Delay the consideration of rewiring edges until an initial solution is found. When multiple batches a...
Definition: BITstar.cpp:2176
double fractionalChange(const ompl::base::Cost &newCost, const ompl::base::Cost &oldCost) const
Calculate the fractional change of cost "newCost" from "oldCost" relative to "oldCost", i.e., (newCost - oldCost)/oldCost.
Definition: BITstar.cpp:1815
void estimateMeasures()
A debug function: Estimate the measure of the free/obstace space via sampling.
Definition: BITstar.cpp:607
bool getJustInTimeSampling() const
Get whether we're using just-in-time sampling.
Definition: BITstar.cpp:2215
double approximateDiff_
The distance of the approximate solution, set to -1.0 for non approximate solutions.
Definition: BITstar.h:601
unsigned int numUniformStates_
The number of states (vertices or samples) that were generated from a uniform distribution. Only valid when refreshSamplesOnPrune_ is true, in which case it's used to calculate the RGG term of the uniform subgraph.
Definition: BITstar.h:558
std::shared_ptr< const Vertex > VertexConstPtr
A constant vertex shared pointer.
Definition: BITstar.h:125
virtual bool resort()
Resort the queue. Returns true if any pruning was done.
Definition: BITstar.cpp:948
BITstar(const base::SpaceInformationPtr &si, const std::string &name="BITstar")
Construct!
Definition: BITstar.cpp:74
void setSamplesPerBatch(unsigned int n)
Set the number of samplers per batch.
Definition: BITstar.cpp:2062
void setStrictQueueOrdering(bool beStrict)
Enable "strict sorting" of the edge queue. Rewirings can change the position in the queue of an edge...
Definition: BITstar.cpp:2124
unsigned int numFreeStatesPruned_
The number of free states that have been pruned. Accessible via statesPrunedProgressProperty.
Definition: BITstar.h:619
virtual void updateNearestTerms()
Update the appropriate nearest-neighbour terms, r_ and k_. Performs this calculation considering the ...
Definition: BITstar.cpp:1850
bool isCostBetterThanOrEquivalentTo(const ompl::base::Cost &a, const ompl::base::Cost &b) const
Compare whether cost a is better or equivalent to cost b by checking that b is not better than a...
Definition: BITstar.cpp:1785
void getEdgeQueue(std::vector< std::pair< VertexConstPtr, VertexConstPtr > > *edgesInQueue)
Get the whole messy set of edges in the queue. Expensive but helpful for some videos.
Definition: BITstar.cpp:572
std::string bestLengthProgressProperty() const
Retrieve the length of the best exact-solution found as a planner-progress property. (bestLength_)
Definition: BITstar.cpp:2287
double rewireFactor_
The rewiring factor, s, so that r_rrg = s r_rrg* > r_rrg* (param)
Definition: BITstar.h:646
ompl::base::Cost getNextEdgeValueInQueue()
Get the value of the next edge to be processed. Causes vertices in the queue to be expanded (if neces...
Definition: BITstar.cpp:543
Random number generation. An instance of this class cannot be used by multiple threads at once (membe...
Definition: RandomNumbers.h:58
std::string nearestNeighbourProgressProperty() const
Retrieve the number of nearest neighbour calls (i.e., NearestNeighbors<T>::nearestK(...) or NearestNeighbors<T>::nearestR(...)) as a planner-progress property. (numNearestNeighbours_)
Definition: BITstar.cpp:2406
std::vector< const ompl::base::State * > bestPathFromGoalToStart() const
Extract the best solution, ordered from the goal to the start and including both the goal and the sta...
Definition: BITstar.cpp:1017
std::vector< VertexPtr > recycledSamples_
A copy of the vertices recycled into samples during this batch.
Definition: BITstar.h:555
double minimumRggK() const
Calculate the lower-bounding k-nearest RGG term for asymptotic almost-sure convergence to the optimal...
Definition: BITstar.cpp:1933
std::vector< VertexPtr > newSamples_
A copy of the new samples from this batch.
Definition: BITstar.h:552
double nnDistance(const VertexConstPtr &a, const VertexConstPtr &b) const
The distance function used for nearest neighbours. Calculates the distance directionally from the giv...
Definition: BITstar.cpp:1652
std::pair< VertexConstPtr, VertexConstPtr > VertexConstPtrPair
A pair of const vertices, i.e., an edge.
Definition: BITstar.h:135
bool delayRewiring_
Whether to delay rewiring until a solution is found (param)
Definition: BITstar.h:661
unsigned int numEdgesProcessed_
The number of edges processed, in one way or other, from the queue. Accessible via edgesProcessedProg...
Definition: BITstar.h:637
unsigned int numSamples_
The number of states generated through sampling. Accessible via statesFromSamplingProgressProperty.
Definition: BITstar.h:613
void updateGoalVertex()
The special work that needs to be done to update the goal vertex is the solution has changed...
Definition: BITstar.cpp:1468
A queue of edges to be processed that integrates both the expansion of Vertices and the ordering of t...
Definition: IntegratedQueue.h:90
ompl::base::Cost currentHeuristicEdgeTarget(const VertexConstPtrPair &edgePair) const
Calculates a heuristic estimate of the cost of a path to the target of an edge, dependent on the cost...
Definition: BITstar.cpp:1696
ompl::base::Cost trueEdgeCost(const VertexConstPtrPair &edgePair) const
The true cost of an edge, including collisions.
Definition: BITstar.cpp:1747
std::pair< const ompl::base::State *, const ompl::base::State * > getNextEdgeInQueue()
Get the next edge to be processed. Causes vertices in the queue to be expanded (if necessary) and the...
Definition: BITstar.cpp:514
A class to store the exit status of Planner::solve()
Definition: PlannerStatus.h:48
ompl::base::Cost costSampled_
The total-heuristic cost up to which we've sampled.
Definition: BITstar.h:585
A shared pointer wrapper for ompl::base::SpaceInformation.
std::string statesPrunedProgressProperty() const
Retrieve the number of states pruned from the problem as a planner-progress property. (numFreeStatesPruned_)
Definition: BITstar.cpp:2371
ompl::base::Cost lowerBoundHeuristicVertex(const VertexConstPtr &vertex) const
Calculates a heuristic estimate of the cost of a solution constrained to pass through a vertex...
Definition: BITstar.cpp:1669
bool stopOnSolnChange_
Whether to stop the planner as soon as the path changes (param)
Definition: BITstar.h:670
bool getStopOnSolnImprovement() const
Get whether BIT* stops each time a solution is found.
Definition: BITstar.cpp:2266
void setRewireFactor(double rewireFactor)
Set the rewiring scale factor, s, such that r_rrg = s r_rrg*.
Definition: BITstar.cpp:2041
std::string stateCollisionCheckProgressProperty() const
Retrieve the number of state collisions checks (i.e., calls to SpaceInformation::isValid(...)) as a planner-progress property. (numStateCollisionChecks_)
Definition: BITstar.cpp:2392
void setPruneThresholdFraction(double fractionalChange)
Set the fractional change in the solution cost necessary for pruning to occur.
Definition: BITstar.cpp:2157
An ID generator class for vertex IDs.
Definition: IdGenerator.h:58
std::pair< VertexPtr, VertexPtr > VertexPtrPair
A pair of vertices, i.e., an edge.
Definition: BITstar.h:133
std::string batchesProgressProperty() const
Retrieve the number of batches processed as a planner-progress property. (numBatches_) ...
Definition: BITstar.cpp:2343
bool getDropSamplesOnPrune() const
Get whether unconnected samples are dropped on pruning.
Definition: BITstar.cpp:2252
std::shared_ptr< IntegratedQueue > IntegratedQueuePtr
An integrated queue shared pointer.
Definition: BITstar.h:129
The vertex of the underlying graphs in BIT*.
Definition: Vertex.h:80
void setJustInTimeSampling(bool useJit)
Delay the generation of samples until they are necessary. This only works when using an r-disc connec...
Definition: BITstar.cpp:2196
ompl::base::Cost currentHeuristicEdge(const VertexConstPtrPair &edgePair) const
Calculates a heuristic estimate of the cost of a solution constrained to go through an edge...
Definition: BITstar.cpp:1689
VertexPtrNNPtr vertexNN_
The vertices as a nearest-neighbours data structure. Sorted by nnDistance. Size accessible via curren...
Definition: BITstar.h:546
bool dropSamplesOnPrune_
Whether to refresh (i.e., forget) unconnected samples on pruning (param)
Definition: BITstar.h:667
bool useStrictQueueOrdering_
Whether to use a strict-queue ordering (param)
Definition: BITstar.h:643
A shared pointer wrapper for ompl::base::OptimizationObjective.
base::PlannerStatus solve(const base::PlannerTerminationCondition &ptc)
Solve.
Definition: BITstar.cpp:413
std::list< VertexPtr > goalVertices_
The goal states of the problem as vertices.
Definition: BITstar.h:531
unsigned int numRewirings_
The number of times a state in the graph was rewired. Accessible via rewiringProgressProperty.
Definition: BITstar.h:625
void addVertex(const VertexPtr &newVertex, const bool &removeFromFree)
Add a vertex to the graph.
Definition: BITstar.cpp:1584
unsigned int numVertices_
The number of vertices ever added to the graph. Will count vertices twice if they spend any time disc...
Definition: BITstar.h:616
void pruneSamples()
Prune all samples with a solution heuristic that is not less than the bestCost_.
Definition: BITstar.cpp:1330
ompl::base::Cost currentHeuristicVertex(const VertexConstPtr &vertex) const
Calculates a heuristic estimate of the cost of a solution constrained to pass through a vertex...
Definition: BITstar.cpp:1676
double calculateR(unsigned int N) const
Calculate the r for r-disc nearest neighbours, a function of the current graph.
Definition: BITstar.cpp:1897
ompl::base::Cost prunedCost_
The cost to which the graph has been pruned. We will only prune the graph if bestCost_ is less than t...
Definition: BITstar.h:576
bool isCostWorseThan(const ompl::base::Cost &a, const ompl::base::Cost &b) const
Compare whether cost a is worse than cost b by checking whether b is better than a.
Definition: BITstar.cpp:1769
void getVertexQueue(std::vector< VertexConstPtr > *verticesInQueue)
Get the whole set of vertices to be expanded. Expensive but helpful for some videos.
Definition: BITstar.cpp:579
ompl::base::Cost combineCosts(const ompl::base::Cost &a, const ompl::base::Cost &b, const ompl::base::Cost &c) const
Combine 3 costs.
Definition: BITstar.cpp:1801
std::string edgeQueueSizeProgressProperty() const
Retrieve the current number of edges in the search queue as a planner-progress property. (The size of the edge subqueue of intQueue_)
Definition: BITstar.cpp:2315
unsigned int numBatches_
The number of batches processed. Accessible via batchesProgressProperty.
Definition: BITstar.h:607
ompl::base::Cost neighbourhoodCost(const VertexConstPtr &vertex) const
Calculate the max req'd cost to define a neighbourhood around a state. Currently only implemented for...
Definition: BITstar.cpp:1754
virtual void statusMessage(const ompl::msg::LogLevel &msgLevel, const std::string &status) const
A debug-level status message for debugging.
Definition: BITstar.cpp:1966
void addEdge(const VertexPtrPair &newEdge, const ompl::base::Cost &edgeCost, const bool &removeFromFree, const bool &updateDescendants)
Add an edge from the edge queue to the tree. Will add the state to the vertex queue if it's new to th...
Definition: BITstar.cpp:1391
virtual void endFailureMessage() const
The message printed when solve finishes unsuccessfully.
Definition: BITstar.cpp:1959
std::string edgesProcessedProgressProperty() const
Retrieve the total number of edges processed from the queue as a planner-progress property...
Definition: BITstar.cpp:2413
void setDropSamplesOnPrune(bool dropSamples)
Drop all unconnected samples when pruning, regardless of their heuristic value. This provides a metho...
Definition: BITstar.cpp:2222
double prunedMeasure_
The measure of the problem domain when we pruned the graph.
Definition: BITstar.h:579
void setPruning(bool prune)
Enable pruning of vertices/samples that CANNOT improve the current solution. When a vertex in the gra...
Definition: BITstar.cpp:2138
std::string iterationProgressProperty() const
Retrieve the number of iterations as a planner-progress property. (numIterations_) ...
Definition: BITstar.cpp:2329
std::string pruningProgressProperty() const
Retrieve the number of graph prunings performed as a planner-progress property. (numPrunings_) ...
Definition: BITstar.cpp:2350
bool getDelayRewiringUntilInitialSolution() const
Get whether BIT* is delaying rewiring until a solution is found.
Definition: BITstar.cpp:2189
double getPruneThresholdFraction() const
Get the fractional change in the solution cost necessary for pruning to occur.
Definition: BITstar.cpp:2169
std::list< VertexPtr > prunedStartVertices_
Any start states of the problem that have been pruned.
Definition: BITstar.h:534
double pruneFraction_
The fractional decrease in solution cost required to trigger pruning (param)
Definition: BITstar.h:658
ompl::base::Cost bestCost_
The best cost found to date. This is the maximum total-heuristic cost of samples we'll consider...
Definition: BITstar.h:570
std::string rewiringProgressProperty() const
Retrieve the number of global-search edges that rewired the graph as a planner-progress property...
Definition: BITstar.cpp:2385
void replaceParent(const VertexPtrPair &newEdge, const ompl::base::Cost &edgeCost, const bool &updateDescendants)
Replace the parent edge with the given new edge and cost.
Definition: BITstar.cpp:1434
std::string currentVertexProgressProperty() const
Retrieve the current number of vertices in the graph as a planner-progress property. (Size of vertexNN_)
Definition: BITstar.cpp:2301
unsigned int calculateK(unsigned int N) const
Calculate the k for k-nearest neighours, a function of the current graph.
Definition: BITstar.cpp:1911
Definition of a cost value. Can represent the cost of a motion or the cost of a state.
Definition: Cost.h:47
ompl::base::Cost edgeCostHeuristic(const VertexConstPtrPair &edgePair) const
Calculate a heuristic estimate of the cost an edge between two Vertices.
Definition: BITstar.cpp:1722
void setStopOnSolnImprovement(bool stopOnChange)
Stop the planner each time a solution improvement is found. Useful for examining the intermediate sol...
Definition: BITstar.cpp:2259
unsigned int numStateCollisionChecks_
The number of state collision checks. Accessible via stateCollisionCheckProgressProperty.
Definition: BITstar.h:628
virtual void goalMessage() const
The message printed when a goal is found/improved.
Definition: BITstar.cpp:1945