diff --git a/CMakeLists.txt b/CMakeLists.txt index 2ebdf434ebedb6a0cf552b56cadcf2da113cd634..bef800f3a4e3de201fb3a2169624210ecca1c501 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,7 +40,7 @@ ADD_REQUIRED_DEPENDENCY(hpp-constraints >= 3.0.0) SET (${PROJECT_NAME}_HEADERS include/hpp/manipulation/fwd.hh - include/hpp/manipulation/grasp.hh + include/hpp/manipulation/gripper.hh include/hpp/manipulation/axial-handle.hh include/hpp/manipulation/handle.hh include/hpp/manipulation/object.hh diff --git a/include/hpp/manipulation/axial-handle.hh b/include/hpp/manipulation/axial-handle.hh index 889eaee3198dbab79db857c3128b637434d0b469..b7de07c0c5a67067fbbc05e154f16fd808bd441f 100644 --- a/include/hpp/manipulation/axial-handle.hh +++ b/include/hpp/manipulation/axial-handle.hh @@ -51,7 +51,7 @@ namespace hpp { /// \return the constraint of relative position between the handle and /// the gripper. The rotation around x is not constrained. virtual DifferentiableFunctionPtr_t createGrasp - (const RobotPtr_t& robot, const GraspPtr_t& grasp) const; + (const GripperPtr_t& gripper) const; virtual std::ostream& print (std::ostream& os) const; protected: diff --git a/include/hpp/manipulation/fwd.hh b/include/hpp/manipulation/fwd.hh index d3f576f4a4b986b1cec2c8c7a526514c9e922dfd..71f291f07f5bcb85ea7f826e5673ee8830b8bd96 100644 --- a/include/hpp/manipulation/fwd.hh +++ b/include/hpp/manipulation/fwd.hh @@ -38,8 +38,8 @@ namespace hpp { typedef boost::shared_ptr <AxialHandle> AxialHandlePtr_t; typedef core::DifferentiableFunction DifferentiableFunction; typedef core::DifferentiableFunctionPtr_t DifferentiableFunctionPtr_t; - HPP_PREDEF_CLASS (Grasp); - typedef boost::shared_ptr <Grasp> GraspPtr_t; + HPP_PREDEF_CLASS (Gripper); + typedef boost::shared_ptr <Gripper> GripperPtr_t; HPP_PREDEF_CLASS (Handle); typedef boost::shared_ptr <Handle> HandlePtr_t; HPP_PREDEF_CLASS (Object); @@ -63,7 +63,7 @@ namespace hpp { typedef model::vectorOut_t vectorOut_t; typedef std::vector <DevicePtr_t> Devices_t; - typedef std::vector <GraspPtr_t> Grasps_t; + typedef std::vector <GripperPtr_t> Grippers_t; typedef std::vector <ObjectPtr_t> Objects_t; typedef std::map <JointConstPtr_t, JointPtr_t> JointMap_t; typedef core::ConstraintPtr_t ConstraintPtr_t; diff --git a/include/hpp/manipulation/grasp.hh b/include/hpp/manipulation/gripper.hh similarity index 65% rename from include/hpp/manipulation/grasp.hh rename to include/hpp/manipulation/gripper.hh index 5df35bbc94199426e2fed9b800f09b9d37f13346..862b0223eaddb4b086f77cf00ff8c80340327544 100644 --- a/include/hpp/manipulation/grasp.hh +++ b/include/hpp/manipulation/gripper.hh @@ -17,62 +17,72 @@ // hpp-manipulation. If not, see // <http://www.gnu.org/licenses/>. -#ifndef HPP_MANIPULATION_GRASP_HH -# define HPP_MANIPULATION_GRASP_HH +#ifndef HPP_MANIPULATION_GRIPPER_HH +# define HPP_MANIPULATION_GRIPPER_HH # include <hpp/manipulation/handle.hh> namespace hpp { namespace manipulation { /// Constraint between the position of a robot joint and of an object handle - class HPP_MANIPULATION_DLLAPI Grasp + class HPP_MANIPULATION_DLLAPI Gripper { public: /// Return a shared pointer to new instance - /// \param joint joint of the robot that holds the handle, - /// \param handle handle that is grasped, + /// \param joint joint of the robot that will hold handles, /// \param handlePositionInJoint handle position in the the grasping /// joint. - static GraspPtr_t create (const JointPtr_t& joint, - const HandlePtr_t& handle, + static GripperPtr_t create (const std::string& name, const JointPtr_t& joint, const Transform3f& handlePositionInJoint) { - Grasp* ptr = new Grasp (joint, handle, handlePositionInJoint); - return GraspPtr_t (ptr); - } - /// Get handle that is grasped - const HandlePtr_t& handle () const - { - return handle_; + Gripper* ptr = new Gripper (name, joint, handlePositionInJoint); + return GripperPtr_t (ptr); } - /// Get joint that grasps + + /// Get joint that Grippers const JointPtr_t& joint () const { return joint_; } - /// Get handle position in the the grasping joint + /// Get handle position in the the Grippering joint const Transform3f& handlePositionInJoint () const { return handlePositionInJoint_; } + ///get name + const std::string& name () const + { + return name_; + } + /// Set name + void name (const std::string& n) + { + name_ = n; + } + + + DifferentiableFunctionPtr_t createGrasp(HandlePtr_t& handle) + { + return handle->createGrasp(GripperPtr_t(this)); + } + protected: /// Constructor /// \param joint joint of the robot that holds the handle, - /// \param handle handle that is grasped, /// \param handlePositionInJoint handle position in the the grasping /// joint. - Grasp (const JointPtr_t& joint, const HandlePtr_t& handle, + Gripper (const std::string& name, const JointPtr_t& joint, const Transform3f& handlePositionInJoint) : - joint_ (joint), handle_ (handle), + joint_ (joint), handlePositionInJoint_ (handlePositionInJoint) { } private: - /// Joint of the robot that holds the handle. + /// Joint of the robot that holds handles. + std::string name_; JointPtr_t joint_; - HandlePtr_t handle_; Transform3f handlePositionInJoint_; - }; // class Grasp + }; // class Gripper } // namespace manipulation } // namespace hpp -#endif // HPP_MANIPULATION_GRASP_HH +#endif // HPP_MANIPULATION_GRIPPER_HH diff --git a/include/hpp/manipulation/handle.hh b/include/hpp/manipulation/handle.hh index 204832c50018fdf03ab4c9942de601aded7cd73d..4afd217fb6082c6e8a083f1e0c9d81f88ad6f916 100644 --- a/include/hpp/manipulation/handle.hh +++ b/include/hpp/manipulation/handle.hh @@ -84,8 +84,7 @@ namespace hpp { } /// Create constraint corresponding to a gripper grasping this object - /// \param robot the robot that grasps the handle, - /// \param grasp object containing the grasp information + /// \param gripper object containing the gripper information /// \return the constraint of relative position between the handle and /// the gripper. /// \note the constraint may constrain less than 6 degrees of freedom @@ -93,7 +92,7 @@ namespace hpp { /// a handle symmetric with respect to its x-axis for instance, the /// rotation around x is not constrained. virtual DifferentiableFunctionPtr_t createGrasp - (const RobotPtr_t& robot, const GraspPtr_t& grasp) const; + (const GripperPtr_t& gripper) const; virtual std::ostream& print (std::ostream& os) const; protected: diff --git a/src/axial-handle.cc b/src/axial-handle.cc index c5484fbe41ddefbd1246a21141af8d26601a059c..7f57d2fc8991a4d73ec9f09ca42c141253f0e0de 100644 --- a/src/axial-handle.cc +++ b/src/axial-handle.cc @@ -22,21 +22,21 @@ #include <hpp/model/joint.hh> #include <hpp/constraints/relative-transformation.hh> #include <hpp/manipulation/axial-handle.hh> -#include <hpp/manipulation/grasp.hh> +#include <hpp/manipulation/gripper.hh> #include <hpp/manipulation/robot.hh> namespace hpp { namespace manipulation { DifferentiableFunctionPtr_t AxialHandle::createGrasp - (const RobotPtr_t& robot, const GraspPtr_t& grasp) const + (const GripperPtr_t& gripper) const { using boost::assign::list_of; std::vector <bool> mask = list_of (true)(true)(true)(false)(true)(true); return RelativeTransformation::create - (robot, grasp->joint (), grasp->handle ()->joint (), - inverse (grasp->handle ()->localPosition ()) * - grasp->handlePositionInJoint (), mask); + (gripper->joint()->robot(), gripper->joint (), joint(), + inverse (localPosition()) * + gripper->handlePositionInJoint (), mask); } HandlePtr_t AxialHandle::clone () const { diff --git a/src/handle.cc b/src/handle.cc index 793477e43a654aebc9a1bbdd2a7a050741e77c65..c66e2e73a244d35bf7c4da5263b9e6e3d4b3b336 100644 --- a/src/handle.cc +++ b/src/handle.cc @@ -22,21 +22,20 @@ #include <hpp/model/joint.hh> #include <hpp/constraints/relative-transformation.hh> #include <hpp/manipulation/handle.hh> -#include <hpp/manipulation/grasp.hh> +#include <hpp/manipulation/gripper.hh> #include <hpp/manipulation/robot.hh> namespace hpp { namespace manipulation { DifferentiableFunctionPtr_t Handle::createGrasp - (const RobotPtr_t& robot, const GraspPtr_t& grasp) const + (const GripperPtr_t& gripper) const { using boost::assign::list_of; std::vector <bool> mask = list_of (true)(true)(true)(true)(true)(true); return RelativeTransformation::create - (robot, grasp->joint (), grasp->handle ()->joint (), - inverse (grasp->handle ()->localPosition ()) * - grasp->handlePositionInJoint (), mask); + (gripper->joint()->robot(), gripper->joint (), joint(), inverse (localPosition()) * + gripper->handlePositionInJoint (), mask); } HandlePtr_t Handle::clone () const diff --git a/src/robot.cc b/src/robot.cc index e7842850a18925535c14805bfc743dfb84c1736d..410d963e77605af5628dbdff17452fae471382a9 100644 --- a/src/robot.cc +++ b/src/robot.cc @@ -20,7 +20,7 @@ #include <hpp/util/debug.hh> #include <hpp/model/object-factory.hh> #include <hpp/manipulation/robot.hh> -#include <hpp/manipulation/grasp.hh> +#include <hpp/manipulation/gripper.hh> namespace hpp { namespace manipulation {