All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
BITstar.cpp
74 BITstar::BITstar(const ompl::base::SpaceInformationPtr& si, const std::string& name /*= "BITstar"*/)
92 bestCost_( std::numeric_limits<double>::infinity() ), //Gets set in setup to the proper calls from OptimizationObjective
94 prunedCost_( std::numeric_limits<double>::infinity() ), //Gets set in setup to the proper calls from OptimizationObjective
96 minCost_( std::numeric_limits<double>::infinity() ), //Gets set in setup to the proper calls from OptimizationObjective
97 costSampled_( std::numeric_limits<double>::infinity() ), //Gets set in setup to the proper calls from OptimizationObjective
125 //Make sure the default name reflects the default k-nearest setting, if not overridden to something else
147 Planner::declareParam<double>("rewire_factor", this, &BITstar::setRewireFactor, &BITstar::getRewireFactor, "1.0:0.01:3.0");
148 Planner::declareParam<unsigned int>("samples_per_batch", this, &BITstar::setSamplesPerBatch, &BITstar::getSamplesPerBatch, "1:1:1000000");
149 Planner::declareParam<bool>("use_k_nearest", this, &BITstar::setKNearest, &BITstar::getKNearest, "0,1");
150 Planner::declareParam<bool>("use_graph_pruning", this, &BITstar::setPruning, &BITstar::getPruning, "0,1");
151 Planner::declareParam<double>("prune_threshold_as_fractional_cost_change", this, &BITstar::setPruneThresholdFraction, &BITstar::getPruneThresholdFraction, "0.0:0.01:1.0");
152 Planner::declareParam<bool>("delay_rewiring_to_first_solution", this, &BITstar::setDelayRewiringUntilInitialSolution, &BITstar::getDelayRewiringUntilInitialSolution, "0,1");
153 Planner::declareParam<bool>("use_just_in_time_sampling", this, &BITstar::setJustInTimeSampling, &BITstar::getJustInTimeSampling, "0,1");
154 Planner::declareParam<bool>("drop_unconnected_samples_on_prune", this, &BITstar::setDropSamplesOnPrune, &BITstar::getDropSamplesOnPrune, "0,1");
155 Planner::declareParam<bool>("stop_on_each_solution_improvement", this, &BITstar::setStopOnSolnImprovement, &BITstar::getStopOnSolnImprovement, "0,1");
157 //More advanced setting callbacks that aren't necessary to be exposed to Python. Uncomment if desired.
158 //Planner::declareParam<bool>("use_strict_queue_ordering", this, &BITstar::setStrictQueueOrdering, &BITstar::getStrictQueueOrdering, "0,1");
159 //Planner::declareParam<bool>("use_edge_failure_tracking", this, &BITstar::setUseFailureTracking, &BITstar::getUseFailureTracking, "0,1");
162 addPlannerProgressProperty("best cost DOUBLE", std::bind(&BITstar::bestCostProgressProperty, this));
163 addPlannerProgressProperty("number of segments in solution path INTEGER", std::bind(&BITstar::bestLengthProgressProperty, this));
164 addPlannerProgressProperty("current free states INTEGER", std::bind(&BITstar::currentFreeProgressProperty, this));
165 addPlannerProgressProperty("current graph vertices INTEGER", std::bind(&BITstar::currentVertexProgressProperty, this));
166 addPlannerProgressProperty("state collision checks INTEGER", std::bind(&BITstar::stateCollisionCheckProgressProperty, this));
167 addPlannerProgressProperty("edge collision checks INTEGER", std::bind(&BITstar::edgeCollisionCheckProgressProperty, this));
168 addPlannerProgressProperty("nearest neighbour calls INTEGER", std::bind(&BITstar::nearestNeighbourProgressProperty, this));
171 //addPlannerProgressProperty("vertex queue size INTEGER", std::bind(&BITstar::vertexQueueSizeProgressProperty, this));
172 //addPlannerProgressProperty("edge queue size INTEGER", std::bind(&BITstar::edgeQueueSizeProgressProperty, this));
173 //addPlannerProgressProperty("iterations INTEGER", std::bind(&BITstar::iterationProgressProperty, this));
174 //addPlannerProgressProperty("batches INTEGER", std::bind(&BITstar::batchesProgressProperty, this));
175 //addPlannerProgressProperty("graph prunings INTEGER", std::bind(&BITstar::pruningProgressProperty, this));
176 //addPlannerProgressProperty("total states generated INTEGER", std::bind(&BITstar::totalStatesCreatedProgressProperty, this));
177 //addPlannerProgressProperty("vertices constructed INTEGER", std::bind(&BITstar::verticesConstructedProgressProperty, this));
178 //addPlannerProgressProperty("states pruned INTEGER", std::bind(&BITstar::statesPrunedProgressProperty, this));
179 //addPlannerProgressProperty("graph vertices disconnected INTEGER", std::bind(&BITstar::verticesDisconnectedProgressProperty, this));
180 //addPlannerProgressProperty("rewiring edges INTEGER", std::bind(&BITstar::rewiringProgressProperty, this));
208 OMPL_INFORM("%s: No optimization objective specified. Defaulting to optimizing path length.", Planner::getName().c_str());
209 Planner::pdef_->setOptimizationObjective( std::make_shared<base::PathLengthOptimizationObjective> (Planner::si_) );
217 OMPL_ERROR("%s::setup() BIT* currently only supports goals that can be cast to a sampleable goal region (i.e., are countable sets).", Planner::getName().c_str());
229 //Only allocate if they are empty (as they can be set to a specific version by a call to setNearestNeighbors)
277 //A not horrible place to start would be hypercube proportional to the distance between the start and goal. It's not *great*, but at least it sort of captures the order-of-magnitude of the problem.
283 throw ompl::Exception("For unbounded planning problems, just-in-time sampling must be enabled before calling setup.");
290 throw ompl::Exception("For unbounded planning problems, at least one start and one goal must exist before calling setup.");
297 //The scale on the maximum distance, i.e. the width of the hypercube is equal to this value times the distance between start and goal.
302 for (std::list<VertexPtr>::const_iterator sIter = startVertices_.begin(); sIter != startVertices_.end(); ++sIter)
304 for (std::list<VertexPtr>::const_iterator gIter = goalVertices_.begin(); gIter != goalVertices_.end(); ++gIter)
306 maxDist = std::max(maxDist, Planner::si_->distance((*sIter)->stateConst(), (*gIter)->stateConst()));
416 OMPL_INFORM("%s: Searching for a solution to the given planning problem.", Planner::getName().c_str());
421 //If we don't have a goal yet, recall updateStartAndGoalStates, but wait for the first goal (or until the PTC comes true and we give up):
427 //Run the outerloop until we're stopped, a suitable cost is found, or until we find the minimum possible cost within tolerance:
428 while (opt_->isSatisfied(bestCost_) == false && ptc == false && (opt_->isCostBetterThan(minCost_, bestCost_) == true || Planner::pis_.haveMoreStartStates() == true || Planner::pis_.haveMoreGoalStates() == true) && stopLoop_ == false)
466 for (std::vector<VertexPtr>::const_iterator sIter = samples.begin(); sIter != samples.end(); ++sIter)
485 for (std::vector<VertexPtr>::const_iterator vIter = vertices.begin(); vIter != vertices.end(); ++vIter)
499 data.addEdge(ompl::base::PlannerDataVertex((*vIter)->getParentConst()->stateConst()), ompl::base::PlannerDataVertex((*vIter)->stateConst()));
530 nextEdge = std::make_pair(intQueue_->frontEdge().first->state(), intQueue_->frontEdge().second->state());
572 void BITstar::getEdgeQueue(std::vector<std::pair<VertexConstPtr, VertexConstPtr> >* edgesInQueue)
589 //Check if the problem is already setup, if so, the NN structs have data in them and you can't really change them:
592 throw ompl::Exception("The type of nearest neighbour datastructure cannot be changed once a planner is setup. ");
609 OMPL_INFORM("%s: Estimating the measure of the planning domain. This is a debugging function that does not have any effect on the planner.", Planner::getName().c_str());
668 OMPL_INFORM("%s: %u samples (%u free, %u in collision) from a space with measure %.4f estimates %.2f%% free and %.2f%% in collision (measures of %.4f and %.4f, respectively).", Planner::getName().c_str(), numTotalSamples, numFreeSamples, numObsSamples, totalMeasure, 100.0*fractionFree, 100.0*fractionObs, freeMeasure, obsMeasure);
690 //If it is, then we've hit a rare condition where we emptied it without having to sort it, so address that
695 //If not, then we're either just starting the problem, or just finished a batch. Either way, make a batch of samples and fill the queue for the first time:
713 if (opt_->isCostBetterThan( this->combineCosts(bestEdge.first->getCost(), this->edgeCostHeuristic(bestEdge), this->costToGoHeuristic(bestEdge.second)), bestCost_ ) == true)
724 if (opt_->isCostBetterThan( this->combineCosts(this->costToComeHeuristic(bestEdge.first), trueEdgeCost, this->costToGoHeuristic(bestEdge.second)), bestCost_ ) == true)
731 if (opt_->isCostBetterThan( opt_->combineCosts(bestEdge.first->getCost(), trueEdgeCost), bestEdge.second->getCost() ) == true)
733 //YAAAAH. Add the edge! Allowing for the sample to be removed from free if it is not currently connected and otherwise propagate cost updates to descendants.
734 //addEdge will update the queue and handle the extra work that occurs if this edge improves the solution.
750 //The edge cannot improve our solution, but the queue is imperfectly sorted, so we must resort before we give up.
755 //Else, I cannot improve the current solution, and as the queue is perfectly sorted and I am the best edge, no one can improve the current solution . Give up on the batch:
817 //Check if we need to generate new samples inorder to completely cover the neighbourhood of the vertex
833 //Calculate the sample density given the number of samples per batch and the measure of this batch by assuming that this batch will fill the same measure as the previous
898 if ( (usePruning_ == true) && (hasSolution_ == true) && (std::abs(this->fractionalChange(bestCost_, prunedCost_)) > pruneFraction_) )
904 //Is there good reason to prune? I.e., is the informed subset measurably less than the total problem domain? If an informed measure is not available, we'll assume yes:
905 if ( (sampler_->hasInformedMeasure() == true && informedMeasure < si_->getSpaceMeasure()) || (sampler_->hasInformedMeasure() == false) )
911 OMPL_INFORM("%s: Pruning the planning problem from a solution of %.4f to %.4f, resulting in a change of problem size from %.4f to %.4f.", Planner::getName().c_str(), prunedCost_.value(), bestCost_.value(), prunedMeasure_, informedMeasure);
922 //Prune the graph. This can be done extra efficiently by using some info in the integrated queue.
923 //This requires access to the nearest neighbour structures so vertices can be moved to free states.s
954 //During resorting we can be lazy and skip resorting vertices that will just be pruned later. So, are we using pruning?
957 //We are, give the queue access to the nearest neighbour structures so vertices can be pruned instead of resorted.
991 for (std::vector<const ompl::base::State*>::const_reverse_iterator sIter = reversePath.rbegin(); sIter != reversePath.rend(); ++sIter)
1025 //Then, use a vertex pointer like an iterator. Starting at the goal, we iterate up the chain pushing the *parent* of the iterator into the vector until the vertex has no parent.
1026 //This will allows us to add the start (as the parent of the first child) and then stop when we get to the start itself, avoiding trying to find its nonexistent child
1027 for (VertexConstPtr curVertex = curGoalVertex_; curVertex->isRoot() == false; curVertex = curVertex->getParentConst())
1029 //Check the case where the chain ends incorrectly. This is unnecessary but sure helpful in debugging:
1032 throw ompl::Exception("The path to the goal does not originate at a start state. Something went wrong.");
1049 //Whether we have to rebuid the queue, i.e.. whether we've called updateStartAndGoalStates before
1054 //We do this as nested conditions so we always call nextGoal(ptc) at least once (regardless of whether there are moreGoalStates or not)
1055 //in case we have been given a non trivial PTC that wants us to wait, but do *not* call it again if there are no more goals
1056 //(as in the nontrivial PTC case, doing so would cause us to wait out the ptc and never try to solve anything)
1067 //It is valid and we are adding a goal, we will need to rebuild the queue if any starts have previously been added as their (and any descendents') heuristic cost-to-go may change:
1086 //And then do the for starts. We do this last as the starts are added to the queue, which uses a cost-to-go heuristic in it's ordering, and for that we want all the goals updated.
1088 //There is no need to rebuild the queue when we add start vertices, as the queue is ordered on current cost-to-come, and adding a start doesn't change that.
1145 //Just like the other new goals, we will need to rebuild the queue if any starts have previously been added. Which was a condition to be here in the first place
1151 //Now, if we added a goal and have previously pruned starts, we will have to do the same on those
1195 for (std::list<VertexPtr>::const_iterator sIter = startVertices_.begin(); sIter != startVertices_.end(); ++sIter)
1205 sampler_ = opt_->allocInformedStateSampler(Planner::pdef_, std::numeric_limits<unsigned int>::max());
1213 OMPL_INFORM("%s: Updating starts/goals and rebuilding the queue.", Planner::getName().c_str());
1216 for (std::list<VertexPtr>::const_iterator sIter = startVertices_.begin(); sIter != startVertices_.end(); ++sIter)
1228 //Make sure that if we have a goal, we also have a start, since there's no way to wait for more *starts*
1231 OMPL_WARN("%s, The problem has a goal but not a start. As PlannerInputStates provides no method to wait for a _start_ state, this will likely be problematic.", Planner::getName().c_str());
1255 //It has, update counters. By definition of the heuristics, start vertices are either in the tree or are deleted. Since we're pruning this one, that means we're going all the way to remove it:
1301 intQueue_->eraseVertex(*goalIter, (*goalIter)->hasParent(), vertexNN_, freeStateNN_, &recycledSamples_);
1353 //Iterate through the list and remove any samples that have a heuristic larger than the bestCost_
1391 void BITstar::addEdge(const VertexPtrPair& newEdge, const ompl::base::Cost& edgeCost, const bool& removeFromFree, const bool& updateDescendants)
1414 //If not, we just add the vertex, first mark the target vertex as no longer new and unexpanded:
1428 //If the path to the goal has changed, we may need to update the cached info about the solution cost or solution length:
1434 void BITstar::replaceParent(const VertexPtrPair& newEdge, const ompl::base::Cost& edgeCost, const bool& updateDescendants)
1442 if (opt_->isCostBetterThan(newEdge.second->getCost(), opt_->combineCosts(newEdge.first->getCost(), edgeCost)) == true)
1459 //Add the parent to the child. This updates the cost of the child as well as all it's descendents (if requested).
1479 for (std::list<VertexPtr>::const_iterator gIter = goalVertices_.begin(); gIter != goalVertices_.end(); ++gIter)
1490 //Ah-ha, We meet again! Are we doing any better? We check the length as sometimes the path length changes with minimal change in cost.
1491 if (opt_->isCostEquivalentTo((*gIter)->getCost(), newCost) == false || ((*gIter)->getDepth() + 1u) != bestLength_)
1559 //The form of path passed to the intermediate solution callback is not well documented, but it *appears* that it's not supposed
1560 //to include the start or goal; however, that makes no sense for multiple start/goal problems, so we're going to include it anyway (sorry).
1561 //Similarly, it appears to be ordered as (goal, goal-1, goal-2,...start+1, start) which conveniently allows us to reuse code.
1562 Planner::pdef_->getIntermediateSolutionCallback()(this, this->bestPathFromGoalToStart(), bestCost_);
1586 //Make sure it's connected first, so that the queue gets updated properly. This is a day of debugging I'll never get back
1611 unsigned int BITstar::nearestSamples(const VertexPtr& vertex, std::vector<VertexPtr>* neighbourSamples)
1633 unsigned int BITstar::nearestVertices(const VertexPtr& vertex, std::vector<VertexPtr>* neighbourVertices)
1654 //Using RRTstar as an example, this order gives us the distance FROM the queried state TO the other neighbours in the structure.
1671 return opt_->combineCosts( this->costToComeHeuristic(vertex), this->costToGoHeuristic(vertex) );
1684 return this->combineCosts(this->costToComeHeuristic(edgePair.first), this->edgeCostHeuristic(edgePair), this->costToGoHeuristic(edgePair.second));
1691 return opt_->combineCosts(this->currentHeuristicEdgeTarget(edgePair), this->costToGoHeuristic(edgePair.second));
1710 for (std::list<VertexPtr>::const_iterator startIter = startVertices_.begin(); startIter != startVertices_.end(); ++startIter)
1713 curBest = opt_->betterCost(curBest, opt_->motionCostHeuristic((*startIter)->stateConst(), vertex->stateConst()));
1736 for (std::list<VertexPtr>::const_iterator goalIter = goalVertices_.begin(); goalIter != goalVertices_.end(); ++goalIter)
1739 curBest = opt_->betterCost(curBest, opt_->motionCostHeuristic(vertex->stateConst(), (*goalIter)->stateConst()));
1756 //Even though the problem domain is defined by prunedCost_ (the cost the last time we pruned), there is no point generating samples outside bestCost_ (which may be less).
1759 return opt_->betterCost(bestCost_, opt_->combineCosts(this->lowerBoundHeuristicVertex(vertex), ompl::base::Cost(2.0 * r_)));
1777 bool BITstar::isCostNotEquivalentTo(const ompl::base::Cost& a, const ompl::base::Cost& b) const
1785 bool BITstar::isCostBetterThanOrEquivalentTo(const ompl::base::Cost& a, const ompl::base::Cost& b) const
1793 bool BITstar::isCostWorseThanOrEquivalentTo(const ompl::base::Cost& a, const ompl::base::Cost& b) const
1801 ompl::base::Cost BITstar::combineCosts(const ompl::base::Cost& a, const ompl::base::Cost& b, const ompl::base::Cost& c) const
1808 ompl::base::Cost BITstar::combineCosts(const ompl::base::Cost& a, const ompl::base::Cost& b, const ompl::base::Cost& c, const ompl::base::Cost& d) const
1815 double BITstar::fractionalChange(const ompl::base::Cost& newCost, const ompl::base::Cost& oldCost) const
1822 double BITstar::fractionalChange(const ompl::base::Cost& newCost, const ompl::base::Cost& oldCost, const ompl::base::Cost& refCost) const
1868 //In general, we calculate the terms considering the future samples. This is only not the case when it's the initial call (i.e., the 0 batch):
1926 return rewireFactor_*2.0*std::pow( (1.0 + 1.0/dimDbl)*( prunedMeasure_/unitNBallMeasure(Planner::si_->getStateDimension()) ), 1.0/dimDbl ); //RRG radius (biggest for unit-volume problem)
1927 //return rewireFactor_*std::pow( 2.0*(1.0 + 1.0/dimDbl)*( prunedMeasure_/unitNBallMeasure(Planner::si_->getStateDimension()) ), 1.0/dimDbl ); //RRT* radius (smaller for unit-volume problem)
1928 //return rewireFactor_*2.0*std::pow( (1.0/dimDbl)*( prunedMeasure_/unitNBallMeasure(Planner::si_->getStateDimension()) ), 1.0/dimDbl ); //FMT* radius (smallest for R2, equiv to RRT* for R3 and then middle for higher d. All unit-volume)
1940 return rewireFactor_*(boost::math::constants::e<double>() + (boost::math::constants::e<double>() / dimDbl)); //RRG k-nearest
1947 OMPL_INFORM("%s (%u iters): Found a solution of cost %.4f (%u vertices) from %u samples by processing %u edges (%u collision checked) to create %u vertices and perform %u rewirings. The graph currently has %u vertices.", Planner::getName().c_str(), numIterations_, bestCost_.value(), bestLength_, numSamples_, numEdgesProcessed_, numEdgeCollisionChecks_, numVertices_, numRewirings_, vertexNN_->size());
1954 OMPL_INFORM("%s: Finished with a solution of cost %.4f (%u vertices) found from %u samples by processing %u edges (%u collision checked) to create %u vertices and perform %u rewirings. The final graph has %u vertices.", Planner::getName().c_str(), bestCost_.value(), bestLength_, numSamples_, numEdgesProcessed_, numEdgeCollisionChecks_, numVertices_, numRewirings_, vertexNN_->size());
1961 OMPL_INFORM("%s (%u iters): Did not find a solution from %u samples after processing %u edges (%u collision checked) to create %u vertices and perform %u rewirings. The final graph has %u vertices.", Planner::getName().c_str(), numIterations_, numSamples_, numEdgesProcessed_, numEdgeCollisionChecks_, numVertices_, numRewirings_, vertexNN_->size());
1966 void BITstar::statusMessage(const ompl::msg::LogLevel& msgLevel, const std::string& status) const
1980 outputStream << "l: " << std::setw(6) << std::setfill(' ') << std::setprecision(5) << bestCost_.value();
2084 //It's current the default k-nearest BIT* name, and we're toggling, so set to the default r-disc
2089 //It's current the default r-disc BIT* name, and we're toggling, so set to the default k-nearest
2142 OMPL_WARN("%s: Turning pruning off has never really been tested.", Planner::getName().c_str());
2200 OMPL_WARN("%s: Just-in-time sampling is experimental and currently only implemented for problems seeking to minimize path-length.", Planner::getName().c_str());
2240 //Remove starts and goals if this won't make us negative. This protects against the case where the problem is setup with starts/goals but not started yet
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
void addPlannerProgressProperty(const std::string &progressPropertyName, const PlannerProgressProperty &prop)
Add a planner progress property called progressPropertyName with a property querying function prop to...
Definition: Planner.h:392
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
void setApproximate(double difference)
Specify that the solution is approximate and set the difference to the goal.
Definition: ProblemDefinition.h:90
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
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
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
bool optimized_
True if the solution was optimized to meet the specified optimization criterion.
Definition: ProblemDefinition.h:126
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
Representation of a solution to a planning problem.
Definition: ProblemDefinition.h:70
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
unsigned int addVertex(const PlannerDataVertex &st)
Adds the given vertex to the graph data. The vertex index is returned. Duplicates are not added...
Definition: PlannerData.cpp:395
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
double unitNBallMeasure(unsigned int N)
The Lebesgue measure (i.e., "volume") of an n-dimensional ball with a unit radius.
Definition: GeometricEquations.cpp:54
PlannerTerminationCondition plannerAlwaysTerminatingCondition()
Simple termination condition that always returns true. The termination condition will always be met...
Definition: PlannerTerminationCondition.cpp:183
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
Base class for a vertex in the PlannerData structure. All derived classes must implement the clone an...
Definition: PlannerData.h:59
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
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
LogLevel getLogLevel()
Retrieve the current level of logging data. Messages with lower logging levels will not be recorded...
Definition: Console.cpp:142
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
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
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:435
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
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:416
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
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
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
bool markGoalState(const State *st)
Mark the given state as a goal vertex. If the given state does not exist in a vertex, false is returned.
Definition: PlannerData.cpp:597
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
void setPlannerName(const std::string &name)
Set the name of the planner used to compute this solution.
Definition: ProblemDefinition.h:105
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
This bit is set if casting to sampleable goal regions (ompl::base::GoalSampleableRegion) is possible...
Definition: GoalTypes.h:55