SPARS.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 */
36 
37 #ifndef OMPL_GEOMETRIC_PLANNERS_SPARSE_ROADMAP_SPANNER_
38 #define OMPL_GEOMETRIC_PLANNERS_SPARSE_ROADMAP_SPANNER_
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 
45 #include <boost/range/adaptor/map.hpp>
46 #include <unordered_map>
47 #include <boost/graph/graph_traits.hpp>
48 #include <boost/graph/adjacency_list.hpp>
49 #include <boost/pending/disjoint_sets.hpp>
50 #include <functional>
51 #include <mutex>
52 #include <iostream>
53 #include <fstream>
54 #include <utility>
55 #include <vector>
56 #include <deque>
57 #include <map>
58 #include <set>
59 
60 namespace ompl
61 {
62 
63  namespace geometric
64  {
65 
80  class SPARS : public base::Planner
81  {
82  public:
84  enum GuardType
85  {
86  START,
87  GOAL,
88  COVERAGE,
89  CONNECTIVITY,
90  INTERFACE,
91  QUALITY,
92  };
93 
94  struct vertex_state_t {
95  typedef boost::vertex_property_tag kind;
96  };
97 
99  typedef boost::vertex_property_tag kind;
100  };
101 
102  struct vertex_color_t {
103  typedef boost::vertex_property_tag kind;
104  };
105 
106  struct vertex_list_t {
107  typedef boost::vertex_property_tag kind;
108  };
109 
111  typedef boost::vertex_property_tag kind;
112  };
113 
115  typedef unsigned long int VertexIndexType;
116 
118  typedef std::unordered_map<VertexIndexType, std::set<VertexIndexType> > InterfaceHash;
119 
121  typedef std::deque<base::State*> DensePath;
122 
135  typedef boost::adjacency_list <
136  boost::vecS, boost::vecS, boost::undirectedS,
137  boost::property < vertex_state_t, base::State*,
138  boost::property < boost::vertex_predecessor_t, VertexIndexType,
139  boost::property < boost::vertex_rank_t, VertexIndexType,
140  boost::property < vertex_color_t, GuardType,
141  boost::property < vertex_list_t, std::set<VertexIndexType>,
142  boost::property < vertex_interface_list_t, InterfaceHash > > > > > >,
143  boost::property < boost::edge_weight_t, base::Cost >
145 
147  typedef boost::graph_traits<SpannerGraph>::vertex_descriptor SparseVertex;
148 
150  typedef boost::graph_traits<SpannerGraph>::edge_descriptor SparseEdge;
151 
153  typedef std::shared_ptr< NearestNeighbors<SparseVertex> > SparseNeighbors;
154 
170  typedef boost::adjacency_list <
171  boost::vecS, boost::vecS, boost::undirectedS,
172  boost::property < vertex_state_t, base::State*,
173  boost::property < boost::vertex_predecessor_t, VertexIndexType,
174  boost::property < boost::vertex_rank_t, VertexIndexType,
175  boost::property < vertex_representative_t, SparseVertex > > > >,
176  boost::property < boost::edge_weight_t, double >
178 
180  typedef boost::graph_traits<DenseGraph>::vertex_descriptor DenseVertex;
181 
183  typedef boost::graph_traits<DenseGraph>::edge_descriptor DenseEdge;
184 
186  typedef std::shared_ptr< NearestNeighbors<DenseVertex> > DenseNeighbors;
187 
189  SPARS(const base::SpaceInformationPtr &si);
191  virtual ~SPARS();
192 
193  virtual void setProblemDefinition(const base::ProblemDefinitionPtr &pdef);
194 
195  virtual void getPlannerData(base::PlannerData &data) const;
196 
199 
202  void constructRoadmap(const base::PlannerTerminationCondition &ptc, bool stopOnMaxFail);
203 
217 
222  void clearQuery();
223 
224  virtual void clear();
225 
231  template<template<typename T> class NN>
233  {
234  nn_.reset(new NN<DenseVertex>());
235  connectionStrategy_ = std::function<const std::vector<DenseVertex>&(const DenseVertex)>();
236  if (isSetup())
237  setup();
238  }
239 
244  template<template<typename T> class NN>
246  {
247  snn_.reset(new NN<SparseVertex>());
248  if (isSetup())
249  setup();
250  }
251 
256  void setMaxFailures(unsigned int m)
257  {
258  maxFailures_ = m;
259  }
260 
264  void setDenseDeltaFraction(double d)
265  {
267  if (denseDelta_ > 0.0) // setup was previously called
268  denseDelta_ = d * si_->getMaximumExtent();
269  }
270 
275  void setSparseDeltaFraction(double d)
276  {
278  if (sparseDelta_ > 0.0) // setup was previously called
279  sparseDelta_ = d * si_->getMaximumExtent();
280  }
281 
285  void setStretchFactor(double t)
286  {
287  stretchFactor_ = t;
288  }
289 
291  unsigned getMaxFailures() const
292  {
293  return maxFailures_;
294  }
295 
297  double getDenseDeltaFraction() const
298  {
299  return denseDeltaFraction_;
300  }
301 
303  double getSparseDeltaFraction() const
304  {
305  return sparseDeltaFraction_;
306  }
307 
309  double getStretchFactor() const
310  {
311  return stretchFactor_;
312  }
313 
314  virtual void setup();
315 
317  const DenseGraph& getDenseGraph() const
318  {
319  return g_;
320  }
321 
324  const SpannerGraph& getRoadmap() const
325  {
326  return s_;
327  }
328 
330  unsigned int milestoneCount() const
331  {
332  return boost::num_vertices(g_);
333  }
334 
336  unsigned int guardCount() const
337  {
338  return boost::num_vertices(s_);
339  }
340 
342  double averageValence() const;
343 
345  void printDebug(std::ostream &out = std::cout) const;
346 
348  bool reachedFailureLimit() const;
349 
351  // Planner progress property functions
352  std::string getIterationCount() const
353  {
354  return boost::lexical_cast<std::string>(iterations_);
355  }
356  std::string getBestCost() const
357  {
358  return boost::lexical_cast<std::string>(bestCost_);
359  }
360 
361  protected:
362 
364  DenseVertex addSample(base::State *workState, const base::PlannerTerminationCondition &ptc);
365 
368 
370  bool sameComponent(SparseVertex m1, SparseVertex m2);
371 
373  DenseVertex addMilestone(base::State *state);
374 
376  SparseVertex addGuard(base::State *state, GuardType type);
377 
379  void connectSparsePoints(SparseVertex v, SparseVertex vp);
380 
382  void connectDensePoints(DenseVertex v, DenseVertex vp);
383 
385  bool checkAddCoverage(const base::State *lastState, const std::vector<SparseVertex> &neigh);
386 
388  bool checkAddConnectivity(const base::State *lastState, const std::vector<SparseVertex> &neigh);
389 
391  bool checkAddInterface(const std::vector<DenseVertex>& graphNeighborhood, const std::vector<DenseVertex>& visibleNeighborhood, DenseVertex q);
392 
394  bool checkAddPath( DenseVertex q, const std::vector<DenseVertex>& neigh );
395 
397  DenseVertex getInterfaceNeighbor(DenseVertex q, SparseVertex rep);
398 
400  bool addPathToSpanner(const DensePath &p, SparseVertex vp, SparseVertex vpp);
401 
403  void updateRepresentatives(SparseVertex v);
404 
406  void calculateRepresentative( DenseVertex q );
407 
409  void addToRepresentatives( DenseVertex q, SparseVertex rep, const std::set<SparseVertex>& oreps );
410 
412  void removeFromRepresentatives( DenseVertex q, SparseVertex rep );
413 
415  void computeVPP(DenseVertex v, DenseVertex vp, std::vector<SparseVertex> &VPPs);
416 
418  void computeX(DenseVertex v, DenseVertex vp, DenseVertex vpp, std::vector<SparseVertex> &Xs);
419 
421  void resetFailures();
422 
425 
427  bool haveSolution(const std::vector<DenseVertex> &start, const std::vector<DenseVertex> &goal, base::PathPtr &solution);
428 
430  bool reachedTerminationCriterion() const;
431 
433  base::PathPtr constructSolution(const SparseVertex start, const SparseVertex goal) const;
434 
436  void computeDensePath(const DenseVertex start, const DenseVertex goal, DensePath &path) const;
437 
439  void freeMemory();
440 
442  void getSparseNeighbors(base::State *inState, std::vector< SparseVertex > &graphNeighborhood);
443 
445  void filterVisibleNeighbors(base::State *inState, const std::vector<SparseVertex> &graphNeighborhood, std::vector<SparseVertex> &visibleNeighborhood) const;
446 
448  void getInterfaceNeighborRepresentatives(DenseVertex q, std::set<SparseVertex> &interfaceRepresentatives);
449 
451  void getInterfaceNeighborhood(DenseVertex q, std::vector<DenseVertex> &interfaceNeighborhood);
452 
454  double distanceFunction(const DenseVertex a, const DenseVertex b) const
455  {
456  return si_->distance(stateProperty_[a], stateProperty_[b]);
457  }
458 
460  double sparseDistanceFunction( const SparseVertex a, const SparseVertex b ) const
461  {
462  return si_->distance( sparseStateProperty_[a], sparseStateProperty_[b] );
463  }
464 
467 
470 
472  DenseNeighbors nn_;
473 
475  SparseNeighbors snn_;
476 
479 
482 
484  std::vector<SparseVertex> startM_;
485 
487  std::vector<SparseVertex> goalM_;
488 
490  DenseVertex sparseQueryVertex_;
491 
493  DenseVertex queryVertex_;
494 
497 
499  boost::property_map<DenseGraph, vertex_state_t>::type stateProperty_;
500 
502  boost::property_map<SpannerGraph, vertex_state_t>::type sparseStateProperty_;
503 
505  boost::property_map<SpannerGraph, vertex_color_t>::type sparseColorProperty_;
506 
508  boost::property_map<DenseGraph, vertex_representative_t>::type representativesProperty_;
509 
511  boost::property_map<SpannerGraph, vertex_list_t>::type nonInterfaceListsProperty_;
512 
514  boost::property_map<SpannerGraph, vertex_interface_list_t>::type interfaceListsProperty_;
515 
518 
520  boost::property_map<DenseGraph, boost::edge_weight_t>::type weightProperty_;
521 
523  boost::disjoint_sets<
524  boost::property_map<SpannerGraph, boost::vertex_rank_t>::type,
525  boost::property_map<SpannerGraph, boost::vertex_predecessor_t>::type >
527 
529  std::function<const std::vector<DenseVertex>&(const DenseVertex)> connectionStrategy_;
530 
532  unsigned int consecutiveFailures_;
533 
536 
538  unsigned int maxFailures_;
539 
542 
545 
548 
550  double denseDelta_;
551 
553  double sparseDelta_;
554 
557 
559  mutable std::mutex graphMutex_;
560 
563 
565  base::Cost costHeuristic(SparseVertex u, SparseVertex v) const;
566 
568  // Planner progress properties
570  long unsigned int iterations_;
573  };
574 
575  }
576 }
577 
578 #endif
double stretchFactor_
The stretch factor in terms of graph spanners for SPARS to check against.
Definition: SPARS.h:535
void freeMemory()
Free all the memory allocated by the planner.
Definition: SPARS.cpp:178
virtual void clear()
Clear all internal datastructures. Planner settings are not affected. Subsequent calls to solve() wil...
Definition: SPARS.cpp:162
Object containing planner generated vertex and edge data. It is assumed that all vertices are unique...
Definition: PlannerData.h:163
boost::adjacency_list< boost::vecS, boost::vecS, boost::undirectedS, 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_list_t, std::set< VertexIndexType >, boost::property< vertex_interface_list_t, InterfaceHash > > > > > >, boost::property< boost::edge_weight_t, base::Cost > > SpannerGraph
The constructed roadmap spanner.
Definition: SPARS.h:144
base::StateSamplerPtr simpleSampler_
Sampler user for generating random in the state space.
Definition: SPARS.h:469
void clearQuery()
Clear the query previously loaded from the ProblemDefinition. Subsequent calls to solve() will reuse ...
Definition: SPARS.cpp:151
unsigned long int VertexIndexType
The type used internally for representing vertex IDs.
Definition: SPARS.h:115
SPARS(const base::SpaceInformationPtr &si)
Constructor.
Definition: SPARS.cpp:55
base::ValidStateSamplerPtr sampler_
Sampler user for generating valid samples in the state space.
Definition: SPARS.h:466
boost::adjacency_list< boost::vecS, boost::vecS, boost::undirectedS, boost::property< vertex_state_t, base::State *, boost::property< boost::vertex_predecessor_t, VertexIndexType, boost::property< boost::vertex_rank_t, VertexIndexType, boost::property< vertex_representative_t, SparseVertex > > > >, boost::property< boost::edge_weight_t, double > > DenseGraph
The underlying roadmap graph.
Definition: SPARS.h:177
A shared pointer wrapper for ompl::base::ProblemDefinition.
PathSimplifierPtr psimp_
A path simplifier used to simplify dense paths added to S.
Definition: SPARS.h:517
RNG rng_
Random number generator.
Definition: SPARS.h:556
A shared pointer wrapper for ompl::base::ValidStateSampler.
virtual void setup()
Perform extra configuration steps, if needed. This call will also issue a call to ompl::base::SpaceIn...
Definition: SPARS.cpp:102
long unsigned int iterations_
A counter for the number of iterations of the algorithm.
Definition: SPARS.h:570
boost::property_map< SpannerGraph, vertex_interface_list_t >::type interfaceListsProperty_
Access to the interface-supporting vertice hashes of the sparse nodes.
Definition: SPARS.h:514
DenseVertex getInterfaceNeighbor(DenseVertex q, SparseVertex rep)
Get the first neighbor of q who has representative rep and is within denseDelta_. ...
Definition: SPARS.cpp:760
A shared pointer wrapper for ompl::base::StateSampler.
double denseDeltaFraction_
SPARS parameter for dense graph connection distance as a fraction of max. extent. ...
Definition: SPARS.h:544
virtual ~SPARS()
Destructor.
Definition: SPARS.cpp:97
const DenseGraph & getDenseGraph() const
Retrieve the underlying dense graph structure. This is built as a PRM* and asymptotically approximate...
Definition: SPARS.h:317
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: SPARS.cpp:308
void setDenseDeltaFraction(double d)
Set the delta fraction for interface detection. If two nodes in the dense graph are more than a delta...
Definition: SPARS.h:264
double sparseDelta_
SPARS parameter for Sparse Roadmap connection distance.
Definition: SPARS.h:553
std::function< const std::vector< DenseVertex > &(const DenseVertex)> connectionStrategy_
Function that returns the milestones to attempt connections with.
Definition: SPARS.h:529
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: SPARS.cpp:1021
double distanceFunction(const DenseVertex a, const DenseVertex b) const
Compute distance between two milestones (this is simply distance between the states of the milestones...
Definition: SPARS.h:454
Encapsulate a termination condition for a motion planner. Planners will call operator() to decide whe...
bool checkAddPath(DenseVertex q, const std::vector< DenseVertex > &neigh)
Checks for adding an entire dense path to the Sparse Roadmap.
Definition: SPARS.cpp:607
boost::graph_traits< SpannerGraph >::edge_descriptor SparseEdge
An edge in the sparse roadmap that is constructed.
Definition: SPARS.h:150
void removeFromRepresentatives(DenseVertex q, SparseVertex rep)
Removes the node from its representative&#39;s lists.
Definition: SPARS.cpp:887
void getInterfaceNeighborRepresentatives(DenseVertex q, std::set< SparseVertex > &interfaceRepresentatives)
Gets the representatives of all interfaces that q supports.
Definition: SPARS.cpp:918
bool reachedTerminationCriterion() const
Returns true if we have reached the iteration failures limit, maxFailures_ or if a solution was added...
Definition: SPARS.cpp:281
SparseNeighbors snn_
Nearest Neighbors structure for the sparse roadmap.
Definition: SPARS.h:475
void constructRoadmap(const base::PlannerTerminationCondition &ptc)
While the termination condition permits, construct the spanner graph.
Definition: SPARS.cpp:395
void printDebug(std::ostream &out=std::cout) const
Print debug information about planner.
Definition: SPARS.cpp:724
void computeVPP(DenseVertex v, DenseVertex vp, std::vector< SparseVertex > &VPPs)
Computes all nodes which qualify as a candidate v" for v and vp.
Definition: SPARS.cpp:900
unsigned int maxFailures_
The maximum number of failures before terminating the algorithm.
Definition: SPARS.h:538
unsigned int milestoneCount() const
Returns the number of milestones added to D.
Definition: SPARS.h:330
base::Cost costHeuristic(SparseVertex u, SparseVertex v) const
Given two vertices, returns a heuristic on the cost of the path connecting them. This method wraps Op...
Definition: SPARS.cpp:1051
boost::property_map< SpannerGraph, vertex_list_t >::type nonInterfaceListsProperty_
Access to all non-interface supporting vertices of the sparse nodes.
Definition: SPARS.h:511
bool checkAddCoverage(const base::State *lastState, const std::vector< SparseVertex > &neigh)
Checks the latest dense sample for the coverage property, and adds appropriately. ...
Definition: SPARS.cpp:530
void setMaxFailures(unsigned int m)
Set the maximum consecutive failures to augment the spanner before termination. In general...
Definition: SPARS.h:256
double getSparseDeltaFraction() const
Retrieve the sparse graph visibility range delta fraction.
Definition: SPARS.h:303
void calculateRepresentative(DenseVertex q)
Calculates the representative for a dense sample.
Definition: SPARS.cpp:845
void updateRepresentatives(SparseVertex v)
Automatically updates the representatives of all dense samplse within sparseDelta_ of v...
Definition: SPARS.cpp:810
void setStretchFactor(double t)
Set the roadmap spanner stretch factor. This value represents a multiplicative upper bound on path qu...
Definition: SPARS.h:285
void addToRepresentatives(DenseVertex q, SparseVertex rep, const std::set< SparseVertex > &oreps)
Adds a dense sample to the appropriate lists of its representative.
Definition: SPARS.cpp:862
double getStretchFactor() const
Retrieve the spanner&#39;s set stretch factor.
Definition: SPARS.h:309
Main namespace. Contains everything in this library.
Definition: Cost.h:42
double getDenseDeltaFraction() const
Retrieve the dense graph interface support delta fraction.
Definition: SPARS.h:297
DenseVertex addMilestone(base::State *state)
Construct a milestone for a given state (state) and store it in the nearest neighbors data structure...
Definition: SPARS.cpp:456
std::vector< SparseVertex > goalM_
Array of goal guards.
Definition: SPARS.h:487
Random number generation. An instance of this class cannot be used by multiple threads at once (membe...
Definition: RandomNumbers.h:58
void getInterfaceNeighborhood(DenseVertex q, std::vector< DenseVertex > &interfaceNeighborhood)
Gets the neighbors of q who help it support an interface.
Definition: SPARS.cpp:938
std::shared_ptr< NearestNeighbors< SparseVertex > > SparseNeighbors
Nearest neighbor structure which works over the SpannerGraph.
Definition: SPARS.h:153
boost::graph_traits< SpannerGraph >::vertex_descriptor SparseVertex
A vertex in the sparse roadmap that is constructed.
Definition: SPARS.h:147
boost::disjoint_sets< boost::property_map< SpannerGraph, boost::vertex_rank_t >::type, boost::property_map< SpannerGraph, boost::vertex_predecessor_t >::type > sparseDJSets_
Data structure that maintains the connected components of S.
Definition: SPARS.h:526
boost::property_map< DenseGraph, vertex_state_t >::type stateProperty_
Access to the internal base::state at each DenseVertex.
Definition: SPARS.h:499
boost::graph_traits< DenseGraph >::edge_descriptor DenseEdge
An edge in DenseGraph.
Definition: SPARS.h:183
boost::property_map< SpannerGraph, vertex_state_t >::type sparseStateProperty_
Access to the internal base::State for each SparseVertex of S.
Definition: SPARS.h:502
Base class for a planner.
Definition: Planner.h:230
void connectDensePoints(DenseVertex v, DenseVertex vp)
Connects points in the dense graph.
Definition: SPARS.cpp:522
const SpannerGraph & getRoadmap() const
Retrieve the sparse roadmap structure. This is the structure which answers given queries, and has the desired property of asymptotic near-optimality.
Definition: SPARS.h:324
boost::graph_traits< DenseGraph >::vertex_descriptor DenseVertex
A vertex in DenseGraph.
Definition: SPARS.h:180
void setDenseNeighbors()
Set a different nearest neighbors datastructure for the roadmap graph. This nearest neighbor structur...
Definition: SPARS.h:232
double sparseDeltaFraction_
SPARS parameter for Sparse Roadmap connection distance as a fraction of max. extent.
Definition: SPARS.h:547
void computeDensePath(const DenseVertex start, const DenseVertex goal, DensePath &path) const
Constructs the dense path between the start and goal vertices (if connected)
Definition: SPARS.cpp:994
base::Cost bestCost_
Best cost found so far by algorithm.
Definition: SPARS.h:572
void filterVisibleNeighbors(base::State *inState, const std::vector< SparseVertex > &graphNeighborhood, std::vector< SparseVertex > &visibleNeighborhood) const
Get the visible neighbors.
Definition: SPARS.cpp:750
SPArse Roadmap Spanner technique.
Definition: SPARS.h:80
boost::property_map< SpannerGraph, vertex_color_t >::type sparseColorProperty_
Access to draw colors for the SparseVertexs of S, to indicate addition type.
Definition: SPARS.h:505
void computeX(DenseVertex v, DenseVertex vp, DenseVertex vpp, std::vector< SparseVertex > &Xs)
Computes all nodes which qualify as a candidate x for v, v&#39;, and v".
Definition: SPARS.cpp:908
unsigned int guardCount() const
Returns the number of guards added to S.
Definition: SPARS.h:336
std::mutex graphMutex_
Mutex to guard access to the graphs.
Definition: SPARS.h:559
bool haveSolution(const std::vector< DenseVertex > &start, const std::vector< DenseVertex > &goal, base::PathPtr &solution)
Check if there exists a solution, i.e., there exists a pair of milestones such that the first is in s...
Definition: SPARS.cpp:241
A class to store the exit status of Planner::solve()
Definition: PlannerStatus.h:48
A shared pointer wrapper for ompl::base::SpaceInformation.
std::shared_ptr< NearestNeighbors< DenseVertex > > DenseNeighbors
Nearest neighbor structure which works over the DenseGraph.
Definition: SPARS.h:186
base::PathPtr constructSolution(const SparseVertex start, const SparseVertex goal) const
Given two milestones from the same connected component, construct a path connecting them and set it a...
Definition: SPARS.cpp:955
Definition of an abstract state.
Definition: State.h:50
DenseVertex sparseQueryVertex_
DenseVertex for performing nearest neighbor queries on the SPARSE roadmap.
Definition: SPARS.h:490
A shared pointer wrapper for ompl::geometric::PathSimplifier.
unsigned getMaxFailures() const
Retrieve the maximum consecutive failure limit.
Definition: SPARS.h:291
unsigned int consecutiveFailures_
A counter for the number of consecutive failed iterations of the algorithm.
Definition: SPARS.h:532
A shared pointer wrapper for ompl::base::OptimizationObjective.
virtual void setProblemDefinition(const base::ProblemDefinitionPtr &pdef)
Set the problem definition for the planner. The problem needs to be set before calling solve()...
Definition: SPARS.cpp:140
DenseVertex queryVertex_
Vertex for performing nearest neighbor queries on the DENSE graph.
Definition: SPARS.h:493
bool checkAddInterface(const std::vector< DenseVertex > &graphNeighborhood, const std::vector< DenseVertex > &visibleNeighborhood, DenseVertex q)
Checks the latest dense sample for bridging an edge-less interface.
Definition: SPARS.cpp:575
SpannerGraph s_
The sparse roadmap, S.
Definition: SPARS.h:481
bool reachedFailureLimit() const
Returns true if we have reached the iteration failures limit, maxFailures_.
Definition: SPARS.cpp:286
double denseDelta_
SPARS parameter for dense graph connection distance.
Definition: SPARS.h:550
void checkForSolution(const base::PlannerTerminationCondition &ptc, base::PathPtr &solution)
Definition: SPARS.cpp:217
bool addedSolution_
A flag indicating that a solution has been added during solve()
Definition: SPARS.h:541
bool checkAddConnectivity(const base::State *lastState, const std::vector< SparseVertex > &neigh)
Checks the latest dense sample for connectivity, and adds appropriately.
Definition: SPARS.cpp:543
base::OptimizationObjectivePtr opt_
Objective cost function for PRM graph edges.
Definition: SPARS.h:562
void connectSparsePoints(SparseVertex v, SparseVertex vp)
Convenience function for creating an edge in the Spanner Roadmap.
Definition: SPARS.cpp:513
void getSparseNeighbors(base::State *inState, std::vector< SparseVertex > &graphNeighborhood)
Get all nodes in the sparse graph which are within sparseDelta_ of the given state.
Definition: SPARS.cpp:740
void setSparseNeighbors()
Set a different nearest neighbors datastructure for the spanner graph. This structure is stores only ...
Definition: SPARS.h:245
void checkQueryStateInitialization()
Check that the query vertex is initialized (used for internal nearest neighbor searches) ...
Definition: SPARS.cpp:291
std::vector< SparseVertex > startM_
Array of start guards.
Definition: SPARS.h:484
Definition of a geometric path.
Definition: PathGeometric.h:60
std::unordered_map< VertexIndexType, std::set< VertexIndexType > > InterfaceHash
Hash for storing interface information.
Definition: SPARS.h:118
boost::property_map< DenseGraph, boost::edge_weight_t >::type weightProperty_
Access to the weights of each DenseEdge.
Definition: SPARS.h:520
SparseVertex addGuard(base::State *state, GuardType type)
Construct a node with the given state (state) for the spanner and store it in the nn structure...
Definition: SPARS.cpp:496
SpaceInformationPtr si_
The space information for which planning is done.
Definition: Planner.h:398
void resetFailures()
A reset function for resetting the failures count.
Definition: SPARS.cpp:146
double sparseDistanceFunction(const SparseVertex a, const SparseVertex b) const
Compute distance between two nodes in the sparse roadmap spanner.
Definition: SPARS.h:460
PathGeometric geomPath_
Geometric Path variable used for smoothing out paths.
Definition: SPARS.h:496
bool addPathToSpanner(const DensePath &p, SparseVertex vp, SparseVertex vpp)
Method for actually adding a dense path to the Roadmap Spanner, S.
Definition: SPARS.cpp:769
boost::property_map< DenseGraph, vertex_representative_t >::type representativesProperty_
Access to the representatives of the Dense vertices.
Definition: SPARS.h:508
std::deque< base::State * > DensePath
Internal representation of a dense path.
Definition: SPARS.h:121
GuardType
Enumeration which specifies the reason a guard is added to the spanner.
Definition: SPARS.h:84
DenseGraph g_
The dense graph, D.
Definition: SPARS.h:478
void setSparseDeltaFraction(double d)
Set the delta fraction for connection distance on the sparse spanner. This value represents the visib...
Definition: SPARS.h:275
DenseVertex addSample(base::State *workState, const base::PlannerTerminationCondition &ptc)
Attempt to add a single sample to the roadmap.
Definition: SPARS.cpp:196
bool sameComponent(SparseVertex m1, SparseVertex m2)
Check that two vertices are in the same connected component.
Definition: SPARS.cpp:303
Definition of a cost value. Can represent the cost of a motion or the cost of a state.
Definition: Cost.h:47
bool isSetup() const
Check if setup() was called for this planner.
Definition: Planner.cpp:107
DenseNeighbors nn_
Nearest neighbors data structure.
Definition: SPARS.h:472
A shared pointer wrapper for ompl::base::Path.
double averageValence() const
Returns the average valence of the spanner graph.
Definition: SPARS.cpp:715