From 891ca96699c53b06aac281f919aa27ceae8da4ff Mon Sep 17 00:00:00 2001
From: Joseph Mirabel <jmirabel@laas.fr>
Date: Wed, 26 Aug 2015 19:01:27 +0200
Subject: [PATCH] createPreGraspComplement makes use of the clearance
 parameters.

* old createPreGraspComplement is now deprecated.
* a new createPreGraspComplement without the shift argument is introduced.
---
 include/hpp/manipulation/axial-handle.hh | 19 +++++++++++++++++--
 include/hpp/manipulation/handle.hh       | 16 +++++++++++++++-
 src/axial-handle.cc                      | 13 +++++++++++++
 src/handle.cc                            | 12 ++++++++++++
 4 files changed, 57 insertions(+), 3 deletions(-)

diff --git a/include/hpp/manipulation/axial-handle.hh b/include/hpp/manipulation/axial-handle.hh
index 1f220e3..590eb44 100644
--- a/include/hpp/manipulation/axial-handle.hh
+++ b/include/hpp/manipulation/axial-handle.hh
@@ -70,13 +70,28 @@ namespace hpp {
 
       /// Create constraint that acts on the non-constrained axis of the
       /// constraint generated by Handle::createPreGrasp.
+      /// \warning {currently, the only constrained axis is x. The rotation
+      ///           around the z-axis is not constrained.}
+      /// \param gripper object containing the gripper information
+      /// \return the constraint of relative position between the handle and
+      ///         the gripper.
+      /// \note The translation along x-axis is constrained.
+      virtual DifferentiableFunctionPtr_t createPreGraspComplement
+      (const GripperPtr_t& gripper) const;
+
+      /// Create constraint that acts on the non-constrained axis of the
+      /// constraint generated by Handle::createPreGrasp.
+      /// \warning {currently, the only constrained axis is x. The rotation
+      ///           around the z-axis is not constrained.}
       /// \param gripper object containing the gripper information
       /// \param shift the target value along the x-axis
       /// \return the constraint of relative position between the handle and
       ///         the gripper.
-      /// \note The translation along x-axis and the rotation around z-axis are constrained.
+      /// \note The translation along x-axis is constrained.
+      /// \deprecated Use createPreGraspComplement(const GripperPtr_t&) instead.
       virtual DifferentiableFunctionPtr_t createPreGraspComplement
-      (const GripperPtr_t& gripper, const value_type& shift) const;
+      (const GripperPtr_t& gripper, const value_type& shift) const
+      HPP_MANIPULATION_DEPRECATED;
 
       virtual std::ostream& print (std::ostream& os) const;
     protected:
diff --git a/include/hpp/manipulation/handle.hh b/include/hpp/manipulation/handle.hh
index ee1da30..3c76664 100644
--- a/include/hpp/manipulation/handle.hh
+++ b/include/hpp/manipulation/handle.hh
@@ -21,6 +21,7 @@
 # define HPP_MANIPULATION_HANDLE_HH
 
 # include <hpp/fcl/math/transform.h>
+# include <hpp/manipulation/deprecated.hh>
 # include <hpp/manipulation/config.hh>
 # include <hpp/manipulation/fwd.hh>
 
@@ -107,6 +108,17 @@ namespace hpp {
       virtual DifferentiableFunctionPtr_t createPreGrasp
       (const GripperPtr_t& gripper) const;
 
+      /// Create constraint that acts on the non-constrained axis of the
+      /// constraint generated by Handle::createPreGrasp.
+      /// \param gripper object containing the gripper information
+      /// \return the constraint of relative position between the handle and
+      ///         the gripper.
+      /// \note Only the x-axis of the relative transformation between the handle and the gripper
+      ///       is constrained. The centers are shifted of
+      ///       \f clearance () + gripper->clearance ()\f along the x-axis.
+      virtual DifferentiableFunctionPtr_t createPreGraspComplement
+        (const GripperPtr_t& gripper) const;
+
       /// Create constraint that acts on the non-constrained axis of the
       /// constraint generated by Handle::createPreGrasp.
       /// \param gripper object containing the gripper information
@@ -115,8 +127,10 @@ namespace hpp {
       ///         the gripper.
       /// \note Only the x-axis of the relative transformation between the handle and the gripper
       ///       is constrained.
+      /// \deprecated Use createPreGraspComplement(const GripperPtr_t&) instead.
       virtual DifferentiableFunctionPtr_t createPreGraspComplement
-        (const GripperPtr_t& gripper, const value_type& shift) const;
+        (const GripperPtr_t& gripper, const value_type& shift) const
+        HPP_MANIPULATION_DEPRECATED;
 
       static DifferentiableFunctionPtr_t createGrasp
       (const GripperPtr_t& gripper,const HandlePtr_t& handle)
diff --git a/src/axial-handle.cc b/src/axial-handle.cc
index 9e8cbfe..0ef632f 100644
--- a/src/axial-handle.cc
+++ b/src/axial-handle.cc
@@ -62,6 +62,19 @@ namespace hpp {
           inverse (localPosition()) * gripper->objectPositionInJoint (), mask);
     }
 
+    DifferentiableFunctionPtr_t AxialHandle::createPreGraspComplement
+      (const GripperPtr_t& gripper) const
+    {
+      using boost::assign::list_of;
+      std::vector <bool> mask = list_of (true)(false)(false);
+      Transform3f transform = inverse (localPosition()) * gripper->objectPositionInJoint ();
+      fcl::Vec3f target = transform.getTranslation ()
+                        + fcl::Vec3f (clearance () + gripper->clearance (),0,0);
+      return RelativePosition::create ("Position_(1,0,0)_" + name () + "_" + gripper->name (),
+          gripper->joint()->robot(), gripper->joint (), joint(), target, fcl::Vec3f (0,0,0), mask);
+    }
+
+
     DifferentiableFunctionPtr_t AxialHandle::createPreGraspComplement
       (const GripperPtr_t& gripper, const value_type& shift) const
     {
diff --git a/src/handle.cc b/src/handle.cc
index 8727e64..b456ea6 100644
--- a/src/handle.cc
+++ b/src/handle.cc
@@ -62,6 +62,18 @@ namespace hpp {
           gripper->joint()->robot(), gripper->joint (), joint(), transform, mask);
     }
 
+    DifferentiableFunctionPtr_t Handle::createPreGraspComplement
+    (const GripperPtr_t& gripper) const
+    {
+      using boost::assign::list_of;
+      std::vector <bool> mask = list_of (true)(false)(false);
+      Transform3f transform = inverse (localPosition()) * gripper->objectPositionInJoint ();
+      fcl::Vec3f target = transform.getTranslation ()
+        + fcl::Vec3f (clearance () + gripper->clearance (),0,0);
+      return RelativePosition::create ("Position_(1,0,0)_" + name () + "_" + gripper->name (),
+          gripper->joint()->robot(), gripper->joint (), joint(), target, fcl::Vec3f (0,0,0), mask);
+    }
+
     DifferentiableFunctionPtr_t Handle::createPreGraspComplement
     (const GripperPtr_t& gripper, const value_type& shift) const
     {
-- 
GitLab