hpp-core 6.0.0
Implement basic classes for canonical path planning for kinematic chains.
Loading...
Searching...
No Matches
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
39namespace hpp {
40namespace 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
187
191 const DistancePtr_t& distance() const;
193 const path::CostPtr_t cost() const;
195 void cost(const path::CostPtr_t& cost);
198 std::ostream& print(std::ostream& os) const;
199
200 protected:
203 Roadmap(const DistancePtr_t& distance, const DevicePtr_t& robot);
204
206
211
214 virtual void push_node(const NodePtr_t& n) { nodes_.push_back(n); }
215
225 virtual void impl_addEdge(const EdgePtr_t& e);
226
230 virtual NodePtr_t createNode(ConfigurationIn_t configuration) const;
231
233 void init(RoadmapWkPtr_t weak);
234
235 private:
244 NodePtr_t addNode(ConfigurationIn_t config,
245 ConnectedComponentPtr_t connectedComponent);
246
250 void connect(const ConnectedComponentPtr_t& cc1,
251 const ConnectedComponentPtr_t& cc2);
252
256 void merge(const ConnectedComponentPtr_t& cc1,
258
259 const DistancePtr_t distance_;
260 path::CostPtr_t cost_;
261 ConnectedComponents_t connectedComponents_;
262 Nodes_t nodes_;
263 Edges_t edges_;
264 NodePtr_t initNode_;
265 NodeVector_t goalNodes_;
266 NearestNeighborPtr_t nearestNeighbor_;
267 RoadmapWkPtr_t weak_;
268
269 HPP_SERIALIZABLE();
270}; // class Roadmap
271std::ostream& operator<<(std::ostream& os, const Roadmap& r);
273} // namespace core
274} // namespace hpp
275#endif // HPP_CORE_ROADMAP_HH
std::set< RawPtr_t > RawPtrs_t
Definition connected-component.hh:46
Definition edge.hh:46
Definition node.hh:46
Definition roadmap.hh:46
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)
const Edges_t & edges() const
Definition roadmap.hh:176
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 ConnectedComponents_t & connectedComponents() const
Get list of connected component of the roadmap.
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
const NodeVector_t & goalNodes() const
Definition roadmap.hh:178
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 DistancePtr_t & distance() const
virtual void push_node(const NodePtr_t &n)
Definition roadmap.hh:214
std::ostream & print(std::ostream &os) const
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 Nodes_t & nodes() const
Definition roadmap.hh:175
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:205
static RoadmapPtr_t create(const DistancePtr_t &distance, const DevicePtr_t &robot)
Return shared pointer to new instance.
NodePtr_t addNode(ConfigurationIn_t config)
void cost(const path::CostPtr_t &cost)
Set cost used to search for optimal path.
const path::CostPtr_t cost() const
Get cost used to search for optimal path.
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
shared_ptr< Cost > CostPtr_t
Definition fwd.hh:249
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
shared_ptr< NearestNeighbor > NearestNeighborPtr_t
Definition fwd.hh:281
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