| Line |
Branch |
Exec |
Source |
| 1 |
|
|
// |
| 2 |
|
|
// Copyright (c) 2016 CNRS |
| 3 |
|
|
// Authors: Joseph Mirabel from 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_PINOCCHIO_GRIPPER_HH |
| 32 |
|
|
#define HPP_PINOCCHIO_GRIPPER_HH |
| 33 |
|
|
|
| 34 |
|
|
#include <hpp/pinocchio/config.hh> |
| 35 |
|
|
#include <hpp/pinocchio/fwd.hh> |
| 36 |
|
|
|
| 37 |
|
|
namespace hpp { |
| 38 |
|
|
namespace pinocchio { |
| 39 |
|
|
/// Definition of a robot gripper |
| 40 |
|
|
/// |
| 41 |
|
|
/// This class represent a robot gripper as a frame attached to the joint |
| 42 |
|
|
/// of the robot that holds the gripper. |
| 43 |
|
|
/// |
| 44 |
|
|
/// \image html figures/figure-gripper.png |
| 45 |
|
|
/// |
| 46 |
|
|
/// To graps a box-shaped object with small lengths along x and y, the |
| 47 |
|
|
/// gripper frame should coincide with the object frame. |
| 48 |
|
|
class HPP_PINOCCHIO_DLLAPI Gripper { |
| 49 |
|
|
public: |
| 50 |
|
|
/// Return a shared pointer to new instance |
| 51 |
|
|
/// \param name of the gripper in the device, |
| 52 |
|
|
/// \param device |
| 53 |
|
✗ |
static GripperPtr_t create(const std::string& name, |
| 54 |
|
|
const DeviceWkPtr_t& device) { |
| 55 |
|
✗ |
Gripper* ptr = new Gripper(name, device); |
| 56 |
|
✗ |
GripperPtr_t shPtr(ptr); |
| 57 |
|
✗ |
ptr->init(shPtr); |
| 58 |
|
✗ |
return shPtr; |
| 59 |
|
|
} |
| 60 |
|
|
|
| 61 |
|
✗ |
static GripperPtr_t createCopy(const GripperPtr_t& gripper, |
| 62 |
|
|
const DeviceWkPtr_t& otherDevice) { |
| 63 |
|
✗ |
Gripper* ptr = new Gripper(gripper->name(), otherDevice); |
| 64 |
|
✗ |
ptr->clearance(gripper->clearance()); |
| 65 |
|
✗ |
GripperPtr_t shPtr(ptr); |
| 66 |
|
✗ |
ptr->init(shPtr); |
| 67 |
|
✗ |
return shPtr; |
| 68 |
|
|
} |
| 69 |
|
|
|
| 70 |
|
|
/// Get joint to which the gripper is attached |
| 71 |
|
✗ |
const JointPtr_t& joint() const { return joint_; } |
| 72 |
|
|
|
| 73 |
|
|
/// Get the frame Id of the gripper in the vector of frame of the Model |
| 74 |
|
✗ |
const FrameIndex& frameId() const { return fid_; } |
| 75 |
|
|
|
| 76 |
|
|
/// Get handle position in the the Grippering joint |
| 77 |
|
|
const Transform3s& objectPositionInJoint() const; |
| 78 |
|
|
|
| 79 |
|
|
/// get name |
| 80 |
|
✗ |
const std::string& name() const { return name_; } |
| 81 |
|
|
|
| 82 |
|
|
/// Get the clearance |
| 83 |
|
|
/// |
| 84 |
|
|
/// The clearance is a distance, from the center of the gripper and along |
| 85 |
|
|
/// the x-aixs, that "ensures" an object being at that distance is not |
| 86 |
|
|
/// colliding with this gripper. |
| 87 |
|
|
/// It also gives an order of magnitude of the size of the gripper. |
| 88 |
|
✗ |
value_type clearance() const { return clearance_; } |
| 89 |
|
|
|
| 90 |
|
|
/// Set the clearance |
| 91 |
|
|
/// \sa clearance() |
| 92 |
|
✗ |
void clearance(const value_type& clearance) { clearance_ = clearance; } |
| 93 |
|
|
|
| 94 |
|
|
GripperPtr_t clone() const; |
| 95 |
|
|
|
| 96 |
|
|
std::ostream& print(std::ostream& os) const; |
| 97 |
|
|
|
| 98 |
|
|
protected: |
| 99 |
|
|
/// Constructor |
| 100 |
|
|
/// \param name of the gripper in the device, |
| 101 |
|
|
/// \param device |
| 102 |
|
|
/// \todo device should be of type DeviceConstPtr_t but the constructor of |
| 103 |
|
|
/// JointPtr_t needs a DevicePtr_t. |
| 104 |
|
|
Gripper(const std::string& name, const DeviceWkPtr_t& device); |
| 105 |
|
|
|
| 106 |
|
✗ |
void init(GripperWkPtr_t weakPtr) { weakPtr_ = weakPtr; } |
| 107 |
|
|
|
| 108 |
|
|
private: |
| 109 |
|
|
inline DevicePtr_t device() const; |
| 110 |
|
|
|
| 111 |
|
|
std::string name_; |
| 112 |
|
|
DeviceWkPtr_t device_; |
| 113 |
|
|
/// Joint of the robot that holds handles. |
| 114 |
|
|
JointPtr_t joint_; |
| 115 |
|
|
mutable FrameIndex fid_; |
| 116 |
|
|
/// Clearance |
| 117 |
|
|
value_type clearance_; |
| 118 |
|
|
/// Weak pointer to itself |
| 119 |
|
|
GripperWkPtr_t weakPtr_; |
| 120 |
|
|
}; // class Gripper |
| 121 |
|
|
|
| 122 |
|
|
inline std::ostream& operator<<(std::ostream& os, const Gripper& gripper) { |
| 123 |
|
|
return gripper.print(os); |
| 124 |
|
|
} |
| 125 |
|
|
} // namespace pinocchio |
| 126 |
|
|
} // namespace hpp |
| 127 |
|
|
|
| 128 |
|
|
#endif // HPP_PINOCCHIO_GRIPPER_HH |
| 129 |
|
|
|