Robotics Library  0.7.0
Prm.h
Go to the documentation of this file.
1 //
2 // Copyright (c) 2009, Markus Rickert
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are met:
7 //
8 // * Redistributions of source code must retain the above copyright notice,
9 // this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright notice,
11 // this list of conditions and the following disclaimer in the documentation
12 // and/or other materials provided with the distribution.
13 //
14 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
18 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24 // POSSIBILITY OF SUCH DAMAGE.
25 //
26 
27 #ifndef RL_PLAN_PRM_H
28 #define RL_PLAN_PRM_H
29 
30 #include <queue>
31 #include <boost/graph/adjacency_list.hpp>
32 #include <boost/pending/disjoint_sets.hpp>
33 
34 #include "Metric.h"
35 #include "NearestNeighbors.h"
36 #include "Planner.h"
37 #include "VectorPtr.h"
38 
39 namespace rl
40 {
41  namespace plan
42  {
43  class Model;
44  class Sampler;
45  class Verifier;
46 
64  class Prm : public Planner
65  {
66  public:
67  Prm();
68 
69  virtual ~Prm();
70 
71  virtual void construct(const ::std::size_t& steps);
72 
73  virtual ::std::string getName() const;
74 
76 
77  ::std::size_t getNumEdges() const;
78 
79  ::std::size_t getNumVertices() const;
80 
82 
83  void reset();
84 
85  void setNearestNeighbors(NearestNeighbors* nearestNeighbors);
86 
87  bool solve();
88 
90  ::std::size_t degree;
91 
93  ::std::size_t k;
94 
97 
99 
101 
102  protected:
103  struct EdgeBundle
104  {
106  };
107 
108  struct GraphBundle;
109 
110  typedef ::boost::adjacency_list_traits<
111  ::boost::listS,
112  ::boost::listS,
113  ::boost::undirectedS,
114  ::boost::listS
115  >::vertex_descriptor Vertex;
116 
118  {
120 
121  ::std::size_t index;
122 
124 
126 
128 
129  ::std::size_t rank;
130  };
131 
132  typedef ::boost::adjacency_list<
133  ::boost::listS,
134  ::boost::listS,
135  ::boost::undirectedS,
136  VertexBundle,
137  EdgeBundle,
139  > Graph;
140 
141  struct GraphBundle
142  {
144  };
145 
146  typedef ::boost::graph_traits<Graph>::edge_descriptor Edge;
147 
148  typedef ::boost::graph_traits<Graph>::edge_iterator EdgeIterator;
149 
150  typedef ::std::pair<EdgeIterator, EdgeIterator> EdgeIteratorPair;
151 
153 
154  typedef ::boost::graph_traits<Graph>::vertex_iterator VertexIterator;
155 
156  typedef ::std::pair<VertexIterator, VertexIterator> VertexIteratorPair;
157 
158  typedef ::boost::property_map<Graph, void* VertexBundle::*>::type VertexParentMap;
159 
160  typedef ::boost::property_map<Graph, ::std::size_t VertexBundle::*>::type VertexRankMap;
161 
162  Edge addEdge(const Vertex& u, const Vertex& v, const ::rl::math::Real& weight);
163 
164  Vertex addVertex(const VectorPtr& q);
165 
166  void insert(const Vertex& vertex);
167 
169 
170  ::boost::disjoint_sets<VertexRankMap, VertexParentMap> ds;
171 
173 
175 
176  private:
177 
178  };
179  }
180 }
181 
182 #endif // RL_PLAN_PRM_H
rl::plan::Prm::getNearestNeighbors
NearestNeighbors * getNearestNeighbors() const
Definition: Prm.cpp:126
rl::plan::Prm::radius
::rl::math::Real radius
Maximum radius for connecting neighbors.
Definition: Prm.h:96
rl::plan::Prm::EdgeIterator
::boost::graph_traits< Graph >::edge_iterator EdgeIterator
Definition: Prm.h:148
rl::plan::Prm::getPath
VectorList getPath()
Get solution path.
Definition: Prm.cpp:144
NearestNeighbors.h
rl::plan::Prm::GraphBundle::nn
NearestNeighbors * nn
Definition: Prm.h:143
rl::plan::Prm::VertexBundle::parent
Vertex parent
Definition: Prm.h:123
rl::plan::Verifier
Definition: Verifier.h:39
rl::plan::Prm::sampler
Sampler * sampler
Definition: Prm.h:98
rl::plan::Prm::EdgeIteratorPair
::std::pair< EdgeIterator, EdgeIterator > EdgeIteratorPair
Definition: Prm.h:150
rl::plan::Prm::setNearestNeighbors
void setNearestNeighbors(NearestNeighbors *nearestNeighbors)
Definition: Prm.cpp:200
rl::plan::Prm::getName
virtual ::std::string getName() const
Definition: Prm.cpp:108
rl::plan::NearestNeighbors::Neighbor
::std::pair< Distance, Value > Neighbor
Definition: NearestNeighbors.h:48
rl::plan::Prm::VertexBundle::rank
::std::size_t rank
Definition: Prm.h:129
rl::plan::VectorList
::std::list< ::rl::math::Vector > VectorList
Definition: VectorList.h:37
rl::plan::Prm::degree
::std::size_t degree
Maximum degree per vertex.
Definition: Prm.h:90
rl::plan::Prm::EdgeBundle
Definition: Prm.h:104
rl::plan::NearestNeighbors
Definition: NearestNeighbors.h:42
rl::plan::Prm::verifier
Verifier * verifier
Definition: Prm.h:100
rl::plan::Prm::VertexRankMap
::boost::property_map< Graph, ::std::size_t VertexBundle::* >::type VertexRankMap
Definition: Prm.h:160
rl::plan::Planner
Definition: Planner.h:47
rl::plan::Prm::k
::std::size_t k
Maximum number of tested neighbors.
Definition: Prm.h:93
Metric.h
rl::plan::Prm::Graph
::boost::adjacency_list< ::boost::listS, ::boost::listS, ::boost::undirectedS, VertexBundle, EdgeBundle, GraphBundle > Graph
Definition: Prm.h:139
rl::plan::Prm::addVertex
Vertex addVertex(const VectorPtr &q)
Definition: Prm.cpp:80
rl::plan::Prm::EdgeBundle::weight
::rl::math::Real weight
Definition: Prm.h:105
rl::plan::Prm::Edge
::boost::graph_traits< Graph >::edge_descriptor Edge
Definition: Prm.h:146
rl::plan::Prm::VertexIteratorPair
::std::pair< VertexIterator, VertexIterator > VertexIteratorPair
Definition: Prm.h:156
rl::plan::Prm::GraphBundle
Definition: Prm.h:142
rl::plan::Prm::construct
virtual void construct(const ::std::size_t &steps)
Definition: Prm.cpp:96
rl::plan::Prm::graph
Graph graph
Definition: Prm.h:174
rl::plan::Prm::Prm
Prm()
Definition: Prm.cpp:42
rl::plan::Prm::VertexBundle::q
VectorPtr q
Definition: Prm.h:127
VectorPtr.h
rl::plan::Prm::insert
void insert(const Vertex &vertex)
Definition: Prm.cpp:162
rl::plan::Prm::reset
void reset()
Reset planner.
Definition: Prm.cpp:191
rl::plan::Prm::VertexBundle::distance
::rl::math::Real distance
Definition: Prm.h:119
rl::plan::Prm::VertexBundle::predecessor
Vertex predecessor
Definition: Prm.h:125
Planner.h
rl::plan::Prm::ds
::boost::disjoint_sets< VertexRankMap, VertexParentMap > ds
Definition: Prm.h:170
rl::plan::Prm
Probabilistic Roadmaps.
Definition: Prm.h:65
rl::plan::Prm::getNumEdges
::std::size_t getNumEdges() const
Definition: Prm.cpp:132
rl::plan::Prm::Vertex
::boost::adjacency_list_traits< ::boost::listS, ::boost::listS, ::boost::undirectedS, ::boost::listS >::vertex_descriptor Vertex
Definition: Prm.h:108
rl::plan::Prm::VertexBundle
Definition: Prm.h:118
rl::plan::Sampler
Definition: Sampler.h:39
rl::plan::Prm::VertexBundle::index
::std::size_t index
Definition: Prm.h:121
rl::plan::Prm::end
Vertex end
Definition: Prm.h:172
rl::plan::Prm::solve
bool solve()
Find collision free path.
Definition: Prm.cpp:206
rl::plan::Prm::VertexParentMap
::boost::property_map< Graph, void *VertexBundle::* >::type VertexParentMap
Definition: Prm.h:158
rl::plan::VectorPtr
::std::shared_ptr< ::rl::math::Vector > VectorPtr
Definition: VectorPtr.h:37
rl::plan::Prm::begin
Vertex begin
Definition: Prm.h:168
rl::plan::Prm::VertexIterator
::boost::graph_traits< Graph >::vertex_iterator VertexIterator
Definition: Prm.h:154
rl::plan::Prm::Neighbor
NearestNeighbors::Neighbor Neighbor
Definition: Prm.h:152
rl::plan::Prm::addEdge
Edge addEdge(const Vertex &u, const Vertex &v, const ::rl::math::Real &weight)
Definition: Prm.cpp:64
rl::math::Real
double Real
Definition: Real.h:42
rl::plan::Prm::getNumVertices
::std::size_t getNumVertices() const
Definition: Prm.cpp:138
rl::plan::Prm::~Prm
virtual ~Prm()
Definition: Prm.cpp:59
rl
Robotics Library.
Definition: AnalogInput.cpp:30