37 #ifndef OMPL_BASE_PLANNER_DATA_
38 #define OMPL_BASE_PLANNER_DATA_
44 #include "ompl/base/State.h"
45 #include "ompl/base/Cost.h"
46 #include "ompl/base/SpaceInformation.h"
47 #include "ompl/util/ClassForward.h"
48 #include <boost/noncopyable.hpp>
49 #include <boost/function.hpp>
50 #include <boost/serialization/access.hpp>
93 return !(*
this == rhs);
99 friend class boost::serialization::access;
100 template <
class Archive>
101 void serialize(Archive & ar,
const unsigned int )
135 return !(*
this == rhs);
140 friend class boost::serialization::access;
141 template <
class Archive>
142 void serialize(Archive & ,
const unsigned int )
148 OMPL_CLASS_FORWARD(StateStorage);
149 OMPL_CLASS_FORWARD(PlannerData);
152 class OptimizationObjective;
159 class PlannerData : boost::noncopyable
218 virtual bool addEdge (
unsigned int v1,
unsigned int v2,
229 virtual bool removeEdge (
unsigned int v1,
unsigned int v2);
234 virtual void clear (
void);
303 bool edgeExists (
unsigned int v1,
unsigned int v2)
const;
313 unsigned int getEdges (
unsigned int v, std::vector<unsigned int>& edgeList)
const;
316 unsigned int getEdges (
unsigned int v, std::map<unsigned int, const PlannerDataEdge*> &edgeMap)
const;
319 unsigned int getIncomingEdges (
unsigned int v, std::vector<unsigned int>& edgeList)
const;
323 unsigned int getIncomingEdges (
unsigned int v, std::map<unsigned int, const PlannerDataEdge*> &edgeMap)
const;
349 void printGraphML (std::ostream& out = std::cout)
const;
411 void freeMemory(
void);
const State * state_
The state represented by this vertex.
Object that handles loading/storing a PlannerData object to/from a binary stream. Serialization of ve...
unsigned int numVertices(void) const
Retrieve the number of vertices in this structure.
SpaceInformationPtr si_
The space information instance for this data.
virtual PlannerDataVertex * clone(void) const
Return a clone of this object, allocated from the heap.
Object containing planner generated vertex and edge data. It is assumed that all vertices are unique...
void computeEdgeWeights()
Computes all edge weights using state space distance (i.e. getSpaceInformation()->distance()) ...
virtual ~PlannerData(void)
Destructor.
Wrapper class for the Boost.Graph representation of the PlannerData. This class inherits from a boost...
unsigned int numStartVertices(void) const
Returns the number of start vertices.
std::vector< unsigned int > startVertexIndices_
A mutable listing of the vertices marked as start states. Stored in sorted order. ...
int tag_
A generic integer tag for this state. Not used for equivalence checking.
virtual int getTag(void) const
Returns the integer tag associated with this vertex.
bool vertexExists(const PlannerDataVertex &v) const
Check whether a vertex exists with the given vertex data.
PlannerDataVertex(const State *st, int tag=0)
Constructor. Takes a state pointer and an optional integer tag.
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...
unsigned int numGoalVertices(void) const
Returns the number of goal vertices.
void extractReachable(unsigned int v, PlannerData &data) const
Extracts the subset of PlannerData reachable from the vertex with index v. For tree structures...
bool markStartState(const State *st)
Mark the given state as a start vertex. If the given state does not exist in a vertex, false is returned.
unsigned int addVertex(const PlannerDataVertex &st)
Adds the given vertex to the graph data. The vertex index is returned. Duplicates are not added...
const PlannerDataVertex & getStartVertex(unsigned int i) const
Retrieve a reference to the ith start vertex object. If i is greater than the number of start vertice...
std::vector< unsigned int > goalVertexIndices_
A mutable listing of the vertices marked as goal states. Stored in sorted order.
unsigned int getStartIndex(unsigned int i) const
Returns the index of the ith start state. INVALID_INDEX is returned if i is out of range...
bool getEdgeWeight(unsigned int v1, unsigned int v2, Cost *weight) const
Returns the weight of the edge between the given vertex indices. If there exists an edge between v1 a...
unsigned int getIncomingEdges(unsigned int v, std::vector< unsigned int > &edgeList) const
Returns a list of vertices with outgoing edges to the vertex with index v. The number of edges connec...
PlannerData(const SpaceInformationPtr &si)
Constructor. Accepts a SpaceInformationPtr for the space planned in.
bool setEdgeWeight(unsigned int v1, unsigned int v2, Cost weight)
Sets the weight of the edge between the given vertex indices. If an edge between v1 and v2 does not e...
StateStoragePtr extractStateStorage(void) const
Extract a ompl::base::GraphStateStorage object from this PlannerData. Memory for states is copied (th...
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)...
std::set< State * > decoupledStates_
A list of states that are allocated during the decoupleFromPlanner method. These states are freed by ...
Base class for a vertex in the PlannerData structure. All derived classes must implement the clone an...
virtual const State * getState(void) const
Retrieve the state associated with this vertex.
virtual bool removeVertex(const PlannerDataVertex &st)
Removes the vertex associated with the given data. If the vertex does not exist, false is returned...
Definition of a cost value. Can represent the cost of a motion or the cost of a state.
bool isGoalVertex(unsigned int index) const
Returns true if the given vertex index is marked as a goal vertex.
const PlannerDataVertex & getGoalVertex(unsigned int i) const
Retrieve a reference to the ith goal vertex object. If i is greater than the number of goal vertices...
bool tagState(const State *st, int tag)
Set the integer tag associated with the given state. If the given state does not exist in a vertex...
bool operator!=(const PlannerDataVertex &rhs) const
Returns true if this vertex is not equal to the argument. This is the complement of the == operator...
void printGraphML(std::ostream &out=std::cout) const
Writes a GraphML file of this structure to the given stream.
unsigned int vertexIndex(const PlannerDataVertex &v) const
Return the index for the vertex associated with the given data. INVALID_INDEX is returned if this ver...
Graph & toBoostGraph(void)
Extract a Boost.Graph object from this PlannerData.
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...
PlannerDataVertex(const PlannerDataVertex &rhs)
Copy constructor.
const PlannerDataVertex & getVertex(unsigned int index) const
Retrieve a reference to the vertex object with the given index. If this vertex does not exist...
void printGraphviz(std::ostream &out=std::cout) const
Writes a Graphviz dot file of this structure to the given stream.
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 of an abstract state.
virtual PlannerDataEdge * clone() const
Return a clone of this object, allocated from the heap.
static const PlannerDataVertex NO_VERTEX
Representation for a non-existant vertex.
Abstract definition of optimization objectives.
bool edgeExists(unsigned int v1, unsigned int v2) const
Check whether an edge between vertex index v1 and index v2 exists.
const SpaceInformationPtr & getSpaceInformation(void) const
Return the instance of SpaceInformation used in this PlannerData.
static const unsigned int INVALID_INDEX
Representation of an invalid vertex index.
const PlannerDataEdge & getEdge(unsigned int v1, unsigned int v2) const
Retrieve a reference to the edge object connecting vertices with indexes v1 and v2. If this edge does not exist, NO_EDGE is returned.
bool markGoalState(const State *st)
Mark the given state as a goal vertex. If the given state does not exist in a vertex, false is returned.
virtual bool hasControls(void) const
Indicate whether any information about controls (ompl::control::Control) is stored in this instance...
bool isStartVertex(unsigned int index) const
Returns true if the given vertex index is marked as a start vertex.
virtual void setTag(int tag)
Set the integer tag associated with this vertex.
virtual void clear(void)
Clears the entire data structure.
void extractMinimumSpanningTree(unsigned int v, const OptimizationObjective &opt, PlannerData &mst) const
Extracts the minimum spanning tree of the data rooted at the vertex with index v. The minimum spannin...
Base class for a PlannerData edge.
std::map< const State *, unsigned int > stateIndexMap_
A mapping of states to vertex indexes. For fast lookup of vertex index.
virtual bool operator==(const PlannerDataEdge &rhs) const
Returns true if the edges point to the same memory.
virtual void decoupleFromPlanner(void)
Creates a deep copy of the states contained in the vertices of this PlannerData structure so that whe...
unsigned int getGoalIndex(unsigned int i) const
Returns the index of the ith goal state. INVALID_INDEX is returned if i is out of range Indexes are v...
virtual bool removeEdge(unsigned int v1, unsigned int v2)
Removes the edge between vertex indexes v1 and v2. Success is returned.
virtual bool operator==(const PlannerDataVertex &rhs) const
Equivalence operator. Return true if the state pointers are equal.
unsigned int numEdges(void) const
Retrieve the number of edges in this structure.
static const PlannerDataEdge NO_EDGE
Representation for a non-existant edge.
std::map< std::string, std::string > properties
Any extra properties (key-value pairs) the planner can set.
bool operator!=(const PlannerDataEdge &rhs) const
Returns true if the edges do not point to the same memory. This is the complement of the == operator...