hpp-manipulation  4.9.0
Classes for manipulation planning.
state.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_STATE_HH
18 # define HPP_MANIPULATION_GRAPH_STATE_HH
19 
20 # include <boost/function.hpp>
21 
22 #include <hpp/core/constraint-set.hh>
23 #include <hpp/core/config-projector.hh>
24 #include <hpp/constraints/implicit.hh>
25 
26 #include "hpp/manipulation/config.hh"
27 #include "hpp/manipulation/fwd.hh"
31 
32 namespace hpp {
33  namespace manipulation {
34  using constraints::Implicit;
36  namespace graph {
39 
44  class HPP_MANIPULATION_DLLAPI State : public GraphComponent
45  {
46  public:
47  typedef boost::function < EdgePtr_t
48  (const std::string&,
49  const GraphWkPtr_t&,
50  const StateWkPtr_t&, const StateWkPtr_t&) >
53  ~State ();
54 
56  static StatePtr_t create (const std::string& name);
57 
61  EdgePtr_t linkTo (const std::string& name, const StatePtr_t& to,
62  const size_type& w = 1,
64 
72  virtual bool contains (ConfigurationIn_t config) const;
73 
74  inline bool isWaypoint () const
75  {
76  return isWaypoint_;
77  }
78 
79  inline void isWaypoint (bool isWaypoint)
80  {
81  isWaypoint_ = isWaypoint;
82  }
83 
85  StateSelectorWkPtr_t stateSelector () const
86  {
87  return selector_;
88  }
89 
91  void stateSelector (const StateSelectorWkPtr_t& parent)
92  {
93  selector_ = parent;
94  };
95 
97  const Neighbors_t& neighbors() const
98  {
99  return neighbors_;
100  }
101 
104  {
105  return neighbors_.values();
106  }
107 
111  const Edges_t& hiddenNeighbors() const
112  {
113  return hiddenNeighbors_;
114  }
115 
117  void updateWeight (const EdgePtr_t&edge, const Weight_t& w);
118 
120  Weight_t getWeight (const EdgePtr_t&edge);
121 
124  {
125  throwIfNotInitialized ();
126  return configConstraints_;
127  }
128 
131  const segments_t& passiveDofs = segments_t ())
132  {
133  isInit_ = false;
134  numericalConstraintsForPath_.push_back (nm);
135  passiveDofsForPath_.push_back (passiveDofs);
136  }
137 
141  {
142  assert (numericalConstraintsForPath_.size () == passiveDofsForPath_.size ());
143  IntervalsContainer_t::const_iterator itpdofs = passiveDofsForPath_.begin ();
144  for (NumericalConstraints_t::const_iterator it = numericalConstraintsForPath_.begin();
145  it != numericalConstraintsForPath_.end(); it++) {
146  proj->add (*it, *itpdofs);
147  itpdofs++;
148  }
149  return !numericalConstraintsForPath_.empty ();
150  }
151 
154  {
155  return numericalConstraintsForPath_;
156  }
157 
159  std::ostream& dotPrint (std::ostream& os, dot::DrawingAttributes da = dot::DrawingAttributes ()) const;
160 
161  protected:
163  void init (const StateWkPtr_t& self);
164 
166  State(const std::string& name);
167 
169  std::ostream& print (std::ostream& os) const;
170 
171  virtual void populateTooltip (dot::Tooltip& tp) const;
172 
173  virtual void initialize ();
174 
175  private:
178  Neighbors_t neighbors_;
179  Edges_t hiddenNeighbors_;
180 
182  ConstraintSetPtr_t configConstraints_;
183 
185  NumericalConstraints_t numericalConstraintsForPath_;
186  IntervalsContainer_t passiveDofsForPath_;
187 
189  StateSelectorWkPtr_t selector_;
190 
192  StateWkPtr_t wkPtr_;
193 
194  bool isWaypoint_;
195  }; // class State
196 
198  } // namespace graph
199  } // namespace manipulation
200 } // namespace hpp
201 
202 #endif // HPP_MANIPULATION_GRAPH_STATE_HH
const Neighbors_t & neighbors() const
Get the neighbors.
Definition: state.hh:97
std::vector< EdgePtr_t > Edges_t
Definition: fwd.hh:46
boost::shared_ptr< ConstraintSet > ConstraintSetPtr_t
Definition: fwd.hh:112
pinocchio::ConfigurationIn_t ConfigurationIn_t
Definition: fwd.hh:38
bool insertNumericalConstraintsForPath(ConfigProjectorPtr_t &proj) const
Definition: state.hh:140
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)
bool isWaypoint() const
Definition: state.hh:74
boost::shared_ptr< State > StatePtr_t
Definition: fwd.hh:36
const Edges_t & hiddenNeighbors() const
Definition: state.hh:111
hpp::core::segments_t segments_t
Definition: fwd.hh:51
static EdgePtr_t create(const std::string &name, const GraphWkPtr_t &graph, const StateWkPtr_t &from, const StateWkPtr_t &to)
Create a new empty Edge.
assert(d.lhs()._blocks()==d.rhs()._blocks())
core::ConfigProjectorPtr_t ConfigProjectorPtr_t
Definition: fwd.hh:110
ConstraintSetPtr_t configConstraint() const
Constraint to project onto this state.
Definition: state.hh:123
void isWaypoint(bool isWaypoint)
Definition: state.hh:79
void stateSelector(const StateSelectorWkPtr_t &parent)
Set the StateSelector containing this state.
Definition: state.hh:91
void init(const ConfigurationShooterWkPtr_t &weak)
constraints::ImplicitPtr_t ImplicitPtr_t
Definition: fwd.hh:105
Definition: state.hh:44
hpp::core::NumericalConstraints_t NumericalConstraints_t
Definition: fwd.hh:53
static GradientBasedPtr_t create(const Problem &problem)
boost::shared_ptr< Edge > EdgePtr_t
Definition: fwd.hh:37
core::size_type size_type
Definition: fwd.hh:80
Define common methods of the graph components.
Definition: graph-component.hh:39
const NumericalConstraints_t & numericalConstraintsForPath() const
Get a reference to the NumericalConstraints_t.
Definition: state.hh:153
Edges_t neighborEdges() const
Get the neighbors.
Definition: state.hh:103
boost::function< EdgePtr_t(const std::string &, const GraphWkPtr_t &, const StateWkPtr_t &, const StateWkPtr_t &) > EdgeFactory
Definition: state.hh:51
std::vector< segments_t > IntervalsContainer_t
Definition: fwd.hh:52
virtual void addNumericalConstraintForPath(const ImplicitPtr_t &nm, const segments_t &passiveDofs=segments_t())
Add constraints::Implicit to the component.
Definition: state.hh:130
boost::shared_ptr< Implicit > ImplicitPtr_t
StateSelectorWkPtr_t stateSelector() const
Get the parent StateSelector.
Definition: state.hh:85
::hpp::statistics::DiscreteDistribution< EdgePtr_t >::Weight_t Weight_t
Definition: fwd.hh:47