hpp-manipulation 6.0.0
Classes for manipulation planning.
Loading...
Searching...
No Matches
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
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_HELPER_HH
30#define HPP_MANIPULATION_GRAPH_HELPER_HH
31
32#include <algorithm>
33#include <string>
34#include <tuple>
35
39
40namespace hpp {
41namespace manipulation {
42typedef constraints::ImplicitPtr_t ImplicitPtr_t;
43namespace graph {
44namespace helper {
48
50 const NumericalConstraints_t& b) {
52 nc.reserve(a.size() + b.size());
53 std::copy(a.begin(), a.end(), nc.begin());
54 std::copy(b.begin(), b.end(), nc.begin());
55 return nc;
56}
57
59 // Manifold definition
63 // Foliation definition
66
69 both.nc = merge_nc(nc, other.nc);
70 both.nc_path = merge_nc(nc_path, other.nc_path);
71
72 std::copy(lj.begin(), lj.end(), both.lj.end());
73 std::copy(other.lj.begin(), other.lj.end(), both.lj.end());
74 return both;
75 }
76
77 void addToState(StatePtr_t comp) const;
78 void addToEdge(EdgePtr_t comp) const;
80
81 bool foliated() const { return !lj_fol.empty() || !nc_fol.empty(); }
82 bool empty() const { return lj.empty() && nc.empty(); }
83};
84
86 NoGrasp = 1 << 0,
87 GraspOnly = 1 << 1,
88 WithPreGrasp = 1 << 2
89};
91 NoPlace = 1 << 3,
92 PlaceOnly = 1 << 4,
93 WithPrePlace = 1 << 5
94};
95
96struct Rule {
97 std::vector<std::string> grippers_;
98 std::vector<std::string> handles_;
99 bool link_;
100 Rule() : grippers_(), handles_(), link_(false) {}
101};
102
103typedef std::vector<Rule> Rules_t;
104
110template <int gCase>
112 const std::string& forwName, const std::string& backName,
113 const StatePtr_t& from, const StatePtr_t& to, const size_type& wForw,
114 const size_type& wBack, const FoliatedManifold& grasp,
115 const FoliatedManifold& pregrasp, const FoliatedManifold& place,
116 const FoliatedManifold& preplace, const bool levelSetGrasp,
117 const bool levelSetPlace,
118 const FoliatedManifold& submanifoldDef = FoliatedManifold());
119
121 const std::string& loopName, const StatePtr_t& state, const size_type& w,
122 const bool levelSet,
123 const FoliatedManifold& submanifoldDef = FoliatedManifold());
124
129
134
135void graspManifold(const GripperPtr_t& gripper, const HandlePtr_t& handle,
136 FoliatedManifold& grasp, FoliatedManifold& pregrasp);
137
141 const ImplicitPtr_t preplacement,
142 const ImplicitPtr_t placementComplement,
143 FoliatedManifold& place,
144 FoliatedManifold& preplace);
145
150 const ImplicitPtr_t preplacement,
151 const LockedJoints_t objectLocks,
152 FoliatedManifold& place,
153 FoliatedManifold& preplace);
154
155typedef std::tuple<ImplicitPtr_t, ImplicitPtr_t, LockedJoints_t>
157typedef std::vector<HandlePtr_t> Handles_t;
158typedef std::vector<GripperPtr_t> Grippers_t;
165typedef std::tuple<PlacementConstraint_t, Handles_t, std::size_t> Object_t;
166typedef std::vector<Object_t> Objects_t;
167
174void graphBuilder(const ProblemSolverPtr_t& ps, const Objects_t& objects,
175 const Grippers_t& grippers, GraphPtr_t graph,
176 const Rules_t& rules = Rules_t());
177
179 std::string name;
181};
182
184 const std::string& graphName, const Strings_t& griNames,
185 const std::vector<ObjectDef_t>& objs,
186 const Strings_t& envNames, const Rules_t& rules,
187 const value_type& prePlaceWidth = 0.05);
189} // namespace helper
190} // namespace graph
191} // namespace manipulation
192} // namespace hpp
193
194#endif // HPP_MANIPULATION_GRAPH_HELPER_HH
Definition problem-solver.hh:45
EdgePtr_t createLoopEdge(const std::string &loopName, const StatePtr_t &state, const size_type &w, const bool levelSet, const FoliatedManifold &submanifoldDef=FoliatedManifold())
std::vector< HandlePtr_t > Handles_t
Definition helper.hh:157
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())
void graphBuilder(const ProblemSolverPtr_t &ps, const Objects_t &objects, const Grippers_t &grippers, GraphPtr_t graph, const Rules_t &rules=Rules_t())
std::tuple< PlacementConstraint_t, Handles_t, std::size_t > Object_t
Definition helper.hh:165
std::vector< Object_t > Objects_t
Definition helper.hh:166
void strictPlacementManifold(const ImplicitPtr_t placement, const ImplicitPtr_t preplacement, const ImplicitPtr_t placementComplement, FoliatedManifold &place, FoliatedManifold &preplace)
PlacementCase
Definition helper.hh:90
GraspingCase
Definition helper.hh:85
std::vector< GripperPtr_t > Grippers_t
Definition helper.hh:158
void relaxedPlacementManifold(const ImplicitPtr_t placement, const ImplicitPtr_t preplacement, const LockedJoints_t objectLocks, FoliatedManifold &place, FoliatedManifold &preplace)
std::vector< Rule > Rules_t
Definition helper.hh:103
NumericalConstraints_t merge_nc(const NumericalConstraints_t &a, const NumericalConstraints_t &b)
Definition helper.hh:49
std::tuple< ImplicitPtr_t, ImplicitPtr_t, LockedJoints_t > PlacementConstraint_t
Definition helper.hh:156
void graspManifold(const GripperPtr_t &gripper, const HandlePtr_t &handle, FoliatedManifold &grasp, FoliatedManifold &pregrasp)
@ NoPlace
Definition helper.hh:91
@ PlaceOnly
Definition helper.hh:92
@ WithPrePlace
Definition helper.hh:93
@ GraspOnly
Definition helper.hh:87
@ NoGrasp
Definition helper.hh:86
@ WithPreGrasp
Definition helper.hh:88
hpp::core::NumericalConstraints_t NumericalConstraints_t
Definition fwd.hh:64
shared_ptr< Edge > EdgePtr_t
Definition fwd.hh:49
shared_ptr< State > StatePtr_t
Definition fwd.hh:48
shared_ptr< LevelSetEdge > LevelSetEdgePtr_t
Definition fwd.hh:51
hpp::core::LockedJoints_t LockedJoints_t
Definition fwd.hh:65
std::vector< EdgePtr_t > Edges_t
Definition fwd.hh:57
shared_ptr< Graph > GraphPtr_t
Definition fwd.hh:47
pinocchio::GripperPtr_t GripperPtr_t
Definition fwd.hh:51
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
std::vector< std::string > Strings_t
Definition fwd.hh:159
shared_ptr< Handle > HandlePtr_t
Definition fwd.hh:58
Definition main.hh:1
bool foliated() const
Definition helper.hh:81
NumericalConstraints_t nc_path
Definition helper.hh:62
FoliatedManifold merge(const FoliatedManifold &other)
Definition helper.hh:67
void specifyFoliation(LevelSetEdgePtr_t lse) const
bool empty() const
Definition helper.hh:82
NumericalConstraints_t nc
Definition helper.hh:60
LockedJoints_t lj_fol
Definition helper.hh:65
NumericalConstraints_t nc_fol
Definition helper.hh:64
LockedJoints_t lj
Definition helper.hh:61
std::string name
Definition helper.hh:179
Strings_t shapes
Definition helper.hh:180
Strings_t handles
Definition helper.hh:180
std::vector< std::string > grippers_
Definition helper.hh:97
Rule()
Definition helper.hh:100
std::vector< std::string > handles_
Definition helper.hh:98
bool link_
Definition helper.hh:99