Line |
Branch |
Exec |
Source |
1 |
|
|
/// |
2 |
|
|
/// Copyright (c) 2014 CNRS |
3 |
|
|
/// Authors: Florent Lamiraux |
4 |
|
|
/// |
5 |
|
|
/// |
6 |
|
|
|
7 |
|
|
// Redistribution and use in source and binary forms, with or without |
8 |
|
|
// modification, are permitted provided that the following conditions are |
9 |
|
|
// met: |
10 |
|
|
// |
11 |
|
|
// 1. Redistributions of source code must retain the above copyright |
12 |
|
|
// notice, this list of conditions and the following disclaimer. |
13 |
|
|
// |
14 |
|
|
// 2. Redistributions in binary form must reproduce the above copyright |
15 |
|
|
// notice, this list of conditions and the following disclaimer in the |
16 |
|
|
// documentation and/or other materials provided with the distribution. |
17 |
|
|
// |
18 |
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
19 |
|
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
20 |
|
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
21 |
|
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
22 |
|
|
// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
23 |
|
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
24 |
|
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 |
|
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 |
|
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 |
|
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 |
|
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH |
29 |
|
|
// DAMAGE. |
30 |
|
|
|
31 |
|
|
#ifndef HPP_MANIPULATION_HANDLE_HH |
32 |
|
|
#define HPP_MANIPULATION_HANDLE_HH |
33 |
|
|
|
34 |
|
|
#include <hpp/manipulation/config.hh> |
35 |
|
|
#include <hpp/manipulation/fwd.hh> |
36 |
|
|
#include <pinocchio/spatial/se3.hpp> |
37 |
|
|
|
38 |
|
|
namespace hpp { |
39 |
|
|
namespace manipulation { |
40 |
|
|
typedef constraints::ImplicitPtr_t ImplicitPtr_t; |
41 |
|
|
/// Frame attached to an object that is aimed at being grasped |
42 |
|
|
/// |
43 |
|
|
/// Together with a hpp::pinocchio::Gripper, a handle defines a grasp. |
44 |
|
|
/// A vector of 6 Boolean values called a mask can be passed to the |
45 |
|
|
/// constructor to define the symmetries of the handle. For example, |
46 |
|
|
/// {True,True,True,False,True,True} means that the handle can be |
47 |
|
|
/// grasped with free orientation around x-axis. |
48 |
|
|
/// See https://hal.laas.fr/hal-02995125v2 for details. |
49 |
|
|
/// The setter method \c mask allows users to define the mask. |
50 |
|
|
/// |
51 |
|
|
/// Along motions where the handle is grasped by a gripper, an additional |
52 |
|
|
/// constraint is enforced, called the complement constraint. This latter |
53 |
|
|
/// constraint ensures that the object is rigidly fixed to the gripper. |
54 |
|
|
/// |
55 |
|
|
/// However, for some applications, the complement constraint can be |
56 |
|
|
/// customized using setter \c maskComp. Note that calling setter method |
57 |
|
|
/// \c mask reinitializes the mask complement. |
58 |
|
|
class HPP_MANIPULATION_DLLAPI Handle { |
59 |
|
|
public: |
60 |
|
|
static std::string className; |
61 |
|
✗ |
virtual ~Handle() {}; |
62 |
|
|
|
63 |
|
|
/// Create constraint corresponding to a gripper grasping this object |
64 |
|
|
/// \param robot the robot that grasps the handle, |
65 |
|
|
/// \param grasp object containing the grasp information |
66 |
|
|
/// \return the constraint of relative position between the handle and |
67 |
|
|
/// the gripper. |
68 |
|
✗ |
static HandlePtr_t create(const std::string& name, |
69 |
|
|
const Transform3s& localPosition, |
70 |
|
|
const DeviceWkPtr_t& robot, |
71 |
|
|
const JointPtr_t& joint) { |
72 |
|
✗ |
Handle* ptr = new Handle(name, localPosition, robot, joint); |
73 |
|
✗ |
HandlePtr_t shPtr(ptr); |
74 |
|
✗ |
ptr->init(shPtr); |
75 |
|
✗ |
return shPtr; |
76 |
|
|
} |
77 |
|
|
/// Return a pointer to the copy of this |
78 |
|
|
virtual HandlePtr_t clone() const; |
79 |
|
|
|
80 |
|
|
/// \name Name |
81 |
|
|
/// \{ |
82 |
|
|
|
83 |
|
|
/// Get name |
84 |
|
✗ |
const std::string& name() const { return name_; } |
85 |
|
|
/// Set name |
86 |
|
|
void name(const std::string& n) { name_ = n; } |
87 |
|
|
/// \} |
88 |
|
|
|
89 |
|
|
/// \name Joint |
90 |
|
|
/// \{ |
91 |
|
|
|
92 |
|
|
/// Get joint to which the handle is linked |
93 |
|
✗ |
const JointPtr_t& joint() const { return joint_; } |
94 |
|
|
/// Set joint to which the handle is linked |
95 |
|
|
void joint(const JointPtr_t& joint) { joint_ = joint; } |
96 |
|
|
|
97 |
|
✗ |
DevicePtr_t robot() const { return robot_.lock(); } |
98 |
|
|
/// \} |
99 |
|
|
|
100 |
|
|
/// Get local position in joint frame |
101 |
|
✗ |
const Transform3s& localPosition() const { return localPosition_; } |
102 |
|
|
|
103 |
|
|
/// Set local position in joint frame |
104 |
|
|
void localPosition(const Transform3s& localPosition) { |
105 |
|
|
localPosition_ = localPosition; |
106 |
|
|
} |
107 |
|
|
|
108 |
|
|
/// Set constraint mask |
109 |
|
|
void mask(const std::vector<bool>& mask); |
110 |
|
|
|
111 |
|
|
/// Get constraint mask |
112 |
|
|
/// See mask(const std::vector<bool>&) |
113 |
|
✗ |
const std::vector<bool>& mask() const { return mask_; } |
114 |
|
|
|
115 |
|
|
/// Set mask of complement constraint |
116 |
|
|
void maskComp(const std::vector<bool>& mask); |
117 |
|
|
|
118 |
|
|
/// Get mask of complement constraint |
119 |
|
|
const std::vector<bool>& maskComp() const { return maskComp_; } |
120 |
|
|
|
121 |
|
|
/// Create constraint corresponding to a gripper grasping this handle |
122 |
|
|
/// \param gripper object containing the gripper information |
123 |
|
|
/// \return the constraint of relative transformation between the handle |
124 |
|
|
/// and the gripper. |
125 |
|
|
/// The degrees of freedom of the relative transformation that are |
126 |
|
|
/// constrained are determined by the mask. |
127 |
|
|
/// \sa constraints::Implicit::mask. |
128 |
|
|
/// The constraint is not parameterizable (has constant right hand side). |
129 |
|
|
virtual ImplicitPtr_t createGrasp(const GripperPtr_t& gripper, |
130 |
|
|
std::string name) const; |
131 |
|
|
|
132 |
|
|
/// Create complement constraint of gripper grasping this handle |
133 |
|
|
/// \param gripper object containing the gripper information |
134 |
|
|
/// \return complement constraint: constraint combined with its complement |
135 |
|
|
/// constitute a full relative transformation constraint. |
136 |
|
|
/// The complement constraint is parameterizable (has non constant right |
137 |
|
|
/// hand side). |
138 |
|
|
virtual ImplicitPtr_t createGraspComplement(const GripperPtr_t& gripper, |
139 |
|
|
std::string name) const; |
140 |
|
|
|
141 |
|
|
/// Create constraint composed of grasp constraint and its complement |
142 |
|
|
/// \param gripper object containing the gripper information |
143 |
|
|
/// \return the composition of grasp constraint and its complement, that |
144 |
|
|
/// that is a full relative transformation constraint. |
145 |
|
|
virtual ImplicitPtr_t createGraspAndComplement(const GripperPtr_t& gripper, |
146 |
|
|
std::string name) const; |
147 |
|
|
|
148 |
|
|
/// Create constraint corresponding to a pregrasping task. |
149 |
|
|
/// \param gripper object containing the gripper information |
150 |
|
|
/// \return the constraint of relative transformation between the handle and |
151 |
|
|
/// the gripper. |
152 |
|
|
/// \note 6 DOFs of the relative transformation between the handle and the |
153 |
|
|
/// gripper |
154 |
|
|
/// are constrained. The transformation is shifted along x-axis of |
155 |
|
|
/// value shift. |
156 |
|
|
virtual ImplicitPtr_t createPreGrasp(const GripperPtr_t& gripper, |
157 |
|
|
const value_type& shift, |
158 |
|
|
std::string name) const; |
159 |
|
|
|
160 |
|
|
/// Get the clearance |
161 |
|
|
/// |
162 |
|
|
/// The clearance is a distance, from the center of the gripper and along |
163 |
|
|
/// the x-aixs, that "ensures" an object being at that distance is not |
164 |
|
|
/// colliding with this gripper. |
165 |
|
|
/// It also gives an order of magnitude of the size of the gripper. |
166 |
|
✗ |
value_type clearance() const { return clearance_; } |
167 |
|
|
|
168 |
|
|
/// Set the clearance |
169 |
|
|
/// \sa clearance() |
170 |
|
✗ |
void clearance(const value_type& clearance) { clearance_ = clearance; } |
171 |
|
|
|
172 |
|
|
protected: |
173 |
|
|
/// Constructor |
174 |
|
|
/// \param robot the robot that grasps the handle, |
175 |
|
|
/// \param grasp object containing the grasp information |
176 |
|
|
/// \return the constraint of relative position between the handle and |
177 |
|
|
/// the gripper. |
178 |
|
✗ |
Handle(const std::string& name, const Transform3s& localPosition, |
179 |
|
|
const DeviceWkPtr_t& robot, const JointPtr_t& joint) |
180 |
|
✗ |
: name_(name), |
181 |
|
✗ |
localPosition_(localPosition), |
182 |
|
✗ |
joint_(joint), |
183 |
|
✗ |
robot_(robot), |
184 |
|
✗ |
clearance_(0), |
185 |
|
✗ |
mask_(6, true), |
186 |
|
✗ |
maskComp_(6, false), |
187 |
|
✗ |
weakPtr_() {} |
188 |
|
✗ |
void init(HandleWkPtr_t weakPtr) { weakPtr_ = weakPtr; } |
189 |
|
|
|
190 |
|
|
virtual std::ostream& print(std::ostream& os) const; |
191 |
|
|
|
192 |
|
|
private: |
193 |
|
|
std::string name_; |
194 |
|
|
/// Position of the handle in the joint frame. |
195 |
|
|
Transform3s localPosition_; |
196 |
|
|
/// Joint to which the handle is linked. |
197 |
|
|
JointPtr_t joint_; |
198 |
|
|
/// Pointer to the robot |
199 |
|
|
DeviceWkPtr_t robot_; |
200 |
|
|
/// Clearance |
201 |
|
|
value_type clearance_; |
202 |
|
|
/// Mask |
203 |
|
|
std::vector<bool> mask_; |
204 |
|
|
/// Mask of complement constraint |
205 |
|
|
std::vector<bool> maskComp_; |
206 |
|
|
/// Weak pointer to itself |
207 |
|
|
HandleWkPtr_t weakPtr_; |
208 |
|
|
|
209 |
|
|
friend std::ostream& operator<<(std::ostream&, const Handle&); |
210 |
|
|
}; // class Handle |
211 |
|
|
|
212 |
|
|
std::ostream& operator<<(std::ostream& os, const Handle& handle); |
213 |
|
|
} // namespace manipulation |
214 |
|
|
} // namespace hpp |
215 |
|
|
|
216 |
|
|
#endif // HPP_MANIPULATION_HANDLE_HH |
217 |
|
|
|