hpp-manipulation  6.0.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 
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_STATE_HH
30 #define HPP_MANIPULATION_GRAPH_STATE_HH
31 
32 #include <functional>
33 #include <hpp/constraints/implicit.hh>
34 #include <hpp/core/config-projector.hh>
35 #include <hpp/core/constraint-set.hh>
36 
38 #include "hpp/manipulation/fwd.hh"
42 
43 namespace hpp {
44 namespace manipulation {
45 using constraints::Implicit;
47 namespace graph {
50 
56  public:
57  typedef std::function<EdgePtr_t(const std::string&, const GraphWkPtr_t&,
58  const StateWkPtr_t&, const StateWkPtr_t&)>
61  ~State();
62 
64  static StatePtr_t create(const std::string& name);
65 
69  EdgePtr_t linkTo(const std::string& name, const StatePtr_t& to,
70  const size_type& w = 1, EdgeFactory create = Edge::create);
71 
79  virtual bool contains(ConfigurationIn_t config) const;
80 
81  inline bool isWaypoint() const { return isWaypoint_; }
82 
83  inline void isWaypoint(bool isWaypoint) { isWaypoint_ = isWaypoint; }
84 
86  StateSelectorWkPtr_t stateSelector() const { return selector_; }
87 
89  void stateSelector(const StateSelectorWkPtr_t& parent) {
90  selector_ = parent;
91  };
92 
94  const Neighbors_t& neighbors() const { return neighbors_; }
95 
97  Edges_t neighborEdges() const { return neighbors_.values(); }
98 
102  const Edges_t& hiddenNeighbors() const { return hiddenNeighbors_; }
103 
105  void updateWeight(const EdgePtr_t& edge, const Weight_t& w);
106 
109 
112  throwIfNotInitialized();
113  return configConstraints_;
114  }
115 
120  virtual void addNumericalConstraint(const ImplicitPtr_t& numConstraint);
121 
124  invalidate();
125  numericalConstraintsForPath_.push_back(nm);
126  }
127 
131  for (const auto& nc : numericalConstraintsForPath_) proj->add(nc);
132  return !numericalConstraintsForPath_.empty();
133  }
134 
137  return numericalConstraintsForPath_;
138  }
139 
141  std::ostream& dotPrint(std::ostream& os, dot::DrawingAttributes da =
142  dot::DrawingAttributes()) const;
143 
144  protected:
146  void init(const StateWkPtr_t& self);
147 
149  State(const std::string& name);
150 
152  std::ostream& print(std::ostream& os) const;
153 
154  virtual void populateTooltip(dot::Tooltip& tp) const;
155 
156  virtual void initialize();
157 
158  private:
161  Neighbors_t neighbors_;
162  Edges_t hiddenNeighbors_;
163 
165  ConstraintSetPtr_t configConstraints_;
166 
168  NumericalConstraints_t numericalConstraintsForPath_;
169 
171  StateSelectorWkPtr_t selector_;
172 
174  StateWkPtr_t wkPtr_;
175 
176  bool isWaypoint_;
177 }; // class State
178 
180 } // namespace graph
181 } // namespace manipulation
182 } // namespace hpp
183 
184 #endif // HPP_MANIPULATION_GRAPH_STATE_HH
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.
Define common methods of the graph components.
Definition: graph-component.hh:51
Definition: state.hh:55
Edges_t neighborEdges() const
Get the neighbors.
Definition: state.hh:97
const Neighbors_t & neighbors() const
Get the neighbors.
Definition: state.hh:94
bool insertNumericalConstraintsForPath(ConfigProjectorPtr_t &proj) const
Definition: state.hh:130
void stateSelector(const StateSelectorWkPtr_t &parent)
Set the StateSelector containing this state.
Definition: state.hh:89
StateSelectorWkPtr_t stateSelector() const
Get the parent StateSelector.
Definition: state.hh:86
void isWaypoint(bool isWaypoint)
Definition: state.hh:83
ConstraintSetPtr_t configConstraint() const
Constraint to project onto this state.
Definition: state.hh:111
std::function< EdgePtr_t(const std::string &, const GraphWkPtr_t &, const StateWkPtr_t &, const StateWkPtr_t &)> EdgeFactory
Definition: state.hh:59
static StatePtr_t create(const std::string &name)
Create a new state.
virtual bool contains(ConfigurationIn_t config) const
const NumericalConstraints_t & numericalConstraintsForPath() const
Get a reference to the NumericalConstraints_t.
Definition: state.hh:136
State(const std::string &name)
Constructor.
virtual void addNumericalConstraint(const ImplicitPtr_t &numConstraint)
std::ostream & dotPrint(std::ostream &os, dot::DrawingAttributes da=dot::DrawingAttributes()) const
Print the object in a stream.
void init(const StateWkPtr_t &self)
Initialize the object.
EdgePtr_t linkTo(const std::string &name, const StatePtr_t &to, const size_type &w=1, EdgeFactory create=Edge::create)
const Edges_t & hiddenNeighbors() const
Definition: state.hh:102
virtual void addNumericalConstraintForPath(const ImplicitPtr_t &nm)
Add a constraint for paths that lie in this state.
Definition: state.hh:123
virtual void populateTooltip(dot::Tooltip &tp) const
Populate DrawingAttributes tooltip.
Weight_t getWeight(const EdgePtr_t &edge)
Get weight of edge starting from this state.
bool isWaypoint() const
Definition: state.hh:81
std::ostream & print(std::ostream &os) const
Print the object in a stream.
void updateWeight(const EdgePtr_t &edge, const Weight_t &w)
Set weight of edge starting from this state.
#define HPP_MANIPULATION_DLLAPI
Definition: config.hh:88
hpp::core::NumericalConstraints_t NumericalConstraints_t
Definition: fwd.hh:64
shared_ptr< Edge > EdgePtr_t
Definition: fwd.hh:49
::hpp::statistics::DiscreteDistribution< EdgePtr_t > Neighbors_t
Definition: fwd.hh:59
shared_ptr< State > StatePtr_t
Definition: fwd.hh:48
std::vector< EdgePtr_t > Edges_t
Definition: fwd.hh:57
::hpp::statistics::DiscreteDistribution< EdgePtr_t >::Weight_t Weight_t
Definition: fwd.hh:58
shared_ptr< ConstraintSet > ConstraintSetPtr_t
Definition: fwd.hh:138
constraints::ImplicitPtr_t ImplicitPtr_t
Definition: fwd.hh:131
core::ConfigProjectorPtr_t ConfigProjectorPtr_t
Definition: fwd.hh:136
core::size_type size_type
Definition: fwd.hh:90
pinocchio::ConfigurationIn_t ConfigurationIn_t
Definition: fwd.hh:49
Definition: main.hh:1