hpp-core  6.0.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 
6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions are
8 // met:
9 //
10 // 1. Redistributions of source code must retain the above copyright
11 // notice, this list of conditions and the following disclaimer.
12 //
13 // 2. Redistributions in binary form must reproduce the above copyright
14 // notice, this list of conditions and the following disclaimer in the
15 // documentation and/or other materials provided with the distribution.
16 //
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 // HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
28 // DAMAGE.
29 
30 #ifndef HPP_CORE_ROADMAP_HH
31 #define HPP_CORE_ROADMAP_HH
32 
33 #include <hpp/core/config.hh>
35 #include <hpp/core/fwd.hh>
36 #include <hpp/util/serialization-fwd.hh>
37 #include <iostream>
38 
39 namespace hpp {
40 namespace core {
43 
47  public:
49  static RoadmapPtr_t create(const DistancePtr_t& distance,
50  const DevicePtr_t& robot);
51 
53  virtual void clear();
54 
62 
69  value_type& minDistance, bool reverse = false);
70 
78  const ConnectedComponentPtr_t& connectedComponent,
79  value_type& minDistance, bool reverse = false);
80 
87 
95  const ConnectedComponentPtr_t& connectedComponent,
96  size_type k);
97 
101  ConfigurationIn_t configuration,
102  const ConnectedComponentPtr_t& connectedComponent,
103  value_type maxDistance);
104 
115  const PathPtr_t path);
116 
127  const PathPtr_t path);
128 
139  const PathPtr_t path);
140 
142  EdgePtr_t addEdge(const NodePtr_t& n1, const NodePtr_t& n2,
143  const PathPtr_t& path);
144 
150  void addEdges(const NodePtr_t from, const NodePtr_t& to,
151  const PathPtr_t& path);
152 
154  void merge(const RoadmapPtr_t& other);
155 
160  void insertPathVector(const PathVectorPtr_t& path, bool backAndForth);
161 
167 
168  void resetGoalNodes() { goalNodes_.clear(); }
169 
170  void initNode(ConfigurationIn_t config) { initNode_ = addNode(config); }
171 
172  virtual ~Roadmap();
174  bool pathExists() const;
175  const Nodes_t& nodes() const { return nodes_; }
176  const Edges_t& edges() const { return edges_; }
177  NodePtr_t initNode() const { return initNode_; }
178  const NodeVector_t& goalNodes() const { return goalNodes_; }
181 
184 
186  void nearestNeighbor(NearestNeighborPtr_t nearestNeighbor);
187 
191  const DistancePtr_t& distance() const;
194  std::ostream& print(std::ostream& os) const;
195 
196  protected:
199  Roadmap(const DistancePtr_t& distance, const DevicePtr_t& robot);
200 
201  Roadmap() {};
202 
206  void addConnectedComponent(const NodePtr_t& node);
207 
210  virtual void push_node(const NodePtr_t& n) { nodes_.push_back(n); }
211 
221  virtual void impl_addEdge(const EdgePtr_t& e);
222 
226  virtual NodePtr_t createNode(ConfigurationIn_t configuration) const;
227 
229  void init(RoadmapWkPtr_t weak);
230 
231  private:
240  NodePtr_t addNode(ConfigurationIn_t config,
241  ConnectedComponentPtr_t connectedComponent);
242 
246  void connect(const ConnectedComponentPtr_t& cc1,
247  const ConnectedComponentPtr_t& cc2);
248 
252  void merge(const ConnectedComponentPtr_t& cc1,
254 
255  const DistancePtr_t distance_;
256  ConnectedComponents_t connectedComponents_;
257  Nodes_t nodes_;
258  Edges_t edges_;
259  NodePtr_t initNode_;
260  NodeVector_t goalNodes_;
261  NearestNeighborPtr_t nearestNeighbor_;
262  RoadmapWkPtr_t weak_;
263 
264  HPP_SERIALIZABLE();
265 }; // class Roadmap
266 std::ostream& operator<<(std::ostream& os, const Roadmap& r);
268 } // namespace core
269 } // namespace hpp
270 #endif // HPP_CORE_ROADMAP_HH
std::set< RawPtr_t > RawPtrs_t
Definition: connected-component.hh:46
Definition: edge.hh:46
Optimization of the nearest neighbor search.
Definition: nearest-neighbor.hh:39
Definition: node.hh:46
Definition: roadmap.hh:46
std::ostream & print(std::ostream &os) const
NodePtr_t nearestNode(ConfigurationIn_t configuration, const ConnectedComponentPtr_t &connectedComponent, value_type &minDistance, bool reverse=false)
Nodes_t nearestNodes(ConfigurationIn_t configuration, size_type k)
void insertPathVector(const PathVectorPtr_t &path, bool backAndForth)
NodePtr_t initNode() const
Definition: roadmap.hh:177
virtual NodePtr_t createNode(ConfigurationIn_t configuration) const
Nodes_t nearestNodes(ConfigurationIn_t configuration, const ConnectedComponentPtr_t &connectedComponent, size_type k)
NodePtr_t addGoalNode(ConfigurationIn_t config)
void init(RoadmapWkPtr_t weak)
Store weak pointer to itself.
bool pathExists() const
Check that a path exists between the initial node and one goal node.
void addEdges(const NodePtr_t from, const NodePtr_t &to, const PathPtr_t &path)
EdgePtr_t addEdge(const NodePtr_t &n1, const NodePtr_t &n2, const PathPtr_t &path)
Add an edge between two nodes.
const Nodes_t & nodes() const
Definition: roadmap.hh:175
NodeVector_t nodesWithinBall(ConfigurationIn_t configuration, const ConnectedComponentPtr_t &connectedComponent, value_type maxDistance)
void addConnectedComponent(const NodePtr_t &node)
void initNode(ConfigurationIn_t config)
Definition: roadmap.hh:170
void resetGoalNodes()
Definition: roadmap.hh:168
NodePtr_t addNodeAndEdge(const NodePtr_t from, ConfigurationIn_t to, const PathPtr_t path)
NodePtr_t addNodeAndEdges(const NodePtr_t from, ConfigurationIn_t to, const PathPtr_t path)
const ConnectedComponents_t & connectedComponents() const
Get list of connected component of the roadmap.
virtual void push_node(const NodePtr_t &n)
Definition: roadmap.hh:210
virtual void impl_addEdge(const EdgePtr_t &e)
void merge(const RoadmapPtr_t &other)
Add the nodes and edges of a roadmap into this one.
NodePtr_t addNodeAndEdge(ConfigurationIn_t from, const NodePtr_t to, const PathPtr_t path)
NearestNeighborPtr_t nearestNeighbor()
Get nearestNeighbor object.
const Edges_t & edges() const
Definition: roadmap.hh:176
const NodeVector_t & goalNodes() const
Definition: roadmap.hh:178
void nearestNeighbor(NearestNeighborPtr_t nearestNeighbor)
Set new NearestNeighbor (roadmap must be empty)
virtual void clear()
Clear the roadmap by deleting nodes and edges.
Roadmap()
Definition: roadmap.hh:201
static RoadmapPtr_t create(const DistancePtr_t &distance, const DevicePtr_t &robot)
Return shared pointer to new instance.
NodePtr_t addNode(ConfigurationIn_t config)
const DistancePtr_t & distance() const
NodePtr_t nearestNode(ConfigurationIn_t configuration, value_type &minDistance, bool reverse=false)
Roadmap(const DistancePtr_t &distance, const DevicePtr_t &robot)
#define HPP_CORE_DLLAPI
Definition: config.hh:88
std::ostream & operator<<(std::ostream &os, const Constraint &constraint)
Definition: constraint.hh:99
pinocchio::value_type value_type
Definition: fwd.hh:174
shared_ptr< PathVector > PathVectorPtr_t
Definition: fwd.hh:193
shared_ptr< Distance > DistancePtr_t
Definition: fwd.hh:141
std::vector< NodePtr_t > NodeVector_t
Definition: fwd.hh:182
std::set< ConnectedComponentPtr_t, SharedComparator > ConnectedComponents_t
Definition: fwd.hh:127
std::list< Edge * > Edges_t
Definition: fwd.hh:145
shared_ptr< Roadmap > RoadmapPtr_t
Definition: fwd.hh:199
pinocchio::ConfigurationIn_t ConfigurationIn_t
Definition: fwd.hh:108
pinocchio::size_type size_type
Definition: fwd.hh:173
std::list< NodePtr_t > Nodes_t
Definition: fwd.hh:181
shared_ptr< ConnectedComponent > ConnectedComponentPtr_t
Definition: fwd.hh:117
pinocchio::DevicePtr_t DevicePtr_t
Definition: fwd.hh:134
shared_ptr< Path > PathPtr_t
Definition: fwd.hh:187
Definition: bi-rrt-planner.hh:35