hpp-core  4.9.0
Implement basic classes for canonical path planning for kinematic chains.
roadmap.hh
Go to the documentation of this file.
1 //
2 // Copyright (c) 2014 CNRS
3 // Authors: Florent Lamiraux
4 //
5 // This file is part of hpp-core
6 // hpp-core is free software: you can redistribute it
7 // and/or modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation, either version
9 // 3 of the License, or (at your option) any later version.
10 //
11 // hpp-core is distributed in the hope that it will be
12 // useful, but WITHOUT ANY WARRANTY; without even the implied warranty
13 // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // General Lesser Public License for more details. You should have
15 // received a copy of the GNU Lesser General Public License along with
16 // hpp-core If not, see
17 // <http://www.gnu.org/licenses/>.
18 
19 #ifndef HPP_CORE_ROADMAP_HH
20 # define HPP_CORE_ROADMAP_HH
21 
22 # include <iostream>
23 # include <hpp/core/fwd.hh>
24 # include <hpp/core/config.hh>
25 
27 
28 namespace hpp {
29  namespace core {
32 
35  class HPP_CORE_DLLAPI Roadmap {
36  public:
38  static RoadmapPtr_t create (const DistancePtr_t& distance, const DevicePtr_t& robot);
39 
41  virtual void clear ();
42 
49  NodePtr_t addNode (const ConfigurationPtr_t& config);
50 
52  {
53  return addNode (ConfigurationPtr_t (new Configuration_t(config)));
54  }
55 
61  NodePtr_t nearestNode (const Configuration_t& configuration,
62  value_type& minDistance, bool reverse = false);
63 
64  NodePtr_t nearestNode (const ConfigurationPtr_t& configuration,
65  value_type& minDistance, bool reverse = false)
66  {
67  return nearestNode (*configuration, minDistance, reverse);
68  }
69 
76  NodePtr_t nearestNode (const Configuration_t& configuration,
77  const ConnectedComponentPtr_t& connectedComponent,
78  value_type& minDistance, bool reverse = false);
79 
80  NodePtr_t nearestNode (const ConfigurationPtr_t& configuration,
81  const ConnectedComponentPtr_t& connectedComponent,
82  value_type& minDistance, bool reverse = false)
83  {
84  return nearestNode (*configuration, connectedComponent, minDistance, reverse);
85  }
86 
92  Nodes_t nearestNodes (const Configuration_t& configuration,
93  size_type k);
94 
95  Nodes_t nearestNodes (const ConfigurationPtr_t& configuration,
96  size_type k)
97  {
98  return nearestNodes (*configuration, k);
99  }
100 
107  Nodes_t nearestNodes (const Configuration_t& configuration,
109  connectedComponent,
110  size_type k);
111 
112  Nodes_t nearestNodes (const ConfigurationPtr_t& configuration,
114  connectedComponent,
115  size_type k)
116  {
117  return nearestNodes (*configuration, connectedComponent, k);
118  }
119 
129  NodePtr_t addNodeAndEdges (const NodePtr_t from,
130  const ConfigurationPtr_t& to,
131  const PathPtr_t path);
132 
142  NodePtr_t addNodeAndEdge (const NodePtr_t from,
143  const ConfigurationPtr_t& to,
144  const PathPtr_t path);
145 
155  NodePtr_t addNodeAndEdge (const ConfigurationPtr_t& from,
156  const NodePtr_t to,
157  const PathPtr_t path);
158 
159 
161  EdgePtr_t addEdge (const NodePtr_t& n1, const NodePtr_t& n2,
162  const PathPtr_t& path);
163 
169  void addEdges (const NodePtr_t from, const NodePtr_t& to,
170  const PathPtr_t& path);
171 
176  NodePtr_t addGoalNode (const ConfigurationPtr_t& config);
177 
179  {
180  goalNodes_.clear ();
181  }
182 
183  void initNode (const ConfigurationPtr_t& config)
184  {
185  initNode_ = addNode (config);
186  }
187 
188  virtual ~Roadmap ();
190  bool pathExists () const;
191  const Nodes_t& nodes () const
192  {
193  return nodes_;
194  }
195  const Edges_t& edges () const
196  {
197  return edges_;
198  }
200  {
201  return initNode_;
202  }
203  const NodeVector_t& goalNodes () const
204  {
205  return goalNodes_;
206  }
208  const ConnectedComponents_t& connectedComponents () const;
209 
211  NearestNeighborPtr_t nearestNeighbor();
212 
214  void nearestNeighbor(NearestNeighborPtr_t nearestNeighbor);
215 
219  const DistancePtr_t& distance () const;
222  std::ostream& print (std::ostream& os) const;
223 
224  protected:
227  Roadmap (const DistancePtr_t& distance, const DevicePtr_t& robot);
228 
232  void addConnectedComponent (const NodePtr_t& node);
233 
236  virtual void push_node (const NodePtr_t& n)
237  {
238  nodes_.push_back (n);
239  }
240 
250  virtual void addEdge (const EdgePtr_t& e);
251 
255  virtual NodePtr_t createNode (const ConfigurationPtr_t& configuration) const;
256 
258  void init (RoadmapWkPtr_t weak);
259 
260  private:
269  NodePtr_t addNode (const ConfigurationPtr_t& config,
270  ConnectedComponentPtr_t connectedComponent);
271 
275  void connect (const ConnectedComponentPtr_t& cc1,
276  const ConnectedComponentPtr_t& cc2);
277 
281  void merge (const ConnectedComponentPtr_t& cc1,
283 
284  const DistancePtr_t distance_;
285  ConnectedComponents_t connectedComponents_;
286  Nodes_t nodes_;
287  Edges_t edges_;
288  NodePtr_t initNode_;
289  NodeVector_t goalNodes_;
290  NearestNeighborPtr_t nearestNeighbor_;
291  RoadmapWkPtr_t weak_;
292  }; // class Roadmap
293  std::ostream& operator<< (std::ostream& os, const Roadmap& r);
295  } // namespace core
296 } // namespace hpp
297 #endif // HPP_CORE_ROADMAP_HH
boost::shared_ptr< Path > PathPtr_t
Definition: fwd.hh:170
Vec3f n
pinocchio::DevicePtr_t DevicePtr_t
Definition: fwd.hh:114
Definition: edge.hh:34
ObjectFactory * create(ObjectFactory *parent=NULL, const XMLElement *element=NULL)
pinocchio::size_type size_type
Definition: fwd.hh:156
FCL_REAL r
virtual void push_node(const NodePtr_t &n)
Definition: roadmap.hh:236
Optimization of the nearest neighbor search.
Definition: nearest-neighbor.hh:27
boost::shared_ptr< ConnectedComponent > ConnectedComponentPtr_t
Definition: fwd.hh:107
NodePtr_t addNode(const Configuration_t &config)
Definition: roadmap.hh:51
std::set< ConnectedComponentPtr_t > ConnectedComponents_t
Definition: fwd.hh:108
Definition: node.hh:34
std::list< NodePtr_t > Nodes_t
Definition: fwd.hh:164
pinocchio::value_type value_type
Definition: fwd.hh:157
std::set< RawPtr_t > RawPtrs_t
Definition: connected-component.hh:34
Nodes_t nearestNodes(const ConfigurationPtr_t &configuration, size_type k)
Definition: roadmap.hh:95
const Nodes_t & nodes() const
Definition: roadmap.hh:191
Nodes_t nearestNodes(const ConfigurationPtr_t &configuration, const ConnectedComponentPtr_t &connectedComponent, size_type k)
Definition: roadmap.hh:112
pinocchio::ConfigurationPtr_t ConfigurationPtr_t
Definition: fwd.hh:99
std::vector< NodePtr_t > NodeVector_t
Definition: fwd.hh:165
std::list< Edge * > Edges_t
Definition: fwd.hh:127
boost::shared_ptr< Roadmap > RoadmapPtr_t
Definition: fwd.hh:181
void initNode(const ConfigurationPtr_t &config)
Definition: roadmap.hh:183
void resetGoalNodes()
Definition: roadmap.hh:178
boost::shared_ptr< Distance > DistancePtr_t
Definition: fwd.hh:122
NodePtr_t nearestNode(const ConfigurationPtr_t &configuration, const ConnectedComponentPtr_t &connectedComponent, value_type &minDistance, bool reverse=false)
Definition: roadmap.hh:80
NodePtr_t nearestNode(const ConfigurationPtr_t &configuration, value_type &minDistance, bool reverse=false)
Definition: roadmap.hh:64
const Edges_t & edges() const
Definition: roadmap.hh:195
std::ostream & operator<<(std::ostream &os, const Constraint &constraint)
Definition: constraint.hh:98
pinocchio::Configuration_t Configuration_t
Definition: fwd.hh:96
const NodeVector_t & goalNodes() const
Definition: roadmap.hh:203
Definition: roadmap.hh:35
NodePtr_t initNode() const
Definition: roadmap.hh:199
FCL_REAL distance(const KDOP< N > &other, Vec3f *P=NULL, Vec3f *Q=NULL) const