hpp-manipulation  4.9.0
Classes for manipulation planning.
helper.hh
Go to the documentation of this file.
1 // Copyright (c) 2016, 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_HELPER_HH
18 # define HPP_MANIPULATION_GRAPH_HELPER_HH
19 
20 # include <string>
21 # include <algorithm>
22 
23 # include <boost/tuple/tuple.hpp>
24 
25 # include "hpp/manipulation/config.hh"
26 # include "hpp/manipulation/fwd.hh"
28 
29 namespace hpp {
30  namespace manipulation {
32  namespace graph {
33  namespace helper {
37 
44  // ret.nc.reserve (nc.size() + other.nc.size());
45  ret.pdof.reserve (pdof.size() + other.pdof.size());
46 
47  std::copy (nc.begin(), nc.end(), ret.nc.begin());
48  std::copy (other.nc.begin(), other.nc.end(), ret.nc.begin());
49 
50  std::copy (pdof.begin(), pdof.end(), ret.pdof.begin());
51  std::copy (other.pdof.begin(), other.pdof.end(), ret.pdof.begin());
52  return ret;
53  }
54 
55  template <bool forPath> void addToComp (GraphComponentPtr_t comp) const;
56 
57  template <bool param> void specifyFoliation (LevelSetEdgePtr_t lse) const;
58  };
59 
61  // Manifold definition
65  // Foliation definition
68 
70  FoliatedManifold both;
71  both.nc = nc.merge (other.nc);
72  both.nc_path = nc_path.merge (other.nc_path);
73 
74  std::copy (lj.begin (), lj.end (), both.lj.end ());
75  std::copy (other.lj.begin (), other.lj.end (), both.lj.end ());
76  return both;
77  }
78 
79  void addToState (StatePtr_t comp) const;
80  void addToEdge (EdgePtr_t comp) const;
81  void specifyFoliation (LevelSetEdgePtr_t lse) const;
82 
83  bool foliated () const {
84  return !lj_fol.empty () || !nc_fol.nc.empty ();
85  }
86  bool empty () const {
87  return lj.empty () && nc.nc.empty ();
88  }
89  };
90 
91  enum GraspingCase {
92  NoGrasp = 1 << 0,
93  GraspOnly = 1 << 1,
94  WithPreGrasp = 1 << 2
95  };
97  NoPlace = 1 << 3,
98  PlaceOnly = 1 << 4,
99  WithPrePlace = 1 << 5
100  };
101 
102  struct Rule {
103  std::vector<std::string> grippers_;
104  std::vector<std::string> handles_;
105  bool link_;
106  Rule() : grippers_(), handles_(), link_(false) {}
107  };
108 
109  typedef std::vector<Rule> Rules_t;
110 
116  template < int gCase >
118  const std::string& forwName, const std::string& backName,
119  const StatePtr_t& from, const StatePtr_t& to,
120  const size_type& wForw, const size_type& wBack,
121  const FoliatedManifold& grasp, const FoliatedManifold& pregrasp,
122  const FoliatedManifold& place, const FoliatedManifold& preplace,
123  const bool levelSetGrasp, const bool levelSetPlace,
124  const FoliatedManifold& submanifoldDef = FoliatedManifold ()
125  );
126 
128  const std::string& loopName,
129  const StatePtr_t& state,
130  const size_type& w,
131  const bool levelSet,
132  const FoliatedManifold& submanifoldDef = FoliatedManifold ()
133  );
134 
139 
144 
147  void graspManifold (
148  const GripperPtr_t& gripper, const HandlePtr_t& handle,
149  FoliatedManifold& grasp, FoliatedManifold& pregrasp);
150 
154  const ImplicitPtr_t placement,
155  const ImplicitPtr_t preplacement,
156  const ImplicitPtr_t placementComplement,
157  FoliatedManifold& place, FoliatedManifold& preplace);
158 
163  const ImplicitPtr_t placement,
164  const ImplicitPtr_t preplacement,
165  const LockedJoints_t objectLocks,
166  FoliatedManifold& place, FoliatedManifold& preplace);
167 
168  typedef boost::tuple <ImplicitPtr_t,
172  typedef std::vector <HandlePtr_t> Handles_t;
173  typedef std::vector <GripperPtr_t> Grippers_t;
179  typedef boost::tuple <PlacementConstraint_t, Handles_t, std::size_t> Object_t;
180  typedef std::vector <Object_t> Objects_t;
181 
188  void graphBuilder (
189  const ProblemSolverPtr_t& ps,
190  const Objects_t& objects,
191  const Grippers_t& grippers,
192  GraphPtr_t graph,
193  const Rules_t& rules = Rules_t ());
194 
195  struct ObjectDef_t {
196  std::string name;
198  };
199 
201  const ProblemSolverPtr_t& ps,
202  const std::string& graphName,
203  const StringList_t& griNames,
204  const std::list <ObjectDef_t>& objs,
205  const StringList_t& envNames,
206  const Rules_t& rules,
207  const value_type& prePlaceWidth = 0.05);
209  } // namespace helper
210  } // namespace graph
211  } // namespace manipulation
212 } // namespace hpp
213 
214 #endif // HPP_MANIPULATION_GRAPH_HELPER_HH
std::vector< std::string > handles_
Definition: helper.hh:104
boost::shared_ptr< GraphComponent > GraphComponentPtr_t
Definition: fwd.hh:43
std::vector< EdgePtr_t > Edges_t
Definition: fwd.hh:46
NumericalConstraintsAndPassiveDofs merge(const NumericalConstraintsAndPassiveDofs &other)
Definition: helper.hh:42
std::string name
Definition: helper.hh:196
void strictPlacementManifold(const ImplicitPtr_t placement, const ImplicitPtr_t preplacement, const ImplicitPtr_t placementComplement, FoliatedManifold &place, FoliatedManifold &preplace)
boost::tuple< PlacementConstraint_t, Handles_t, std::size_t > Object_t
Definition: helper.hh:179
void graspManifold(const GripperPtr_t &gripper, const HandlePtr_t &handle, FoliatedManifold &grasp, FoliatedManifold &pregrasp)
boost::shared_ptr< LevelSetEdge > LevelSetEdgePtr_t
Definition: fwd.hh:39
NumericalConstraints_t nc
Definition: helper.hh:39
EdgePtr_t createLoopEdge(const std::string &loopName, const StatePtr_t &state, const size_type &w, const bool levelSet, const FoliatedManifold &submanifoldDef=FoliatedManifold())
LockedJoints_t lj
Definition: helper.hh:63
NumericalConstraintsAndPassiveDofs nc_path
Definition: helper.hh:64
boost::tuple< ImplicitPtr_t, ImplicitPtr_t, LockedJoints_t > PlacementConstraint_t
Definition: helper.hh:171
std::vector< HandlePtr_t > Handles_t
Definition: helper.hh:172
boost::shared_ptr< State > StatePtr_t
Definition: fwd.hh:36
core::value_type value_type
Definition: fwd.hh:79
bool empty() const
Definition: helper.hh:86
std::vector< GripperPtr_t > Grippers_t
Definition: helper.hh:173
std::vector< Object_t > Objects_t
Definition: helper.hh:180
bool foliated() const
Definition: helper.hh:83
std::vector< Rule > Rules_t
Definition: helper.hh:109
LockedJoints_t lj_fol
Definition: helper.hh:67
hpp::core::LockedJoints_t LockedJoints_t
Definition: fwd.hh:54
PlacementCase
Definition: helper.hh:96
boost::shared_ptr< Handle > HandlePtr_t
Definition: fwd.hh:48
constraints::ImplicitPtr_t ImplicitPtr_t
Definition: fwd.hh:105
Rule()
Definition: helper.hh:106
hpp::core::NumericalConstraints_t NumericalConstraints_t
Definition: fwd.hh:53
StringList_t shapes
Definition: helper.hh:197
GraspingCase
Definition: helper.hh:91
NumericalConstraintsAndPassiveDofs nc_fol
Definition: helper.hh:66
boost::shared_ptr< Edge > EdgePtr_t
Definition: fwd.hh:37
std::list< std::string > StringList_t
Definition: fwd.hh:132
core::size_type size_type
Definition: fwd.hh:80
void graphBuilder(const ProblemSolverPtr_t &ps, const Objects_t &objects, const Grippers_t &grippers, GraphPtr_t graph, const Rules_t &rules=Rules_t())
boost::shared_ptr< Graph > GraphPtr_t
Definition: fwd.hh:35
FoliatedManifold merge(const FoliatedManifold &other)
Definition: helper.hh:69
std::vector< segments_t > IntervalsContainer_t
Definition: fwd.hh:52
void relaxedPlacementManifold(const ImplicitPtr_t placement, const ImplicitPtr_t preplacement, const LockedJoints_t objectLocks, FoliatedManifold &place, FoliatedManifold &preplace)
Edges_t createEdges(const std::string &forwName, const std::string &backName, const StatePtr_t &from, const StatePtr_t &to, const size_type &wForw, const size_type &wBack, const FoliatedManifold &grasp, const FoliatedManifold &pregrasp, const FoliatedManifold &place, const FoliatedManifold &preplace, const bool levelSetGrasp, const bool levelSetPlace, const FoliatedManifold &submanifoldDef=FoliatedManifold())
boost::shared_ptr< Implicit > ImplicitPtr_t
std::vector< std::string > grippers_
Definition: helper.hh:103
virtual SteeringMethodPtr_t copy() const
Definition: problem-solver.hh:33
pinocchio::GripperPtr_t GripperPtr_t
Definition: fwd.hh:41
bool link_
Definition: helper.hh:105
NumericalConstraintsAndPassiveDofs nc
Definition: helper.hh:62