BITstar.h
1 /*********************************************************************
2 * Software License Agreement (BSD License)
3 *
4 * Copyright (c) 2014, University of Toronto
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
17 * * Neither the name of the University of Toronto nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 * POSSIBILITY OF SUCH DAMAGE.
33 *********************************************************************/
34 
35 /* Authors: Jonathan Gammell */
36 
37 #ifndef OMPL_GEOMETRIC_PLANNERS_BITSTAR_BITSTAR_
38 #define OMPL_GEOMETRIC_PLANNERS_BITSTAR_BITSTAR_
39 
40 //STL:
41 //std::string
42 #include <string>
43 //std::pair
44 #include <utility>
45 //std::vector
46 #include <vector>
47 //std::list
48 #include <list>
49 
50 //OMPL:
51 //The base-class of planners:
52 #include "ompl/base/Planner.h"
53 //The nearest neighbours structure
54 #include "ompl/datastructures/NearestNeighbors.h"
55 //The informed sampler structure
56 #include "ompl/base/samplers/InformedStateSampler.h"
57 //Planner includes:
58 //#include "ompl/geometric/planners/PlannerIncludes.h"
59 
60 //BIT*:
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.
62 
63 
64 
65 namespace ompl
66 {
67  namespace geometric
68  {
112  {
113  public:
114  //Forward declarations so that the classes belong to BIT*:
116  class Vertex;
118  class IdGenerator;
121  //Helpful typedefs:
123  typedef std::shared_ptr<Vertex> VertexPtr;
125  typedef std::shared_ptr<const Vertex> VertexConstPtr;
127  typedef std::weak_ptr<Vertex> VertexWeakPtr;
129  typedef std::shared_ptr<IntegratedQueue> IntegratedQueuePtr;
131  typedef unsigned int VertexId;
133  typedef std::pair<VertexPtr, VertexPtr> VertexPtrPair;
135  typedef std::pair<VertexConstPtr, VertexConstPtr> VertexConstPtrPair;
137  typedef std::shared_ptr< NearestNeighbors<VertexPtr> > VertexPtrNNPtr;
138 
139 
141  BITstar(const base::SpaceInformationPtr& si, const std::string& name = "BITstar");
142 
144  virtual ~BITstar();
145 
147  virtual void setup();
148 
150  virtual void clear();
151 
154 
156  virtual void getPlannerData(base::PlannerData& data) const;
157 
159  // Planner info for debugging, etc:
161  std::pair<const ompl::base::State*, const ompl::base::State*> getNextEdgeInQueue();
162 
165 
167  void getEdgeQueue(std::vector<std::pair<VertexConstPtr, VertexConstPtr> >* edgesInQueue);
168 
170  void getVertexQueue(std::vector<VertexConstPtr>* verticesInQueue);
171 
173  unsigned int numIterations() const;
174 
176  ompl::base::Cost bestCost() const;
178 
180  // Planner settings:
182  template<template<typename T> class NN>
183  void setNearestNeighbors();
184 
186  void setRewireFactor(double rewireFactor);
187 
189  double getRewireFactor() const;
190 
192  void setSamplesPerBatch(unsigned int n);
193 
195  unsigned int getSamplesPerBatch() const;
196 
198  void setKNearest(bool useKNearest);
199 
201  bool getKNearest() const;
202 
208  void setStrictQueueOrdering(bool beStrict);
209 
211  bool getStrictQueueOrdering() const;
212 
218  void setPruning(bool prune);
219 
221  bool getPruning() const;
222 
225 
227  double getPruneThresholdFraction() const;
228 
233  void setDelayRewiringUntilInitialSolution(bool delayRewiring);
234 
237 
244  void setJustInTimeSampling(bool useJit);
245 
247  bool getJustInTimeSampling() const;
248 
255  void setDropSamplesOnPrune(bool dropSamples);
256 
258  bool getDropSamplesOnPrune() const;
259 
262  void setStopOnSolnImprovement(bool stopOnChange);
263 
265  bool getStopOnSolnImprovement() const;
267 
268  protected:
269  //Everything is only protected so we can create modifications without duplicating code by deriving from the class:
270 
271  //Functions:
273  void estimateMeasures();
274 
276  //BIT* primitives:
278  virtual void iterate();
279 
281  void newBatch();
282 
284  void updateSamples(const VertexConstPtr& vertex);
285 
287  virtual bool prune();
288 
290  virtual bool resort();
291 
293  void publishSolution();
295 
297  //Helper functions for data manipulation and other low-level functions
299  std::vector<const ompl::base::State*> bestPathFromGoalToStart() const;
300 
303 
305  void pruneStartsGoals();
306 
308  void pruneSamples();
309 
311  bool checkEdge(const VertexConstPtrPair& edge);
312 
314  void dropSample(VertexPtr oldSample);
315 
317  void addEdge(const VertexPtrPair& newEdge, const ompl::base::Cost& edgeCost, const bool& removeFromFree, const bool& updateDescendants);
318 
320  void replaceParent(const VertexPtrPair& newEdge, const ompl::base::Cost& edgeCost, const bool& updateDescendants);
321 
323  void updateGoalVertex();
324 
326  void addSample(const VertexPtr& newSample);
327 
329  void addVertex(const VertexPtr& newVertex, const bool& removeFromFree);
330 
332  unsigned int nearestSamples(const VertexPtr& vertex, std::vector<VertexPtr>* neighbourSamples);
333 
335  unsigned int nearestVertices(const VertexPtr& vertex, std::vector<VertexPtr>* neighbourVertices);
337 
339  //Helper functions for sorting queues/nearest-neighbour structures and the related calculations.
341  double nnDistance(const VertexConstPtr& a, const VertexConstPtr& b) const;
343 
345  //Helper functions for various heuristics.
348 
351 
354 
357 
360 
363 
366 
369 
371  ompl::base::Cost trueEdgeCost(const VertexConstPtrPair& edgePair) const;
372 
375 
377  bool isCostWorseThan(const ompl::base::Cost& a, const ompl::base::Cost& b) const;
378 
380  bool isCostNotEquivalentTo(const ompl::base::Cost& a, const ompl::base::Cost& b) const;
381 
384 
386  bool isCostWorseThanOrEquivalentTo(const ompl::base::Cost& a, const ompl::base::Cost& b) const;
387 
390 
393 
395  double fractionalChange(const ompl::base::Cost& newCost, const ompl::base::Cost& oldCost) const;
396 
398  double fractionalChange(const ompl::base::Cost& newCost, const ompl::base::Cost& oldCost, const ompl::base::Cost& refCost) const;
400 
402  //Helper functions to calculate parameters:
404  void initializeNearestTerms();
405 
407  virtual void updateNearestTerms();
408 
410  double calculateR(unsigned int N) const;
411 
413  unsigned int calculateK(unsigned int N) const;
414 
416  double minimumRggR() const;
417 
419  double minimumRggK() const;
421 
423  //Helper functions for logging
425  virtual void goalMessage() const;
426 
428  virtual void endSuccessMessage() const;
429 
431  virtual void endFailureMessage() const;
432 
434  virtual void statusMessage(const ompl::msg::LogLevel& msgLevel, const std::string& status) const;
436 
438  // Planner progress property functions
441  std::string bestCostProgressProperty() const;
442 
445  std::string bestLengthProgressProperty() const;
446 
449  std::string currentFreeProgressProperty() const;
450 
453  std::string currentVertexProgressProperty() const;
454 
457  std::string vertexQueueSizeProgressProperty() const;
458 
461  std::string edgeQueueSizeProgressProperty() const;
462 
465  std::string iterationProgressProperty() const;
466 
469  unsigned int numBatches() const;
472  std::string batchesProgressProperty() const;
473 
476  std::string pruningProgressProperty() const;
477 
480  virtual std::string totalStatesCreatedProgressProperty() const;
481 
484  std::string verticesConstructedProgressProperty() const;
485 
488  std::string statesPrunedProgressProperty() const;
489 
493  std::string verticesDisconnectedProgressProperty() const;
494 
497  std::string rewiringProgressProperty() const;
498 
501  std::string stateCollisionCheckProgressProperty() const;
502 
505  std::string edgeCollisionCheckProgressProperty() const;
506 
509  std::string nearestNeighbourProgressProperty() const;
510 
512  std::string edgesProcessedProgressProperty() const;
514 
515 
516 
517  //Variables -- Make sure every one is configured in setup() and reset in clear():
520 
522  ompl::base::InformedSamplerPtr sampler_;
523 
526 
528  std::list<VertexPtr> startVertices_;
529 
531  std::list<VertexPtr> goalVertices_;
532 
534  std::list<VertexPtr> prunedStartVertices_;
535 
537  std::list<VertexPtr> prunedGoalVertices_;
538 
541 
544 
547 
550 
552  std::vector<VertexPtr> newSamples_;
553 
555  std::vector<VertexPtr> recycledSamples_;
556 
558  unsigned int numUniformStates_;
559 
561  double r_;
562 
564  double k_rgg_;
565 
567  unsigned int k_;
568 
571 
573  unsigned int bestLength_;
574 
577 
580 
583 
586 
589 
591  bool stopLoop_;
592 
594 
596  //Informational variables - Make sure initialized in setup and reset in clear
599 
602 
604  unsigned int numIterations_;
605 
607  unsigned int numBatches_;
608 
610  unsigned int numPrunings_;
611 
613  unsigned int numSamples_;
614 
616  unsigned int numVertices_;
617 
619  unsigned int numFreeStatesPruned_;
620 
623 
625  unsigned int numRewirings_;
626 
629 
632 
634  unsigned int numNearestNeighbours_;
635 
637  unsigned int numEdgesProcessed_;
639 
641  //Parameters - Set defaults in construction/setup and DO NOT reset in clear.
644 
647 
649  unsigned int samplesPerBatch_;
650 
653 
656 
659 
662 
665 
668 
672  }; //class: BITstar
673  } //geometric
674 } //ompl
675 
676 
677 //BIT* Includes:
678 //The Vertex ID generator class
679 #include "ompl/geometric/planners/bitstar/datastructures/IdGenerator.h"
680 //My vertex class:
681 #include "ompl/geometric/planners/bitstar/datastructures/Vertex.h"
682 //My queue class
683 #include "ompl/geometric/planners/bitstar/datastructures/IntegratedQueue.h"
684 
685 #endif //OMPL_GEOMETRIC_PLANNERS_BITSTAR_BITSTAR_
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
virtual ~BITstar()
Destruct!
Definition: BITstar.cpp:185
ompl::base::OptimizationObjectivePtr opt_
Optimization objective copied from ProblemDefinition.
Definition: BITstar.h:525
bool useJustInTimeSampling_
Whether to use just-in-time sampling (param)
Definition: BITstar.h:664
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
std::weak_ptr< Vertex > VertexWeakPtr
A vertex weak pointer.
Definition: BITstar.h:127
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
ompl::base::InformedSamplerPtr sampler_
State sampler.
Definition: BITstar.h:522
std::list< VertexPtr > prunedGoalVertices_
Any goal states of the problem that have been pruned.
Definition: BITstar.h:537
bool stopLoop_
A manual stop on the solve loop.
Definition: BITstar.h:591
double r_
The current r-disc RGG connection radius.
Definition: BITstar.h:561
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...
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
virtual void iterate()
A single iteration.
Definition: BITstar.cpp:672
bool hasSolution_
If we've found a solution yet.
Definition: BITstar.h:588
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
bool usePruning_
Whether to use graph pruning (param)
Definition: BITstar.h:655
virtual void getPlannerData(base::PlannerData &data) const
Get results.
Definition: BITstar.cpp:450
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
bool approximateSoln_
If the solution is approximate.
Definition: BITstar.h:598
double getRewireFactor() const
Get the rewiring scale factor.
Definition: BITstar.cpp:2055
Base class for a planner.
Definition: Planner.h:230
std::vector< VertexPtr > recycledSamples_
A copy of the vertices recycled into samples during this batch.
Definition: BITstar.h:555
bool getKNearest() const
Get whether a k-nearest search is being used.
Definition: BITstar.cpp:2118
double minimumRggK() const
Calculate the lower-bounding k-nearest RGG term for asymptotic almost-sure convergence to the optimal...
Definition: BITstar.cpp:1933
VertexPtr curGoalVertex_
The goal vertex of the current best solution.
Definition: BITstar.h:540
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 addSample(const VertexPtr &newSample)
Add a sample.
Definition: BITstar.cpp:1570
virtual void setup()
Setup.
Definition: BITstar.cpp:191
Batch Informed Trees (BIT*)
Definition: BITstar.h:111
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...
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
ompl::RNG rng_
An instance of a random number generator.
Definition: BITstar.h:519
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
virtual void clear()
Clear.
Definition: BITstar.cpp:324
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
bool useKNearest_
Option to use k-nearest search for rewiring (param)
Definition: BITstar.h:652
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
void newBatch()
Initialize variables for a new batch.
Definition: BITstar.cpp:763
unsigned int k_
The current k-nearest RGG connection number.
Definition: BITstar.h:567
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
void initializeNearestTerms()
Initialize the nearest-neighbour terms.
Definition: BITstar.cpp:1839
std::shared_ptr< Vertex > VertexPtr
A vertex shared pointer.
Definition: BITstar.h:120
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
LogLevel
The set of priorities for message logging.
Definition: Console.h:85
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
unsigned int samplesPerBatch_
The number of samples per batch (param)
Definition: BITstar.h:649
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 VertexId
The vertex id type.
Definition: BITstar.h:131
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