hpp-manipulation  9.0.2
Classes for manipulation planning.
handle.hh
Go to the documentation of this file.
1 
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 
35 #include <hpp/manipulation/fwd.hh>
36 #include <pinocchio/spatial/se3.hpp>
37 
38 namespace hpp {
39 namespace manipulation {
59  public:
60  static std::string className;
61  virtual ~Handle() {};
62 
70  static HandlePtr_t create(const std::string& name, const Transform3s& pose,
71  const DeviceWkPtr_t& robot,
72  const JointPtr_t& joint) {
73  Handle* ptr = new Handle(name, pose, robot, joint);
74  HandlePtr_t shPtr(ptr);
75  ptr->init(shPtr);
76  return shPtr;
77  }
79  virtual HandlePtr_t clone() const;
80 
83 
85  const std::string& name() const { return name_; }
87  void name(const std::string& n) { name_ = n; }
89 
92 
94  const JointPtr_t& joint() const { return joint_; }
96  void joint(const JointPtr_t& joint) { joint_ = joint; }
97 
98  DevicePtr_t robot() const { return robot_.lock(); }
100 
102  const Transform3s& localPosition() const { return localPosition_; }
103 
105  void localPosition(const Transform3s& localPosition) {
106  localPosition_ = localPosition;
107  }
108 
110  void mask(const std::vector<bool>& mask);
111 
114  const std::vector<bool>& mask() const { return mask_; }
115 
117  void maskComp(const std::vector<bool>& mask);
118 
120  const std::vector<bool>& maskComp() const { return maskComp_; }
121 
130  virtual ImplicitPtr_t createGrasp(const GripperPtr_t& gripper,
131  std::string name) const;
132 
140  std::string name) const;
141 
147  std::string name) const;
148 
157  virtual ImplicitPtr_t createPreGrasp(const GripperPtr_t& gripper,
158  const value_type& shift,
159  std::string name) const;
160 
167  value_type clearance() const { return clearance_; }
168 
171  void clearance(const value_type& clearance) { clearance_ = clearance; }
172 
176  return approachingDirection_;
177  }
178 
181  void approachingDirection(const vector3_t& dir) {
182  approachingDirection_ = dir;
183  }
184 
185  protected:
192  Handle(const std::string& name, const Transform3s& pose,
193  const DeviceWkPtr_t& robot, const JointPtr_t& joint)
194  : name_(name),
195  localPosition_(pose),
196  joint_(joint),
197  robot_(robot),
198  clearance_(0),
199  mask_(6, true),
200  maskComp_(6, false),
201  weakPtr_(),
202  approachingDirection_(1, 0, 0) {}
203  void init(HandleWkPtr_t weakPtr) { weakPtr_ = weakPtr; }
204 
205  virtual std::ostream& print(std::ostream& os) const;
206 
207  private:
208  std::string name_;
210  Transform3s localPosition_;
212  JointPtr_t joint_;
216  value_type clearance_;
218  std::vector<bool> mask_;
220  std::vector<bool> maskComp_;
222  HandleWkPtr_t weakPtr_;
224  vector3_t approachingDirection_;
225  friend std::ostream& operator<<(std::ostream&, const Handle&);
226 }; // class Handle
227 
228 std::ostream& operator<<(std::ostream& os, const Handle& handle);
229 } // namespace manipulation
230 } // namespace hpp
231 
232 #endif // HPP_MANIPULATION_HANDLE_HH
Definition: handle.hh:58
void maskComp(const std::vector< bool > &mask)
Set mask of complement constraint.
void clearance(const value_type &clearance)
Definition: handle.hh:171
virtual ~Handle()
Definition: handle.hh:61
static std::string className
Definition: handle.hh:60
virtual ImplicitPtr_t createGrasp(const GripperPtr_t &gripper, std::string name) const
const std::vector< bool > & maskComp() const
Get mask of complement constraint.
Definition: handle.hh:120
void joint(const JointPtr_t &joint)
Set joint to which the handle is linked.
Definition: handle.hh:96
const vector3_t & approachingDirection() const
Definition: handle.hh:175
Handle(const std::string &name, const Transform3s &pose, const DeviceWkPtr_t &robot, const JointPtr_t &joint)
Definition: handle.hh:192
virtual ImplicitPtr_t createPreGrasp(const GripperPtr_t &gripper, const value_type &shift, std::string name) const
void init(HandleWkPtr_t weakPtr)
Definition: handle.hh:203
value_type clearance() const
Definition: handle.hh:167
virtual HandlePtr_t clone() const
Return a pointer to the copy of this.
void approachingDirection(const vector3_t &dir)
Definition: handle.hh:181
virtual ImplicitPtr_t createGraspComplement(const GripperPtr_t &gripper, std::string name) const
virtual ImplicitPtr_t createGraspAndComplement(const GripperPtr_t &gripper, std::string name) const
void name(const std::string &n)
Set name.
Definition: handle.hh:87
static HandlePtr_t create(const std::string &name, const Transform3s &pose, const DeviceWkPtr_t &robot, const JointPtr_t &joint)
Definition: handle.hh:70
virtual std::ostream & print(std::ostream &os) const
const std::vector< bool > & mask() const
Definition: handle.hh:114
void mask(const std::vector< bool > &mask)
Set constraint mask.
void localPosition(const Transform3s &localPosition)
Set local position in joint frame.
Definition: handle.hh:105
DevicePtr_t robot() const
Definition: handle.hh:98
friend std::ostream & operator<<(std::ostream &, const Handle &)
const std::string & name() const
Get name.
Definition: handle.hh:85
const JointPtr_t & joint() const
Get joint to which the handle is linked.
Definition: handle.hh:94
const Transform3s & localPosition() const
Get local position in joint frame.
Definition: handle.hh:102
#define HPP_MANIPULATION_DLLAPI
Definition: config.hh:88
DevicePtr_t robot_
shared_ptr< Implicit > ImplicitPtr_t
pinocchio::DeviceWkPtr_t DeviceWkPtr_t
pinocchio::JointPtr_t JointPtr_t
Definition: fwd.hh:43
core::vector3_t vector3_t
Definition: fwd.hh:151
pinocchio::GripperPtr_t GripperPtr_t
Definition: fwd.hh:51
constraints::ImplicitPtr_t ImplicitPtr_t
Definition: fwd.hh:131
core::Transform3s Transform3s
Definition: fwd.hh:91
std::ostream & operator<<(std::ostream &os, const Handle &handle)
core::value_type value_type
Definition: fwd.hh:89
shared_ptr< Device > DevicePtr_t
Definition: fwd.hh:40
shared_ptr< Handle > HandlePtr_t
Definition: fwd.hh:58