SPARSdb.h
1 /*********************************************************************
2 * Software License Agreement (BSD License)
3 *
4 * Copyright (c) 2013, Rutgers the State University of New Jersey, New Brunswick
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 Rutgers University 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 /* Author: Andrew Dobson, Dave Coleman */
36 
37 #ifndef OMPL_TOOLS_THUNDER_SPARS_DB_
38 #define OMPL_TOOLS_THUNDER_SPARS_DB_
39 
40 #include "ompl/geometric/planners/PlannerIncludes.h"
41 #include "ompl/datastructures/NearestNeighbors.h"
42 #include "ompl/geometric/PathSimplifier.h"
43 #include "ompl/util/Time.h"
44 #include "ompl/util/Hash.h"
45 
46 #include <boost/range/adaptor/map.hpp>
47 #include <unordered_map>
48 #include <boost/graph/graph_traits.hpp>
49 #include <boost/graph/adjacency_list.hpp>
50 #include <boost/graph/filtered_graph.hpp>
51 #include <boost/graph/graph_utility.hpp>
52 #include <boost/graph/astar_search.hpp>
53 #include <boost/graph/connected_components.hpp>
54 #include <boost/property_map/property_map.hpp>
55 #include <boost/pending/disjoint_sets.hpp>
56 #include <functional>
57 #include <thread>
58 #include <iostream>
59 #include <fstream>
60 #include <utility>
61 #include <vector>
62 #include <map>
63 
64 namespace ompl
65 {
66 
67  namespace geometric
68  {
69 
88  class SPARSdb : public base::Planner
89  {
90  public:
91 
93  enum GuardType
94  {
95  START,
96  GOAL,
97  COVERAGE,
98  CONNECTIVITY,
99  INTERFACE,
100  QUALITY,
101  };
102 
104  // BOOST GRAPH DETAILS
106 
108  typedef unsigned long int VertexIndexType;
109 
111  typedef std::pair< VertexIndexType, VertexIndexType > VertexPair;
112 
114 
116  {
119  base::State *pointB_;
120 
123  base::State *sigmaB_;
124 
126  double d_;
127 
130  pointA_(nullptr),
131  pointB_(nullptr),
132  sigmaA_(nullptr),
133  sigmaB_(nullptr),
134  d_(std::numeric_limits<double>::infinity())
135  {
136  }
137 
140  {
141  if (pointA_)
142  {
143  si->freeState(pointA_);
144  pointA_ = nullptr;
145  }
146  if (pointB_)
147  {
148  si->freeState(pointB_);
149  pointB_ = nullptr;
150  }
151  if (sigmaA_)
152  {
153  si->freeState(sigmaA_);
154  sigmaA_ = nullptr;
155  }
156  if (sigmaB_)
157  {
158  si->freeState(sigmaB_);
159  sigmaB_ = nullptr;
160  }
161  d_ = std::numeric_limits<double>::infinity();
162  }
163 
165  void setFirst(const base::State *p, const base::State *s, const base::SpaceInformationPtr& si)
166  {
167  if (pointA_)
168  si->copyState(pointA_, p);
169  else
170  pointA_ = si->cloneState(p);
171  if (sigmaA_)
172  si->copyState(sigmaA_, s);
173  else
174  sigmaA_ = si->cloneState(s);
175  if (pointB_)
176  d_ = si->distance(pointA_, pointB_);
177  }
178 
180  void setSecond(const base::State *p, const base::State *s, const base::SpaceInformationPtr& si)
181  {
182  if (pointB_)
183  si->copyState(pointB_, p);
184  else
185  pointB_ = si->cloneState(p);
186  if (sigmaB_)
187  si->copyState(sigmaB_, s);
188  else
189  sigmaB_ = si->cloneState(s);
190  if (pointA_)
191  d_ = si->distance(pointA_, pointB_);
192  }
193  };
194 
196  typedef std::unordered_map<VertexPair, InterfaceData> InterfaceHash;
197 
199  // The InterfaceHash structure is wrapped inside of this struct due to a compilation error on
200  // GCC 4.6 with Boost 1.48. An implicit assignment operator overload does not compile with these
201  // components, so an explicit overload is given here.
202  // Remove this struct when the minimum Boost requirement is > v1.48.
204  {
205  InterfaceHashStruct& operator=(const InterfaceHashStruct &rhs) { interfaceHash = rhs.interfaceHash; return *this; }
206  InterfaceHash interfaceHash;
207  };
208 
210  // Vertex properties
211 
212  struct vertex_state_t {
213  typedef boost::vertex_property_tag kind;
214  };
215 
216  struct vertex_color_t {
217  typedef boost::vertex_property_tag kind;
218  };
219 
221  typedef boost::vertex_property_tag kind;
222  };
223 
225  // Edge properties
226 
228  typedef boost::edge_property_tag kind;
229  };
230 
233  {
234  NOT_CHECKED,
235  IN_COLLISION,
236  FREE
237  };
238 
241  {
242  bool isApproximate_;
243  base::PathPtr path_;
244  // Edge 0 is edge from vertex 0 to vertex 1. Thus, there is n-1 edges for n vertices
245  std::vector<EdgeCollisionState> edgeCollisionStatus_;
246  // TODO save the collision state of the vertexes also?
247 
248  std::size_t getStateCount()
249  {
250  return static_cast<ompl::geometric::PathGeometric&>(*path_).getStateCount();
251  }
252 
253  ompl::geometric::PathGeometric& getGeometricPath()
254  {
255  return static_cast<ompl::geometric::PathGeometric&>(*path_);
256  }
257  };
258 
260 
284  typedef boost::property < vertex_state_t, base::State*,
285  boost::property < boost::vertex_predecessor_t, VertexIndexType,
286  boost::property < boost::vertex_rank_t, VertexIndexType,
287  boost::property < vertex_color_t, GuardType,
288  boost::property < vertex_interface_data_t, InterfaceHashStruct > > > > > VertexProperties;
289 
291  typedef boost::property < boost::edge_weight_t, double,
292  boost::property < edge_collision_state_t, int > > EdgeProperties;
293 
295  typedef boost::adjacency_list <
296  boost::vecS, // store in std::vector
297  boost::vecS, // store in std::vector
298  boost::undirectedS,
300  EdgeProperties
301  > Graph;
302 
304  typedef boost::graph_traits<Graph>::vertex_descriptor Vertex;
305 
307  typedef boost::graph_traits<Graph>::edge_descriptor Edge;
308 
310  // Typedefs for property maps
311 
313  typedef boost::property_map<Graph, edge_collision_state_t>::type EdgeCollisionStateMap;
314 
316 
321  {
322  private:
323 
324  const Graph &g_; // Graph used
325  const EdgeCollisionStateMap &collisionStates_;
326 
327  public:
328 
330  typedef Edge key_type;
332  typedef double value_type;
334  typedef double &reference;
336  typedef boost::readable_property_map_tag category;
337 
342  edgeWeightMap (const Graph &graph, const EdgeCollisionStateMap &collisionStates);
343 
349  double get (Edge e) const;
350 
351  };
352 
354 
358  {
359  };
360 
362 
366  class CustomVisitor : public boost::default_astar_visitor
367  {
368  private:
369 
370  Vertex goal; // Goal Vertex of the search
371 
372  public:
373 
378  CustomVisitor (Vertex goal);
379 
386  void examine_vertex(Vertex u, const Graph &g) const;
387  };
388 
390  // SPARS MEMBER FUNCTIONS
392 
395 
397  virtual ~SPARSdb();
398 
399  virtual void setProblemDefinition(const base::ProblemDefinitionPtr &pdef);
400 
402  void setStretchFactor(double t)
403  {
404  stretchFactor_ = t;
405  }
406 
408  void setSparseDeltaFraction( double D )
409  {
411  if (sparseDelta_ > 0.0) // setup was previously called
412  sparseDelta_ = D * si_->getMaximumExtent();
413  }
414 
416  void setDenseDeltaFraction( double d )
417  {
419  if (denseDelta_ > 0.0) // setup was previously called
420  denseDelta_ = d * si_->getMaximumExtent();
421  }
422 
424  void setMaxFailures( unsigned int m )
425  {
426  maxFailures_ = m;
427  }
428 
430  unsigned int getMaxFailures( ) const
431  {
432  return maxFailures_;
433  }
434 
436  double getDenseDeltaFraction( ) const
437  {
438  return denseDeltaFraction_;
439  }
440 
442  double getSparseDeltaFraction( ) const
443  {
444  return sparseDeltaFraction_;
445  }
446 
448  double getStretchFactor( ) const
449  {
450  return stretchFactor_;
451  }
452 
453  bool getGuardSpacingFactor(const double pathLength, double &numGuards, double &spacingFactor);
454 
462  bool getGuardSpacingFactor(const double pathLength, int &numGuards, double &spacingFactor);
463 
464  bool addPathToRoadmap(const base::PlannerTerminationCondition &ptc,
465  ompl::geometric::PathGeometric& solutionPath);
466 
467  bool checkStartGoalConnection(ompl::geometric::PathGeometric& solutionPath);
468 
469  bool addStateToRoadmap(const base::PlannerTerminationCondition &ptc, base::State *newState);
470 
484 
489  void clearQuery();
490 
491  virtual void clear();
492 
494  template<template<typename T> class NN>
496  {
497  nn_.reset(new NN< Vertex >());
498  if (isSetup())
499  setup();
500  }
501 
510  bool getSimilarPaths(int nearestK, const base::State* start, const base::State* goal,
511  CandidateSolution &candidateSolution,
513 
514  virtual void setup();
515 
517  const Graph& getRoadmap() const
518  {
519  return g_;
520  }
521 
523  unsigned int getNumVertices() const
524  {
525  return boost::num_vertices(g_);
526  }
527 
529  unsigned int getNumEdges() const
530  {
531  return boost::num_edges(g_);
532  }
533 
535  unsigned int getNumConnectedComponents() const
536  {
537  // Make sure graph is populated
538  if (!getNumVertices())
539  return 0;
540 
541  std::vector<int> components(boost::num_vertices(g_));
542 
543  // it always overcounts by 1, i think because it is missing vertex 0 which is the new state insertion component
544  return boost::connected_components(g_, &components[0]) - 1;
545  }
546 
548  unsigned int getNumPathInsertionFailed() const
549  {
551  }
552 
554  unsigned int getNumConsecutiveFailures() const
555  {
556  return consecutiveFailures_;
557  }
558 
560  long unsigned int getIterations() const
561  {
562  return iterations_;
563  }
564 
574  bool convertVertexPathToStatePath(std::vector<Vertex> &vertexPath,
575  const base::State* actualStart,
576  const base::State* actualGoal,
577  CandidateSolution &candidateSolution,
578  bool disableCollisionWarning = false);
579 
580  virtual void getPlannerData(base::PlannerData &data) const;
581 
586  void setPlannerData(const base::PlannerData &data);
587 
589  bool reachedFailureLimit () const;
590 
592  void printDebug(std::ostream &out = std::cout) const;
593 
596 
597  protected:
598 
600  void freeMemory();
601 
604 
606  bool checkAddCoverage(const base::State *qNew, std::vector<Vertex> &visibleNeighborhood);
607 
609  bool checkAddConnectivity(const base::State *qNew, std::vector<Vertex> &visibleNeighborhood);
610 
612  bool checkAddInterface(const base::State *qNew, std::vector<Vertex> &graphNeighborhood,
613  std::vector<Vertex> &visibleNeighborhood);
614 
616  bool checkAddPath( Vertex v );
617 
619  void resetFailures();
620 
622  void findGraphNeighbors(base::State *state, std::vector<Vertex> &graphNeighborhood,
623  std::vector<Vertex> &visibleNeighborhood);
624 
631  bool findGraphNeighbors(const base::State *state, std::vector<Vertex> &graphNeighborhood);
632 
634  void approachGraph( Vertex v );
635 
637  Vertex findGraphRepresentative(base::State *st);
638 
640  void findCloseRepresentatives(base::State *workState, const base::State *qNew, Vertex qRep,
641  std::map<Vertex, base::State*> &closeRepresentatives,
643 
645  void updatePairPoints(Vertex rep, const base::State *q, Vertex r, const base::State *s);
646 
648  void computeVPP(Vertex v, Vertex vp, std::vector<Vertex> &VPPs);
649 
651  void computeX(Vertex v, Vertex vp, Vertex vpp, std::vector<Vertex> &Xs);
652 
654  VertexPair index( Vertex vp, Vertex vpp );
655 
657  InterfaceData& getData( Vertex v, Vertex vp, Vertex vpp );
658 
660  void distanceCheck(Vertex rep, const base::State *q, Vertex r, const base::State *s, Vertex rp);
661 
663  void abandonLists(base::State *st);
664 
666  Vertex addGuard(base::State *state, GuardType type);
667 
669  void connectGuards( Vertex v, Vertex vp );
670 
672  bool getPaths(const std::vector<Vertex> &candidateStarts,
673  const std::vector<Vertex> &candidateGoals,
674  const base::State* actualStart,
675  const base::State* actualGoal,
676  CandidateSolution &candidateSolution,
678 
683  bool lazyCollisionSearch(const Vertex &start,
684  const Vertex &goal,
685  const base::State* actualStart,
686  const base::State* actualGoal,
687  CandidateSolution &candidateSolution,
689 
691  bool lazyCollisionCheck(std::vector<Vertex> &vertexPath, const base::PlannerTerminationCondition &ptc);
692 
695 
702  bool constructSolution(const Vertex start, const Vertex goal,
703  std::vector<Vertex> &vertexPath) const;
704 
706  bool sameComponent(Vertex m1, Vertex m2);
707 
709  double distanceFunction(const Vertex a, const Vertex b) const
710  {
711  return si_->distance(stateProperty_[a], stateProperty_[b]);
712  }
713 
716 
718  std::shared_ptr< NearestNeighbors<Vertex> > nn_;
719 
722 
724  std::vector<Vertex> startM_;
725 
727  std::vector<Vertex> goalM_;
728 
730  Vertex queryVertex_;
731 
734 
737 
740 
742  unsigned int maxFailures_;
743 
746 
748  unsigned int nearSamplePoints_;
749 
752 
754  boost::property_map<Graph, boost::edge_weight_t>::type edgeWeightProperty_; // TODO: this is not used
755 
757  EdgeCollisionStateMap edgeCollisionStateProperty_;
758 
760  boost::property_map<Graph, vertex_state_t>::type stateProperty_;
761 
763  boost::property_map<Graph, vertex_color_t>::type colorProperty_;
764 
766  boost::property_map<Graph, vertex_interface_data_t>::type interfaceDataProperty_;
767 
769  boost::disjoint_sets<
770  boost::property_map<Graph, boost::vertex_rank_t>::type,
771  boost::property_map<Graph, boost::vertex_predecessor_t>::type >
775 
778 
780  unsigned int consecutiveFailures_;
781 
783  long unsigned int iterations_;
784 
786  double sparseDelta_;
787 
789  double denseDelta_;
790 
792  std::vector<Vertex> startVertexCandidateNeighbors_;
793  std::vector<Vertex> goalVertexCandidateNeighbors_;
794 
796  bool verbose_;
797  };
798 
799  }
800 }
801 
802 #endif
803 
double d_
Last known distance between the two interfaces supported by points_ and sigmas.
Definition: SPARSdb.h:126
virtual void setup()
Perform extra configuration steps, if needed. This call will also issue a call to ompl::base::SpaceIn...
Definition: SPARSdb.cpp:142
double denseDeltaFraction_
Maximum range for allowing two samples to support an interface as a fraction of maximum extent...
Definition: SPARSdb.h:739
double getSparseDeltaFraction() const
Retrieve the sparse graph visibility range delta.
Definition: SPARSdb.h:442
void setDenseDeltaFraction(double d)
Sets interface support tolerance as a fraction of max. extent.
Definition: SPARSdb.h:416
Object containing planner generated vertex and edge data. It is assumed that all vertices are unique...
Definition: PlannerData.h:163
double getStretchFactor() const
Retrieve the spanner&#39;s set stretch factor.
Definition: SPARSdb.h:448
boost::property_map< Graph, vertex_color_t >::type colorProperty_
Access to the colors for the vertices.
Definition: SPARSdb.h:763
Interface information storage class, which does bookkeeping for criterion four.
Definition: SPARSdb.h:115
boost::property_map< Graph, edge_collision_state_t >::type EdgeCollisionStateMap
Access map that stores the lazy collision checking status of each edge.
Definition: SPARSdb.h:313
A shared pointer wrapper for ompl::base::ProblemDefinition.
EdgeCollisionState
Possible collision states of an edge.
Definition: SPARSdb.h:232
bool convertVertexPathToStatePath(std::vector< Vertex > &vertexPath, const base::State *actualStart, const base::State *actualGoal, CandidateSolution &candidateSolution, bool disableCollisionWarning=false)
Convert astar results to correctly ordered path.
Definition: SPARSdb.cpp:1652
SPARSdb(const base::SpaceInformationPtr &si)
Constructor.
Definition: SPARSdb.cpp:99
void setMaxFailures(unsigned int m)
Sets the maximum failures until termination.
Definition: SPARSdb.h:424
A shared pointer wrapper for ompl::base::ValidStateSampler.
Graph g_
Connectivity graph.
Definition: SPARSdb.h:721
void findGraphNeighbors(base::State *state, std::vector< Vertex > &graphNeighborhood, std::vector< Vertex > &visibleNeighborhood)
Finds visible nodes in the graph near state.
Definition: SPARSdb.cpp:1276
boost::property_map< Graph, boost::edge_weight_t >::type edgeWeightProperty_
Access to the weights of each Edge.
Definition: SPARSdb.h:754
boost::adjacency_list< boost::vecS, boost::vecS, boost::undirectedS, VertexProperties, EdgeProperties > Graph
Definition: SPARSdb.h:301
boost::disjoint_sets< boost::property_map< Graph, boost::vertex_rank_t >::type, boost::property_map< Graph, boost::vertex_predecessor_t >::type > disjointSets_
Data structure that maintains the connected components.
Definition: SPARSdb.h:772
bool constructSolution(const Vertex start, const Vertex goal, std::vector< Vertex > &vertexPath) const
Given two milestones from the same connected component, construct a path connecting them and set it a...
Definition: SPARSdb.cpp:424
void clear(const base::SpaceInformationPtr &si)
Clears the given interface data.
Definition: SPARSdb.h:139
bool checkAddCoverage(const base::State *qNew, std::vector< Vertex > &visibleNeighborhood)
Checks to see if the sample needs to be added to ensure coverage of the space.
Definition: SPARSdb.cpp:1065
bool lazyCollisionCheck(std::vector< Vertex > &vertexPath, const base::PlannerTerminationCondition &ptc)
Check recalled path for collision and disable as needed.
Definition: SPARSdb.cpp:490
bool verbose_
Option to enable debugging output.
Definition: SPARSdb.h:796
boost::property_map< Graph, vertex_interface_data_t >::type interfaceDataProperty_
Access to the interface pair information for the vertices.
Definition: SPARSdb.h:766
Encapsulate a termination condition for a motion planner. Planners will call operator() to decide whe...
bool addedSolution_
A flag indicating that a solution has been added during solve()
Definition: SPARSdb.h:777
base::State * pointA_
States which lie inside the visibility region of a vertex and support an interface.
Definition: SPARSdb.h:118
STL namespace.
unsigned int getNumEdges() const
Get the number of edges in the sparse roadmap.
Definition: SPARSdb.h:529
bool checkAddPath(Vertex v)
Checks vertex v for short paths through its region and adds when appropriate.
Definition: SPARSdb.cpp:1171
void distanceCheck(Vertex rep, const base::State *q, Vertex r, const base::State *s, Vertex rp)
Performs distance checking for the candidate new state, q against the current information.
Definition: SPARSdb.cpp:1535
double sparseDeltaFraction_
Maximum visibility range for nodes in the graph as a fraction of maximum extent.
Definition: SPARSdb.h:736
bool checkAddInterface(const base::State *qNew, std::vector< Vertex > &graphNeighborhood, std::vector< Vertex > &visibleNeighborhood)
Checks to see if the current sample reveals the existence of an interface, and if so...
Definition: SPARSdb.cpp:1129
Struct for passing around partially solved solutions.
Definition: SPARSdb.h:240
boost::property< vertex_state_t, base::State *, boost::property< boost::vertex_predecessor_t, VertexIndexType, boost::property< boost::vertex_rank_t, VertexIndexType, boost::property< vertex_color_t, GuardType, boost::property< vertex_interface_data_t, InterfaceHashStruct > > > > > VertexProperties
The underlying roadmap graph.
Definition: SPARSdb.h:288
boost::readable_property_map_tag category
Definition: SPARSdb.h:336
SPArse Roadmap Spanner Version 2.0
Definition: SPARSdb.h:88
virtual ~SPARSdb()
Destructor.
Definition: SPARSdb.cpp:137
Vertex queryVertex_
Vertex for performing nearest neighbor queries.
Definition: SPARSdb.h:730
void computeX(Vertex v, Vertex vp, Vertex vpp, std::vector< Vertex > &Xs)
Computes all nodes which qualify as a candidate x for v, v&#39;, and v".
Definition: SPARSdb.cpp:1506
void resetFailures()
A reset function for resetting the failures count.
Definition: SPARSdb.cpp:1271
long unsigned int getIterations() const
Get the number of iterations the algorithm performed.
Definition: SPARSdb.h:560
std::size_t getStateCount() const
Get the number of states (way-points) that make up this path.
void freeMemory()
Free all the memory allocated by the planner.
Definition: SPARSdb.cpp:180
void printDebug(std::ostream &out=std::cout) const
Print debug information about planner.
Definition: SPARSdb.cpp:564
unsigned int maxFailures_
The number of consecutive failures to add to the graph before termination.
Definition: SPARSdb.h:742
unsigned int getNumConnectedComponents() const
Get the number of disjoint sets in the sparse roadmap.
Definition: SPARSdb.h:535
bool getSimilarPaths(int nearestK, const base::State *start, const base::State *goal, CandidateSolution &candidateSolution, const base::PlannerTerminationCondition &ptc)
Search the roadmap for the best path close to the given start and goal states that is valid...
Definition: SPARSdb.cpp:199
void findCloseRepresentatives(base::State *workState, const base::State *qNew, Vertex qRep, std::map< Vertex, base::State * > &closeRepresentatives, const base::PlannerTerminationCondition &ptc)
Finds representatives of samples near qNew_ which are not his representative.
Definition: SPARSdb.cpp:1372
virtual base::PlannerStatus solve(const base::PlannerTerminationCondition &ptc)
Function that can solve the motion planning problem. This function can be called multiple times on th...
Definition: SPARSdb.cpp:1059
unsigned int numPathInsertionFailures_
Track how many solutions fail to have connectivity at end.
Definition: SPARSdb.h:745
base::State * sigmaA_
States which lie just outside the visibility region of a vertex and support an interface.
Definition: SPARSdb.h:122
Main namespace. Contains everything in this library.
Definition: Cost.h:42
Vertex findGraphRepresentative(base::State *st)
Finds the representative of the input state, st.
Definition: SPARSdb.cpp:1344
void checkQueryStateInitialization()
Check that the query vertex is initialized (used for internal nearest neighbor searches) ...
Definition: SPARSdb.cpp:1050
std::vector< Vertex > startVertexCandidateNeighbors_
Used by getSimilarPaths.
Definition: SPARSdb.h:792
boost::property< boost::edge_weight_t, double, boost::property< edge_collision_state_t, int > > EdgeProperties
Definition: SPARSdb.h:292
Random number generation. An instance of this class cannot be used by multiple threads at once (membe...
Definition: RandomNumbers.h:58
long unsigned int iterations_
A counter for the number of iterations of the algorithm.
Definition: SPARSdb.h:783
Base class for a planner.
Definition: Planner.h:230
unsigned int getNumVertices() const
Get the number of vertices in the sparse roadmap.
Definition: SPARSdb.h:523
void setNearestNeighbors()
Set a different nearest neighbors datastructure.
Definition: SPARSdb.h:495
unsigned int getMaxFailures() const
Retrieve the maximum consecutive failure limit.
Definition: SPARSdb.h:430
VertexPair index(Vertex vp, Vertex vpp)
Rectifies indexing order for accessing the vertex data.
Definition: SPARSdb.cpp:1520
void clearEdgeCollisionStates()
Clear all past edge state information about in collision or not.
Definition: SPARSdb.cpp:1832
double distanceFunction(const Vertex a, const Vertex b) const
Compute distance between two milestones (this is simply distance between the states of the milestones...
Definition: SPARSdb.h:709
void setPlannerData(const base::PlannerData &data)
Set the sparse graph from file.
Definition: SPARSdb.cpp:1766
A class to store the exit status of Planner::solve()
Definition: PlannerStatus.h:48
base::ValidStateSamplerPtr sampler_
Sampler user for generating valid samples in the state space.
Definition: SPARSdb.h:715
void checkForSolution(const base::PlannerTerminationCondition &ptc, base::PathPtr &solution)
boost::graph_traits< Graph >::vertex_descriptor Vertex
Vertex in Graph.
Definition: SPARSdb.h:304
A shared pointer wrapper for ompl::base::SpaceInformation.
bool getPaths(const std::vector< Vertex > &candidateStarts, const std::vector< Vertex > &candidateGoals, const base::State *actualStart, const base::State *actualGoal, CandidateSolution &candidateSolution, const base::PlannerTerminationCondition &ptc)
Check if there exists a solution, i.e., there exists a pair of milestones such that the first is in s...
Definition: SPARSdb.cpp:259
unsigned int nearSamplePoints_
Number of sample points to use when trying to detect interfaces.
Definition: SPARSdb.h:748
bool reachedFailureLimit() const
Returns whether we have reached the iteration failures limit, maxFailures_.
Definition: SPARSdb.cpp:559
void computeVPP(Vertex v, Vertex vp, std::vector< Vertex > &VPPs)
Computes all nodes which qualify as a candidate v" for v and vp.
Definition: SPARSdb.cpp:1497
bool checkAddConnectivity(const base::State *qNew, std::vector< Vertex > &visibleNeighborhood)
Checks to see if the sample needs to be added to ensure connectivity.
Definition: SPARSdb.cpp:1079
Definition of an abstract state.
Definition: State.h:50
boost::graph_traits< Graph >::edge_descriptor Edge
Edge in Graph.
Definition: SPARSdb.h:307
std::unordered_map< VertexPair, InterfaceData > InterfaceHash
the hash which maps pairs of neighbor points to pairs of states
Definition: SPARSdb.h:196
void setSparseDeltaFraction(double D)
Sets vertex visibility range as a fraction of max. extent.
Definition: SPARSdb.h:408
boost::property_map< Graph, vertex_state_t >::type stateProperty_
Access to the internal base::state at each Vertex.
Definition: SPARSdb.h:760
double stretchFactor_
Stretch Factor as per graph spanner literature (multiplicative bound on path quality) ...
Definition: SPARSdb.h:733
const Graph & getRoadmap() const
Retrieve the computed roadmap.
Definition: SPARSdb.h:517
void setSecond(const base::State *p, const base::State *s, const base::SpaceInformationPtr &si)
Sets information for the second interface (i.e. interface with larger index vertex).
Definition: SPARSdb.h:180
A shared pointer wrapper for ompl::geometric::PathSimplifier.
double sparseDelta_
Maximum visibility range for nodes in the graph.
Definition: SPARSdb.h:786
unsigned int consecutiveFailures_
A counter for the number of consecutive failed iterations of the algorithm.
Definition: SPARSdb.h:780
std::vector< Vertex > goalM_
Array of goal milestones.
Definition: SPARSdb.h:727
unsigned int getNumPathInsertionFailed() const
Get the number of times a path was inserted into the database and it failed to have connectivity...
Definition: SPARSdb.h:548
void approachGraph(Vertex v)
Approaches the graph from a given vertex.
Definition: SPARSdb.cpp:1330
EdgeCollisionStateMap edgeCollisionStateProperty_
Access to the collision checking state of each Edge.
Definition: SPARSdb.h:757
RNG rng_
Random number generator.
Definition: SPARSdb.h:774
InterfaceData & getData(Vertex v, Vertex vp, Vertex vpp)
Retrieves the Vertex data associated with v,vp,vpp.
Definition: SPARSdb.cpp:1530
bool sameComponent(Vertex m1, Vertex m2)
Check if two milestones (m1 and m2) are part of the same connected component. This is not a const fun...
Definition: SPARSdb.cpp:554
void updatePairPoints(Vertex rep, const base::State *q, Vertex r, const base::State *s)
High-level method which updates pair point information for repV_ with neighbor r. ...
Definition: SPARSdb.cpp:1485
std::vector< Vertex > startM_
Array of start milestones.
Definition: SPARSdb.h:724
PathSimplifierPtr psimp_
A path simplifier used to simplify dense paths added to the graph.
Definition: SPARSdb.h:751
std::pair< VertexIndexType, VertexIndexType > VertexPair
Pair of vertices which support an interface.
Definition: SPARSdb.h:111
Vertex addGuard(base::State *state, GuardType type)
Construct a guard for a given state (state) and store it in the nearest neighbors data structure...
Definition: SPARSdb.cpp:1597
double getDenseDeltaFraction() const
Retrieve the dense graph interface support delta.
Definition: SPARSdb.h:436
unsigned long int VertexIndexType
The type used internally for representing vertex IDs.
Definition: SPARSdb.h:108
Definition of a geometric path.
Definition: PathGeometric.h:60
void abandonLists(base::State *st)
When a new guard is added at state st, finds all guards who must abandon their interface information ...
Definition: SPARSdb.cpp:1580
std::shared_ptr< NearestNeighbors< Vertex > > nn_
Nearest neighbors data structure.
Definition: SPARSdb.h:718
bool lazyCollisionSearch(const Vertex &start, const Vertex &goal, const base::State *actualStart, const base::State *actualGoal, CandidateSolution &candidateSolution, const base::PlannerTerminationCondition &ptc)
Repeatidly search through graph for connection then check for collisions then repeat.
Definition: SPARSdb.cpp:315
void connectGuards(Vertex v, Vertex vp)
Connect two guards in the roadmap.
Definition: SPARSdb.cpp:1623
SpaceInformationPtr si_
The space information for which planning is done.
Definition: Planner.h:398
void clearQuery()
Clear the query previously loaded from the ProblemDefinition. Subsequent calls to solve() will reuse ...
Definition: SPARSdb.cpp:162
void setFirst(const base::State *p, const base::State *s, const base::SpaceInformationPtr &si)
Sets information for the first interface (i.e. interface with smaller index vertex).
Definition: SPARSdb.h:165
void setStretchFactor(double t)
Sets the stretch factor.
Definition: SPARSdb.h:402
GuardType
Enumeration which specifies the reason a guard is added to the spanner.
Definition: SPARSdb.h:93
virtual void setProblemDefinition(const base::ProblemDefinitionPtr &pdef)
Set the problem definition for the planner. The problem needs to be set before calling solve()...
Definition: SPARSdb.cpp:156
bool isSetup() const
Check if setup() was called for this planner.
Definition: Planner.cpp:107
A shared pointer wrapper for ompl::base::Path.
double denseDelta_
Maximum range for allowing two samples to support an interface.
Definition: SPARSdb.h:789
virtual void getPlannerData(base::PlannerData &data) const
Get information about the current run of the motion planner. Repeated calls to this function will upd...
Definition: SPARSdb.cpp:1718
unsigned int getNumConsecutiveFailures() const
description
Definition: SPARSdb.h:554