hpp-manipulation  4.9.0
Classes for manipulation planning.
edge.hh
Go to the documentation of this file.
1 // Copyright (c) 2014, LAAS-CNRS
2 // Authors: Joseph Mirabel (joseph.mirabel@laas.fr)
3 //
4 // This file is part of hpp-manipulation.
5 // hpp-manipulation is free software: you can redistribute it
6 // and/or modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation, either version
8 // 3 of the License, or (at your option) any later version.
9 //
10 // hpp-manipulation is distributed in the hope that it will be
11 // useful, but WITHOUT ANY WARRANTY; without even the implied warranty
12 // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Lesser Public License for more details. You should have
14 // received a copy of the GNU Lesser General Public License along with
15 // hpp-manipulation. If not, see <http://www.gnu.org/licenses/>.
16 
17 #ifndef HPP_MANIPULATION_GRAPH_EDGE_HH
18 # define HPP_MANIPULATION_GRAPH_EDGE_HH
19 
20 #include <hpp/core/constraint-set.hh>
21 #include <hpp/core/steering-method.hh>
22 #include <hpp/core/relative-motion.hh>
23 #include <hpp/core/path.hh>
24 
25 #include "hpp/manipulation/config.hh"
26 #include "hpp/manipulation/fwd.hh"
28 
29 namespace hpp {
30  namespace manipulation {
31  namespace graph {
34 
38 
59  class HPP_MANIPULATION_DLLAPI Edge : public GraphComponent
60  {
61  public:
63 
65  virtual ~Edge ();
66 
68  static EdgePtr_t create
69  (const std::string& name,
70  const GraphWkPtr_t& graph,
71  const StateWkPtr_t& from,
72  const StateWkPtr_t& to);
73 
83  virtual bool applyConstraints (core::NodePtr_t nStart,
84  ConfigurationOut_t q) const
86 
96  virtual bool applyConstraints (ConfigurationIn_t qStart,
97  ConfigurationOut_t q) const
99 
108  virtual bool generateTargetConfig(core::NodePtr_t nStart,
109  ConfigurationOut_t q) const;
110 
119  virtual bool generateTargetConfig (ConfigurationIn_t qStart,
120  ConfigurationOut_t q) const;
121 
122  virtual bool canConnect (ConfigurationIn_t q1, ConfigurationIn_t q2) const;
123 
124  virtual bool build (core::PathPtr_t& path, ConfigurationIn_t q1,
125  ConfigurationIn_t q2) const;
126 
128  StatePtr_t stateTo () const;
129 
131  StatePtr_t stateFrom () const;
132 
134  StatePtr_t state () const
135  {
136  return state_.lock();
137  }
138 
139  void state (StatePtr_t state)
140  {
141  state_ = state;
142  }
143 
146  {
147  return steeringMethod_;
148  }
149 
152  {
153  return pathValidation_;
154  }
155 
157  {
158  return relMotion_;
159  }
160 
162  void relativeMotion(const RelativeMotion::matrix_type & m);
163 
172  void securityMarginForPair(const size_type& row, const size_type& col,
173  const value_type& margin);
174 
176  const matrix_t& securityMargins() const
177  {
178  return securityMargins_;
179  }
180 
183  virtual bool direction (const core::PathPtr_t& path) const;
184 
187  virtual bool intersectionConstraint (const EdgePtr_t& other,
188  ConfigProjectorPtr_t projector) const;
189 
191  virtual std::ostream& dotPrint (std::ostream& os, dot::DrawingAttributes da = dot::DrawingAttributes ()) const;
192 
195  ConstraintSetPtr_t configConstraint() const
197 
199  ConstraintSetPtr_t targetConstraint() const;
200 
201  void setShort (bool isShort) {
202  isShort_ = isShort;
203  }
204 
205  bool isShort () const {
206  return isShort_;
207  }
210  ConstraintSetPtr_t pathConstraint() const;
211 
212  protected:
214  void init (const EdgeWkPtr_t& weak, const GraphWkPtr_t& graph, const StateWkPtr_t& from,
215  const StateWkPtr_t& to);
216 
218  Edge (const std::string& name);
219 
220  virtual ConstraintSetPtr_t buildConfigConstraint()
222 
224  virtual ConstraintSetPtr_t buildTargetConstraint();
225 
227  virtual ConstraintSetPtr_t buildPathConstraint();
228 
229  virtual void initialize ();
230 
232  virtual std::ostream& print (std::ostream& os) const;
233 
234  bool isShort_;
235 
236  private:
238  ConstraintSetPtr_t pathConstraints_;
239 
242  ConstraintSetPtr_t targetConstraints_;
243 
245  StateWkPtr_t from_, to_;
246 
248  StateWkPtr_t state_;
249 
252 
254  mutable RelativeMotion::matrix_type relMotion_;
256  matrix_t securityMargins_;
257 
258  core::PathValidationPtr_t pathValidation_;
259 
261  EdgeWkPtr_t wkPtr_;
262 
263  friend class Graph;
264  }; // class Edge
265 
300  class HPP_MANIPULATION_DLLAPI WaypointEdge : public Edge
301  {
302  public:
305  (const std::string& name,
306  const GraphWkPtr_t& graph, const StateWkPtr_t& from,
307  const StateWkPtr_t& to);
308 
309  virtual bool canConnect (ConfigurationIn_t q1, ConfigurationIn_t q2) const;
310 
311  virtual bool build (core::PathPtr_t& path, ConfigurationIn_t q1, ConfigurationIn_t q2) const;
312 
313 
323  virtual bool applyConstraints (ConfigurationIn_t qStart,
324  ConfigurationOut_t q) const
326 
335  virtual bool generateTargetConfig (ConfigurationIn_t qStart,
336  ConfigurationOut_t q) const;
337 
339  const EdgePtr_t& waypoint (const std::size_t index) const;
340 
342  virtual std::ostream& dotPrint (std::ostream& os, dot::DrawingAttributes da = dot::DrawingAttributes ()) const;
343 
345  void nbWaypoints (const size_type number);
346 
347  std::size_t nbWaypoints () const
348  {
349  return edges_.size () - 1;
350  }
351 
354  void setWaypoint (const std::size_t index, const EdgePtr_t wEdge, const StatePtr_t wTo);
355 
356  protected:
357  WaypointEdge (const std::string& name) :
358  Edge (name),
359  lastSucceeded_ (false)
360  {
361  }
363  void init (const WaypointEdgeWkPtr_t& weak, const GraphWkPtr_t& graph, const StateWkPtr_t& from,
364  const StateWkPtr_t& to);
365 
367  virtual std::ostream& print (std::ostream& os) const;
368 
369  private:
370  Edges_t edges_;
371  States_t states_;
372 
373  mutable matrix_t configs_;
374  mutable bool lastSucceeded_;
375 
376  WaypointEdgeWkPtr_t wkPtr_;
377  }; // class WaypointEdge
378 
451  class HPP_MANIPULATION_DLLAPI LevelSetEdge : public Edge
452  {
453  public:
454  virtual ~LevelSetEdge ();
455 
458  (const std::string& name,
459  const GraphWkPtr_t& graph, const StateWkPtr_t& from,
460  const StateWkPtr_t& to);
461 
471  virtual bool applyConstraints (core::NodePtr_t nStart,
472  ConfigurationOut_t q) const
474 
484  virtual bool applyConstraints (ConfigurationIn_t qStart,
485  ConfigurationOut_t q) const
487 
496  virtual bool generateTargetConfig(core::NodePtr_t nStart,
497  ConfigurationOut_t q) const;
498 
507  virtual bool generateTargetConfig (ConfigurationIn_t qStart,
508  ConfigurationOut_t q) const;
509 
517  bool generateTargetConfigOnLeaf(ConfigurationIn_t qStart,
518  ConfigurationIn_t qLeaf,
519  ConfigurationOut_t q) const;
520 
522  virtual ConstraintSetPtr_t buildConfigConstraint()
524 
526  virtual ConstraintSetPtr_t buildTargetConstraint();
527 
530  void buildHistogram ();
531 
548  LeafHistogramPtr_t histogram () const;
549 
552 
557  void insertParamConstraint (const ImplicitPtr_t& nm,
558  const segments_t& passiveDofs = segments_t ());
559 
561  const NumericalConstraints_t& paramConstraints() const;
562 
565  void insertConditionConstraint (const ImplicitPtr_t& nm,
566  const segments_t& passiveDofs = segments_t ());
567 
570  const NumericalConstraints_t& conditionConstraints() const;
572 
574  virtual std::ostream& dotPrint (std::ostream& os, dot::DrawingAttributes da = dot::DrawingAttributes ()) const;
575 
576  protected:
578  void init (const LevelSetEdgeWkPtr_t& weak, const GraphWkPtr_t& graph, const StateWkPtr_t& from,
579  const StateWkPtr_t& to);
580 
581  LevelSetEdge (const std::string& name);
582 
584  virtual std::ostream& print (std::ostream& os) const;
585 
587  virtual void populateTooltip (dot::Tooltip& tp) const;
588 
589  virtual void initialize ();
590 
591  private:
592  // Parametrizer
593  // NumericalConstraints_t
594  NumericalConstraints_t paramNumericalConstraints_;
595  IntervalsContainer_t paramPassiveDofs_;
596 
597  // Condition
598  // NumericalConstraints_t
599  NumericalConstraints_t condNumericalConstraints_;
600  IntervalsContainer_t condPassiveDofs_;
601 
603  LeafHistogramPtr_t hist_;
604 
605  LevelSetEdgeWkPtr_t wkPtr_;
606  }; // class LevelSetEdge
607 
609  } // namespace graph
610  } // namespace manipulation
611 } // namespace hpp
612 
613 #endif // HPP_MANIPULATION_GRAPH_EDGE_HH
boost::shared_ptr< Path > PathPtr_t
StateHistogram NodeHistogram HPP_MANIPULATION_DEPRECATED
Definition: statistics.hh:200
const RelativeMotion::matrix_type & relativeMotion() const
Definition: edge.hh:156
const matrix_t & securityMargins() const
Accessor to the security margin.
Definition: edge.hh:176
std::vector< EdgePtr_t > Edges_t
Definition: fwd.hh:46
boost::shared_ptr< ConstraintSet > ConstraintSetPtr_t
Definition: fwd.hh:112
bool isShort() const
Definition: edge.hh:205
core::RelativeMotion RelativeMotion
Definition: edge.hh:62
boost::shared_ptr< LevelSetEdge > LevelSetEdgePtr_t
Definition: fwd.hh:39
void state(StatePtr_t state)
Definition: edge.hh:139
pinocchio::ConfigurationIn_t ConfigurationIn_t
Definition: fwd.hh:38
bool initialize(MeshCollisionTraversalNode< BV, RelativeTransformationIsIdentity > &node, BVHModel< BV > &model1, Transform3f &tf1, BVHModel< BV > &model2, Transform3f &tf2, CollisionResult &result, bool use_refit=false, bool refit_bottomup=false)
boost::shared_ptr< State > StatePtr_t
Definition: fwd.hh:36
bool isShort_
Definition: edge.hh:234
core::value_type value_type
Definition: fwd.hh:79
hpp::core::segments_t segments_t
Definition: fwd.hh:51
void setShort(bool isShort)
Definition: edge.hh:201
const core::PathValidationPtr_t & pathValidation() const
Get path validation associated to the edge.
Definition: edge.hh:151
std::size_t nbWaypoints() const
Definition: edge.hh:347
core::ConfigProjectorPtr_t ConfigProjectorPtr_t
Definition: fwd.hh:110
boost::shared_ptr< WaypointEdge > WaypointEdgePtr_t
Definition: fwd.hh:38
boost::shared_ptr< PathValidation > PathValidationPtr_t
void init(const ConfigurationShooterWkPtr_t &weak)
constraints::ImplicitPtr_t ImplicitPtr_t
Definition: fwd.hh:105
hpp::core::NumericalConstraints_t NumericalConstraints_t
Definition: fwd.hh:53
core::matrix_t matrix_t
Definition: fwd.hh:120
static GradientBasedPtr_t create(const Problem &problem)
boost::shared_ptr< Edge > EdgePtr_t
Definition: fwd.hh:37
pinocchio::ConfigurationOut_t ConfigurationOut_t
Definition: fwd.hh:39
SSM_t::Ptr_t steeringMethod_
core::size_type size_type
Definition: fwd.hh:80
Define common methods of the graph components.
Definition: graph-component.hh:39
boost::shared_ptr< SteeringMethod > SteeringMethodPtr_t
Definition: edge.hh:59
std::vector< StatePtr_t > States_t
Definition: fwd.hh:45
std::vector< segments_t > IntervalsContainer_t
Definition: fwd.hh:52
boost::shared_ptr< LeafHistogram > LeafHistogramPtr_t
Definition: fwd.hh:61
const core::SteeringMethodPtr_t & steeringMethod() const
Get steering method associated to the edge.
Definition: edge.hh:145
Definition: graph.hh:45
Eigen::Matrix< RelativeMotionType, Eigen::Dynamic, Eigen::Dynamic > matrix_type
StatePtr_t state() const
Get the state in which path is.
Definition: edge.hh:134
WaypointEdge(const std::string &name)
Definition: edge.hh:357