hpp-manipulation  9.0.2
Classes for manipulation planning.
graph.hh
Go to the documentation of this file.
1 // Copyright (c) 2014, LAAS-CNRS
2 // Authors: Joseph Mirabel (joseph.mirabel@laas.fr)
3 //
4 
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // 1. Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 //
12 // 2. Redistributions in binary form must reproduce the above copyright
13 // notice, this list of conditions and the following disclaimer in the
14 // documentation and/or other materials provided with the distribution.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
27 // DAMAGE.
28 
29 #ifndef HPP_MANIPULATION_GRAPH_GRAPH_HH
30 #define HPP_MANIPULATION_GRAPH_GRAPH_HH
31 
32 #include <tuple>
33 
36 #include "hpp/manipulation/fwd.hh"
39 
40 namespace hpp {
41 namespace manipulation {
43 namespace graph {
46 
62  public:
67  static GraphPtr_t create(const std::string& name, DevicePtr_t robot,
68  const ProblemPtr_t& problem);
69 
77  value_type param);
78 
79  GraphPtr_t self() const { return wkPtr_.lock(); }
80 
82  StateSelectorPtr_t createStateSelector(const std::string& name);
83 
89 
91  StateSelectorPtr_t stateSelector() const { return stateSelector_; }
92 
95 
98 
100  Edges_t getEdges(const StatePtr_t& from, const StatePtr_t& to) const;
101 
104 
108 
122  void registerConstraints(const ImplicitPtr_t& constraint,
123  const ImplicitPtr_t& complement,
124  const ImplicitPtr_t& both);
125 
137  bool isComplement(const ImplicitPtr_t& constraint,
138  const ImplicitPtr_t& complement,
139  ImplicitPtr_t& combinationOfBoth) const;
140 
146 
151 
159 
170  vector_t& error) const;
171 
179  // of the edge
184  vector_t& error) const;
185 
197  ConfigurationIn_t config,
198  const EdgePtr_t& edge, vector_t& error) const;
199 
211  ConfigurationIn_t config,
212  const EdgePtr_t& edge,
213  vector_t& error) const;
214 
219 
221  void maxIterations(size_type iterations);
222 
225 
227  void errorThreshold(const value_type& threshold);
228 
231 
233  const DevicePtr_t& robot() const;
234 
236  const ProblemPtr_t& problem() const;
237 
240 
243  hists_.push_back(hist);
244  }
245 
247  const Histograms_t& histograms() const { return hists_; }
248 
250  GraphComponentWkPtr_t get(std::size_t id) const;
251 
252  std::size_t nbComponents() const { return components_.size(); }
253 
255  virtual std::ostream& dotPrint(
256  std::ostream& os,
258 
260  virtual void initialize();
261 
263  virtual void invalidate();
264 
265  protected:
267  void init(const GraphWkPtr_t& weak, DevicePtr_t robot);
268 
271  Graph(const std::string& name, const ProblemPtr_t& problem);
272 
274  std::ostream& print(std::ostream& os) const;
275 
276  private:
278  GraphComponents_t& components();
279 
281  GraphComponents_t components_;
282 
284  StateSelectorPtr_t stateSelector_;
285 
288  ConstraintPtr_t constraints_;
289 
292 
294  GraphWkPtr_t wkPtr_;
295 
297  typedef std::map<StatePtr_t, ConstraintSetPtr_t> MapFromState;
298  typedef std::pair<StatePtr_t, ConstraintSetPtr_t> PairStateConstraints;
299  MapFromState constraintSetMapFromState_;
300 
302  Histograms_t hists_;
303 
305  typedef std::map<EdgePtr_t, ConstraintSetPtr_t> MapFromEdge;
306  typedef std::pair<EdgePtr_t, ConstraintSetPtr_t> PairEdgeConstraints;
307  MapFromEdge cfgConstraintSetMapFromEdge_, pathConstraintSetMapFromEdge_;
308  ProblemPtr_t problem_;
309  value_type errorThreshold_;
310  size_type maxIterations_;
311 
312  ConstraintsAndComplements_t constraintsAndComplements_;
313  friend class GraphComponent;
314 }; // Class Graph
315 
317 } // namespace graph
318 } // namespace manipulation
319 
320 } // namespace hpp
321 
322 BOOST_CLASS_EXPORT_KEY(hpp::manipulation::graph::Graph)
323 
324 #endif // HPP_MANIPULATION_GRAPH_GRAPH_HH
Definition: roadmap-node.hh:42
Define common methods of the graph components.
Definition: graph-component.hh:50
Definition: graph.hh:61
void stateSelector(StateSelectorPtr_t ns)
StateSelectorPtr_t createStateSelector(const std::string &name)
Create and insert a state selector inside the graph.
value_type errorThreshold() const
Get error threshold in config projector.
void errorThreshold(const value_type &threshold)
Set error threshold.
virtual void initialize()
Initialize all components of the graph (edges and states)
bool getConfigErrorForEdge(ConfigurationIn_t config, const EdgePtr_t &edge, vector_t &error) const
const DevicePtr_t & robot() const
Get the robot.
void problem(const ProblemPtr_t &problem)
Set the problem.
Edges_t getEdges(const StatePtr_t &from, const StatePtr_t &to) const
Get possible edges between two nodes.
GraphComponentWkPtr_t get(std::size_t id) const
Get the component by its ID.
const ConstraintsAndComplements_t & constraintsAndComplements() const
void insertHistogram(const graph::HistogramPtr_t &hist)
Register an histogram representing a foliation.
Definition: graph.hh:242
ConstraintSetPtr_t configConstraint(const StatePtr_t &state) const
StatePtr_t getState(RoadmapNodePtr_t node) const
Returns the state of a roadmap node.
static GraphPtr_t create(const std::string &name, DevicePtr_t robot, const ProblemPtr_t &problem)
Graph(const std::string &name, const ProblemPtr_t &problem)
void maxIterations(size_type iterations)
Set maximal number of iterations.
void registerConstraints(const ImplicitPtr_t &constraint, const ImplicitPtr_t &complement, const ImplicitPtr_t &both)
static EdgePtr_t edgeAtParam(const core::PathVectorPtr_t &path, value_type param)
size_type maxIterations() const
Get maximal number of iterations in config projector.
ConstraintSetPtr_t targetConstraint(const EdgePtr_t &edge) const
virtual void invalidate()
Invalidate all states and edges of the graph.
StateSelectorPtr_t stateSelector() const
Get the state selector.
Definition: graph.hh:91
const Histograms_t & histograms() const
Get the histograms.
Definition: graph.hh:247
bool getConfigErrorForEdgeLeaf(ConfigurationIn_t leafConfig, ConfigurationIn_t config, const EdgePtr_t &edge, vector_t &error) const
std::ostream & print(std::ostream &os) const
Print the object in a stream.
bool getConfigErrorForState(ConfigurationIn_t config, const StatePtr_t &state, vector_t &error) const
const ProblemPtr_t & problem() const
Get the problem.
std::size_t nbComponents() const
Definition: graph.hh:252
virtual std::ostream & dotPrint(std::ostream &os, dot::DrawingAttributes da=dot::DrawingAttributes()) const
Print the component in DOT language.
void init(const GraphWkPtr_t &weak, DevicePtr_t robot)
Initialization of the object.
EdgePtr_t chooseEdge(RoadmapNodePtr_t node) const
Select randomly outgoing edge of the given node.
ConstraintSetPtr_t pathConstraint(const EdgePtr_t &edge) const
bool isComplement(const ImplicitPtr_t &constraint, const ImplicitPtr_t &complement, ImplicitPtr_t &combinationOfBoth) const
StatePtr_t getState(ConfigurationIn_t config) const
Returns the state of a configuration.
bool getConfigErrorForEdgeTarget(ConfigurationIn_t leafConfig, ConfigurationIn_t config, const EdgePtr_t &edge, vector_t &error) const
#define HPP_MANIPULATION_DLLAPI
Definition: config.hh:88
std::vector< ConstraintAndComplement_t > ConstraintsAndComplements_t
Definition: constraint-set.hh:87
ProblemConstPtr_t problem() const
DevicePtr_t robot_
shared_ptr< Implicit > ImplicitPtr_t
shared_ptr< PathVector > PathVectorPtr_t
shared_ptr< Edge > EdgePtr_t
Definition: fwd.hh:49
shared_ptr< State > StatePtr_t
Definition: fwd.hh:48
std::vector< EdgePtr_t > Edges_t
Definition: fwd.hh:57
shared_ptr< StateSelector > StateSelectorPtr_t
Definition: fwd.hh:52
std::list< HistogramPtr_t > Histograms_t
Definition: fwd.hh:73
shared_ptr< Histogram > HistogramPtr_t
Definition: fwd.hh:69
std::vector< GraphComponentWkPtr_t > GraphComponents_t
Definition: fwd.hh:55
shared_ptr< Graph > GraphPtr_t
Definition: fwd.hh:47
shared_ptr< Problem > ProblemPtr_t
Definition: fwd.hh:65
shared_ptr< ConstraintSet > ConstraintSetPtr_t
Definition: fwd.hh:138
constraints::ImplicitPtr_t ImplicitPtr_t
Definition: fwd.hh:131
core::size_type size_type
Definition: fwd.hh:90
core::value_type value_type
Definition: fwd.hh:89
shared_ptr< Device > DevicePtr_t
Definition: fwd.hh:40
pinocchio::ConfigurationIn_t ConfigurationIn_t
Definition: fwd.hh:49
core::vector_t vector_t
Definition: fwd.hh:92
core::ConstraintPtr_t ConstraintPtr_t
Definition: fwd.hh:128