Robotics Library  0.7.0
Rrt.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_RRT_H
28 #define RL_PLAN_RRT_H
29 
30 #include <memory>
31 #include <boost/graph/adjacency_list.hpp>
32 
33 #include "MatrixPtr.h"
34 #include "Metric.h"
35 #include "NearestNeighbors.h"
36 #include "Planner.h"
37 #include "TransformPtr.h"
38 #include "VectorPtr.h"
39 
40 namespace rl
41 {
42  namespace plan
43  {
44  class Model;
45  class Sampler;
46  class Verifier;
47 
57  class Rrt : public Planner
58  {
59  public:
60  Rrt(const ::std::size_t& trees = 1);
61 
62  virtual ~Rrt();
63 
64  virtual ::std::string getName() const;
65 
66  NearestNeighbors* getNearestNeighbors(const ::std::size_t& i) const;
67 
68  virtual ::std::size_t getNumEdges() const;
69 
70  virtual ::std::size_t getNumVertices() const;
71 
72  virtual VectorList getPath();
73 
74  virtual void reset();
75 
76  void setNearestNeighbors(NearestNeighbors* nearestNeighbors, const ::std::size_t& i);
77 
78  virtual bool solve();
79 
82 
85 
87 
88  protected:
89  struct VertexBundle
90  {
91  ::std::size_t index;
92 
94  };
95 
96  struct TreeBundle;
97 
98  typedef ::boost::adjacency_list<
99  ::boost::listS,
100  ::boost::listS,
101  ::boost::bidirectionalS,
102  ::std::shared_ptr<VertexBundle>,
103  ::boost::no_property,
104  TreeBundle
105  > Tree;
106 
107  typedef ::boost::adjacency_list_traits<
108  ::boost::listS,
109  ::boost::listS,
110  ::boost::bidirectionalS,
111  ::boost::listS
112  >::vertex_descriptor Vertex;
113 
114  struct TreeBundle
115  {
117  };
118 
119  typedef ::boost::graph_traits<Tree>::edge_descriptor Edge;
120 
121  typedef ::boost::graph_traits<Tree>::edge_iterator EdgeIterator;
122 
123  typedef ::std::pair<EdgeIterator, EdgeIterator> EdgeIteratorPair;
124 
125  typedef ::std::pair< ::rl::math::Real, Vertex> Neighbor;
126 
127  typedef ::boost::graph_traits<Tree>::vertex_iterator VertexIterator;
128 
129  typedef ::std::pair<VertexIterator, VertexIterator> VertexIteratorPair;
130 
131  virtual Edge addEdge(const Vertex& u, const Vertex& v, Tree& tree);
132 
133  virtual Vertex addVertex(Tree& tree, const VectorPtr& q);
134 
136 
138 
139  virtual Vertex connect(Tree& tree, const Neighbor& nearest, const ::rl::math::Vector& chosen);
140 
141  virtual Vertex extend(Tree& tree, const Neighbor& nearest, const ::rl::math::Vector& chosen);
142 
143  static VertexBundle* get(const Tree& tree, const Vertex& v);
144 
145  virtual Neighbor nearest(const Tree& tree, const ::rl::math::Vector& chosen);
146 
147  ::std::vector<Vertex> begin;
148 
149  ::std::vector<Vertex> end;
150 
151  ::std::vector<Tree> tree;
152 
153  private:
154 
155  };
156  }
157 }
158 
159 #endif // RL_PLAN_RRT_H
rl::plan::Rrt::Edge
::boost::graph_traits< Tree >::edge_descriptor Edge
Definition: Rrt.h:119
rl::plan::Rrt::TreeBundle
Definition: Rrt.h:115
rl::plan::Rrt::addVertex
virtual Vertex addVertex(Tree &tree, const VectorPtr &q)
Definition: Rrt.cpp:68
NearestNeighbors.h
rl::plan::Rrt::getPath
virtual VectorList getPath()
Get solution path.
Definition: Rrt.cpp:247
rl::plan::Rrt::EdgeIteratorPair
::std::pair< EdgeIterator, EdgeIterator > EdgeIteratorPair
Definition: Rrt.h:123
rl::plan::Rrt::VertexBundle::index
::std::size_t index
Definition: Rrt.h:91
rl::plan::Rrt::getName
virtual ::std::string getName() const
Definition: Rrt.cpp:209
rl::plan::Rrt::choose
virtual ::rl::math::Vector choose()
Definition: Rrt.cpp:101
rl::plan::Rrt::connect
virtual Vertex connect(Tree &tree, const Neighbor &nearest, const ::rl::math::Vector &chosen)
Definition: Rrt.cpp:107
rl::plan::Rrt
Rapidly-Exploring Random Trees.
Definition: Rrt.h:58
rl::plan::Rrt::reset
virtual void reset()
Reset planner.
Definition: Rrt.cpp:275
rl::plan::VectorList
::std::list< ::rl::math::Vector > VectorList
Definition: VectorList.h:37
rl::plan::NearestNeighbors
Definition: NearestNeighbors.h:42
rl::math::Vector
::Eigen::Matrix< Real, ::Eigen::Dynamic, 1 > Vector
Definition: Vector.h:42
rl::plan::Rrt::delta
::rl::math::Real delta
Configuration step size.
Definition: Rrt.h:81
rl::plan::Rrt::VertexIterator
::boost::graph_traits< Tree >::vertex_iterator VertexIterator
Definition: Rrt.h:127
rl::plan::Rrt::Tree
::boost::adjacency_list< ::boost::listS, ::boost::listS, ::boost::bidirectionalS, ::std::shared_ptr< VertexBundle >, ::boost::no_property, TreeBundle > Tree
Definition: Rrt.h:96
rl::plan::Planner
Definition: Planner.h:47
Metric.h
rl::plan::Rrt::VertexBundle
Definition: Rrt.h:90
rl::plan::Rrt::tree
::std::vector< Tree > tree
Definition: Rrt.h:151
rl::plan::Rrt::Vertex
::boost::adjacency_list_traits< ::boost::listS, ::boost::listS, ::boost::bidirectionalS, ::boost::listS >::vertex_descriptor Vertex
Definition: Rrt.h:112
rl::plan::Rrt::nearest
virtual Neighbor nearest(const Tree &tree, const ::rl::math::Vector &chosen)
Definition: Rrt.cpp:265
VectorPtr.h
rl::plan::Rrt::areEqual
bool areEqual(const ::rl::math::Vector &lhs, const ::rl::math::Vector &rhs) const
Definition: Rrt.cpp:88
TransformPtr.h
rl::plan::Rrt::epsilon
::rl::math::Real epsilon
Epsilon for configuration comparison.
Definition: Rrt.h:84
rl::plan::Rrt::sampler
Sampler * sampler
Definition: Rrt.h:86
rl::plan::Rrt::get
static VertexBundle * get(const Tree &tree, const Vertex &v)
Definition: Rrt.cpp:203
rl::plan::Rrt::getNumVertices
virtual ::std::size_t getNumVertices() const
Definition: Rrt.cpp:234
rl::plan::Rrt::TreeBundle::nn
NearestNeighbors * nn
Definition: Rrt.h:116
rl::plan::Rrt::Neighbor
::std::pair< ::rl::math::Real, Vertex > Neighbor
Definition: Rrt.h:125
rl::plan::Rrt::getNumEdges
virtual ::std::size_t getNumEdges() const
Definition: Rrt.cpp:221
Planner.h
rl::plan::Rrt::getNearestNeighbors
NearestNeighbors * getNearestNeighbors(const ::std::size_t &i) const
Definition: Rrt.cpp:215
rl::plan::Rrt::extend
virtual Vertex extend(Tree &tree, const Neighbor &nearest, const ::rl::math::Vector &chosen)
Definition: Rrt.cpp:180
rl::plan::Rrt::setNearestNeighbors
void setNearestNeighbors(NearestNeighbors *nearestNeighbors, const ::std::size_t &i)
Definition: Rrt.cpp:287
rl::plan::Rrt::VertexBundle::q
VectorPtr q
Definition: Rrt.h:93
rl::plan::Sampler
Definition: Sampler.h:39
rl::plan::VectorPtr
::std::shared_ptr< ::rl::math::Vector > VectorPtr
Definition: VectorPtr.h:37
rl::plan::Rrt::end
::std::vector< Vertex > end
Definition: Rrt.h:149
rl::plan::Rrt::EdgeIterator
::boost::graph_traits< Tree >::edge_iterator EdgeIterator
Definition: Rrt.h:121
MatrixPtr.h
rl::plan::Rrt::Rrt
Rrt(const ::std::size_t &trees=1)
Definition: Rrt.cpp:39
rl::math::Real
double Real
Definition: Real.h:42
rl::plan::Rrt::addEdge
virtual Edge addEdge(const Vertex &u, const Vertex &v, Tree &tree)
Definition: Rrt.cpp:55
rl::plan::Rrt::VertexIteratorPair
::std::pair< VertexIterator, VertexIterator > VertexIteratorPair
Definition: Rrt.h:129
rl::plan::Rrt::~Rrt
virtual ~Rrt()
Definition: Rrt.cpp:50
rl::plan::Rrt::begin
::std::vector< Vertex > begin
Definition: Rrt.h:147
rl::plan::Rrt::solve
virtual bool solve()
Find collision free path.
Definition: Rrt.cpp:293
rl
Robotics Library.
Definition: AnalogInput.cpp:30