Loading...
Searching...
No Matches
SPARSdb.cpp
55// edgeWeightMap methods ////////////////////////////////////////////////////////////////////////////
58 (boost::ReadablePropertyMapConcept<ompl::geometric::SPARSdb::edgeWeightMap, ompl::geometric::SPARSdb::Edge>));
60ompl::geometric::SPARSdb::edgeWeightMap::edgeWeightMap(const Graph &graph, const EdgeCollisionStateMap &collisionStates)
76 double get(const ompl::geometric::SPARSdb::edgeWeightMap &m, const ompl::geometric::SPARSdb::Edge &e)
82// CustomVisitor methods ////////////////////////////////////////////////////////////////////////////
85 (boost::AStarVisitorConcept<ompl::geometric::SPARSdb::CustomVisitor, ompl::geometric::SPARSdb::Graph>));
97// SPARSdb methods ////////////////////////////////////////////////////////////////////////////////////////
119 Planner::declareParam<double>("stretch_factor", this, &SPARSdb::setStretchFactor, &SPARSdb::getStretchFactor,
125 Planner::declareParam<unsigned int>("max_failures", this, &SPARSdb::setMaxFailures, &SPARSdb::getMaxFailures,
139 nn_->setDistanceFunction([this](const Vertex a, const Vertex b) { return distanceFunction(a, b); });
179 foreach (InterfaceData &d, interfaceDataProperty_[v].interfaceHash | boost::adaptors::map_values)
191bool ompl::geometric::SPARSdb::getSimilarPaths(int /*nearestK*/, const base::State *start, const base::State *goal,
197 // Get neighbors near start and goal. Note: potentially they are not *visible* - will test for this later
221 getPaths(startVertexCandidateNeighbors_, goalVertexCandidateNeighbors_, start, goal, candidateSolution, ptc);
319 true; // sameComponent(start, goal); // TODO is this important? I disabled it during dev and never used it
347 // this is necessary for lazy collision checking i.e. rerun after marking invalid edges we found
444 // if ((diff < std::numeric_limits<double>::epsilon()) && (-diff < std::numeric_limits<double>::epsilon()))
572bool ompl::geometric::SPARSdb::getGuardSpacingFactor(const double pathLength, int &numGuards, double &spacingFactor)
581 OMPL_INFORM("Path length is too short to get a correct sparcing factor: length: %f, min: %f ", pathLength,
649 // Find spacing factor - 2.0 would be a perfect amount, but we leave room for rounding/interpolation errors and
656 OMPL_DEBUG("Expected number of necessary coverage guards is calculated to be %i from the original path state count "
663 n += si_->getStateSpace()->validSegmentCount(solutionPath.getState(i), solutionPath.getState(i + 1));
679 visualizeStateCallback(solutionPath.getState(solutionPath.getStateCount() - 1), 3, sparseDelta_);
697 distanceFromLastState = si_->distance(solutionPath.getState(i), solutionPath.getState(lastStateID));
729 double distA = si_->distance(solutionPath.getState(lastStateID), solutionPath.getState(midStateID));
732 if ((diff < std::numeric_limits<double>::epsilon()) && (-diff < std::numeric_limits<double>::epsilon()))
801 for (std::size_t i = 1; i < solutionPath.getStateCount(); ++i) // skip 0 because start already added
839bool ompl::geometric::SPARSdb::checkStartGoalConnection(ompl::geometric::PathGeometric &solutionPath)
934bool ompl::geometric::SPARSdb::addStateToRoadmap(const base::PlannerTerminationCondition &ptc, base::State *newState)
960 OMPL_INFORM("Visible neighbor is vertex %f with distance %f ", v, si_->distance(qNew, stateProperty_[v]));
971 OMPL_INFORM(" -- checkAddConnectivity() Does this node connect neighboring nodes that are not connected? ");
976 OMPL_INFORM(" --- checkAddInterface() Does this node's neighbor's need it to better connect them? ");
1060bool ompl::geometric::SPARSdb::checkAddCoverage(const base::State *qNew, std::vector<Vertex> &visibleNeighborhood)
1074bool ompl::geometric::SPARSdb::checkAddConnectivity(const base::State *qNew, std::vector<Vertex> &visibleNeighborhood)
1076 // Identify visibile nodes around our new state that are unconnected (in different connected components)
1125bool ompl::geometric::SPARSdb::checkAddInterface(const base::State *qNew, std::vector<Vertex> &graphNeighborhood,
1132 if (graphNeighborhood[0] == visibleNeighborhood[0] && graphNeighborhood[1] == visibleNeighborhood[1])
1138 if (si_->checkMotion(stateProperty_[visibleNeighborhood[0]], stateProperty_[visibleNeighborhood[1]]))
1272void ompl::geometric::SPARSdb::findGraphNeighbors(base::State *st, std::vector<Vertex> &graphNeighborhood,
1288bool ompl::geometric::SPARSdb::findGraphNeighbors(const base::State *state, std::vector<Vertex> &graphNeighborhood)
1341ompl::geometric::SPARSdb::Vertex ompl::geometric::SPARSdb::findGraphRepresentative(base::State *st)
1349 OMPL_INFORM(" ------- findGraphRepresentative found %d nearest neighbors of distance %f", nbh.size(),
1369void ompl::geometric::SPARSdb::findCloseRepresentatives(base::State *workState, const base::State *qNew,
1380 nearSamplePoints_ /= 10; // HACK - this makes it look for the same number of samples as dimensions
1484void ompl::geometric::SPARSdb::updatePairPoints(Vertex rep, const base::State *q, Vertex r, const base::State *s)
1505void ompl::geometric::SPARSdb::computeX(Vertex v, Vertex vp, Vertex vpp, std::vector<Vertex> &Xs)
1534void ompl::geometric::SPARSdb::distanceCheck(Vertex rep, const base::State *q, Vertex r, const base::State *s,
1549 // Should probably keep the one that is further away from rep? Not known what to do in this case.
1596ompl::geometric::SPARSdb::Vertex ompl::geometric::SPARSdb::addGuard(base::State *state, GuardType type)
1614 visualizeStateCallback(state, 4, sparseDelta_); // Candidate node has already (just) been added
1667 // the edge from actualStart to start is always valid otherwise we would not have used that start
1690 OMPL_ERROR("A chosen path has an edge that has not been checked for collision. This should not "
Definition of a cost value. Can represent the cost of a motion or the cost of a state.
Definition Cost.h:48
virtual bool isStartGoalPairValid(const State *, const State *) const
Since there can be multiple starting states (and multiple goal states) it is possible certain pairs a...
Definition Goal.h:136
Base class for a vertex in the PlannerData structure. All derived classes must implement the clone an...
Definition PlannerData.h:59
virtual const State * getState() const
Retrieve the state associated with this vertex.
Definition PlannerData.h:80
Object containing planner generated vertex and edge data. It is assumed that all vertices are unique,...
Definition PlannerData.h:175
unsigned int addStartVertex(const PlannerDataVertex &v)
Adds the given vertex to the graph data, and marks it as a start vertex. The vertex index is returned...
Definition PlannerData.cpp:405
unsigned int addGoalVertex(const PlannerDataVertex &v)
Adds the given vertex to the graph data, and marks it as a start vertex. The vertex index is returned...
Definition PlannerData.cpp:414
unsigned int numVertices() const
Retrieve the number of vertices in this structure.
Definition PlannerData.cpp:200
unsigned int getEdges(unsigned int v, std::vector< unsigned int > &edgeList) const
Returns a list of the vertex indexes directly connected to vertex with index v (outgoing edges)....
Definition PlannerData.cpp:102
const PlannerDataVertex & getVertex(unsigned int index) const
Retrieve a reference to the vertex object with the given index. If this vertex does not exist,...
Definition PlannerData.cpp:210
virtual bool addEdge(unsigned int v1, unsigned int v2, const PlannerDataEdge &edge=PlannerDataEdge(), Cost weight=Cost(1.0))
Adds a directed edge between the given vertex indexes. An optional edge structure and weight can be s...
Definition PlannerData.cpp:424
unsigned int addVertex(const PlannerDataVertex &st)
Adds the given vertex to the graph data. The vertex index is returned. Duplicates are not added....
Definition PlannerData.cpp:383
std::map< std::string, std::string > properties
Any extra properties (key-value pairs) the planner can set.
Definition PlannerData.h:410
Encapsulate a termination condition for a motion planner. Planners will call operator() to decide whe...
Definition PlannerTerminationCondition.h:64
std::size_t getStateCount() const
Get the number of states (way-points) that make up this path.
Definition PathGeometric.h:257
void interpolate(unsigned int count)
Insert a number of states in a path so that the path is made up of exactly count states....
Definition PathGeometric.cpp:348
double length() const override
Compute the length of a geometric path (sum of lengths of segments that make up the path).
Definition PathGeometric.cpp:113
base::State * getState(unsigned int index)
Get the state located at index along the path.
Definition PathGeometric.h:245
void examine_vertex(Vertex u, const Graph &g) const
Definition SPARSdb.cpp:91
CustomVisitor(Vertex goal)
Definition SPARSdb.cpp:87
edgeWeightMap(const Graph &graph, const EdgeCollisionStateMap &collisionStates)
Definition SPARSdb.cpp:60
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:1649
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:1060
void getPlannerData(base::PlannerData &data) const override
Get information about the current run of the motion planner. Repeated calls to this function will upd...
Definition SPARSdb.cpp:1716
unsigned int maxFailures_
The number of consecutive failures to add to the graph before termination.
Definition SPARSdb.h:730
double sparseDeltaFraction_
Maximum visibility range for nodes in the graph as a fraction of maximum extent.
Definition SPARSdb.h:723
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:191
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:1074
std::vector< Vertex > startVertexCandidateNeighbors_
Used by getSimilarPaths.
Definition SPARSdb.h:779
double getSparseDeltaFraction() const
Retrieve the sparse graph visibility range delta.
Definition SPARSdb.h:427
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:1125
unsigned int getNumEdges() const
Get the number of edges in the sparse roadmap.
Definition SPARSdb.h:516
unsigned int consecutiveFailures_
A counter for the number of consecutive failed iterations of the algorithm.
Definition SPARSdb.h:767
void clearQuery() override
Clear the query previously loaded from the ProblemDefinition. Subsequent calls to solve() will reuse ...
Definition SPARSdb.cpp:154
VertexPair index(Vertex vp, Vertex vpp)
Rectifies indexing order for accessing the vertex data.
Definition SPARSdb.cpp:1519
bool constructSolution(Vertex start, 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:413
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:305
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:1369
base::ValidStateSamplerPtr sampler_
Sampler user for generating valid samples in the state space.
Definition SPARSdb.h:702
void setSparseDeltaFraction(double D)
Sets vertex visibility range as a fraction of max. extent.
Definition SPARSdb.h:393
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:303
bool reachedFailureLimit() const
Returns whether we have reached the iteration failures limit, maxFailures_.
Definition SPARSdb.cpp:549
bool checkAddPath(Vertex v)
Checks vertex v for short paths through its region and adds when appropriate.
Definition SPARSdb.cpp:1168
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:759
boost::property_map< Graph, vertex_interface_data_t >::type interfaceDataProperty_
Access to the interface pair information for the vertices.
Definition SPARSdb.h:754
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:1579
boost::property_map< Graph, boost::edge_weight_t >::type edgeWeightProperty_
Access to the weights of each Edge.
Definition SPARSdb.h:742
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:696
boost::adjacency_list< boost::vecS, boost::vecS, boost::undirectedS, VertexProperties, EdgeProperties > Graph
Definition SPARSdb.h:289
EdgeCollisionStateMap edgeCollisionStateProperty_
Access to the collision checking state of each Edge.
Definition SPARSdb.h:745
long unsigned int getIterations() const
Get the number of iterations the algorithm performed.
Definition SPARSdb.h:549
double denseDeltaFraction_
Maximum range for allowing two samples to support an interface as a fraction of maximum extent.
Definition SPARSdb.h:727
boost::property_map< Graph, vertex_color_t >::type colorProperty_
Access to the colors for the vertices.
Definition SPARSdb.h:751
void computeX(Vertex v, Vertex vp, Vertex vpp, std::vector< Vertex > &Xs)
Computes all nodes which qualify as a candidate x for v, v', and v".
Definition SPARSdb.cpp:1505
void setup() override
Perform extra configuration steps, if needed. This call will also issue a call to ompl::base::SpaceIn...
Definition SPARSdb.cpp:134
void clear() override
Clear all internal datastructures. Planner settings are not affected. Subsequent calls to solve() wil...
Definition SPARSdb.cpp:161
InterfaceData & getData(Vertex v, Vertex vp, Vertex vpp)
Retrieves the Vertex data associated with v,vp,vpp.
Definition SPARSdb.cpp:1529
void printDebug(std::ostream &out=std::cout) const
Print debug information about planner.
Definition SPARSdb.cpp:554
void checkQueryStateInitialization()
Check that the query vertex is initialized (used for internal nearest neighbor searches).
Definition SPARSdb.cpp:1045
PathSimplifierPtr psimp_
A path simplifier used to simplify dense paths added to the graph.
Definition SPARSdb.h:739
void setMaxFailures(unsigned int m)
Sets the maximum failures until termination.
Definition SPARSdb.h:409
void setDenseDeltaFraction(double d)
Sets interface support tolerance as a fraction of max. extent.
Definition SPARSdb.h:401
bool lazyCollisionCheck(std::vector< Vertex > &vertexPath, const base::PlannerTerminationCondition &ptc)
Check recalled path for collision and disable as needed.
Definition SPARSdb.cpp:480
double stretchFactor_
Stretch Factor as per graph spanner literature (multiplicative bound on path quality).
Definition SPARSdb.h:720
void findGraphNeighbors(base::State *state, std::vector< Vertex > &graphNeighborhood, std::vector< Vertex > &visibleNeighborhood)
Finds visible nodes in the graph near state.
Definition SPARSdb.cpp:1272
double denseDelta_
Maximum range for allowing two samples to support an interface.
Definition SPARSdb.h:776
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:1596
unsigned int getMaxFailures() const
Retrieve the maximum consecutive failure limit.
Definition SPARSdb.h:415
std::shared_ptr< NearestNeighbors< Vertex > > nn_
Nearest neighbors data structure.
Definition SPARSdb.h:705
base::PlannerStatus solve(const base::PlannerTerminationCondition &ptc) override
Function that can solve the motion planning problem. This function can be called multiple times on th...
Definition SPARSdb.cpp:1054
unsigned int nearSamplePoints_
Number of sample points to use when trying to detect interfaces.
Definition SPARSdb.h:736
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:1534
Vertex findGraphRepresentative(base::State *st)
Finds the representative of the input state, st.
Definition SPARSdb.cpp:1341
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:544
std::pair< VertexIndexType, VertexIndexType > VertexPair
Pair of vertices which support an interface.
Definition SPARSdb.h:107
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:1496
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:1484
void clearEdgeCollisionStates()
Clear all past edge state information about in collision or not.
Definition SPARSdb.cpp:1830
double getDenseDeltaFraction() const
Retrieve the dense graph interface support delta.
Definition SPARSdb.h:421
long unsigned int iterations_
A counter for the number of iterations of the algorithm.
Definition SPARSdb.h:770
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:251
unsigned int getNumVertices() const
Get the number of vertices in the sparse roadmap.
Definition SPARSdb.h:510
boost::property_map< Graph, vertex_state_t >::type stateProperty_
Access to the internal base::state at each Vertex.
Definition SPARSdb.h:748
void setPlannerData(const base::PlannerData &data)
Set the sparse graph from file.
Definition SPARSdb.cpp:1765
GuardType
Enumeration which specifies the reason a guard is added to the spanner.
Definition SPARSdb.h:90
void connectGuards(Vertex v, Vertex vp)
Connect two guards in the roadmap.
Definition SPARSdb.cpp:1621
static NearestNeighbors< _T > * getDefaultNearestNeighbors(const base::Planner *planner)
Select a default nearest neighbor datastructure for the given space.
Definition SelfConfig.h:105
This namespace contains sampling based planning routines shared by both planning under geometric cons...
Definition ConstrainedSpaceInformation.h:55
@ GOAL_SAMPLEABLE_REGION
This bit is set if casting to sampleable goal regions (ompl::base::GoalSampleableRegion) is possible.
Definition GoalTypes.h:56
A class to store the exit status of Planner::solve().
Definition PlannerStatus.h:49
Struct for passing around partially solved solutions.
Definition SPARSdb.h:233
Interface information storage class, which does bookkeeping for criterion four.
Definition SPARSdb.h:112
double d_
Last known distance between the two interfaces supported by points_ and sigmas.
Definition SPARSdb.h:122
void clear(const base::SpaceInformationPtr &si)
Clears the given interface data.
Definition SPARSdb.h:128
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:169
base::State * pointA_
States which lie inside the visibility region of a vertex and support an interface.
Definition SPARSdb.h:114
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:154
base::State * sigmaA_
States which lie just outside the visibility region of a vertex and support an interface.
Definition SPARSdb.h:118