Skip to content
Snippets Groups Projects
Commit 4c931d1f authored by Florent Lamiraux's avatar Florent Lamiraux Committed by Florent Lamiraux florent@laas.fr
Browse files

Add a method createGraspAndComplement in Handle classes

  - create a constraint merging a grasp constraint and its complement.
parent 8cbb0948
No related branches found
No related tags found
No related merge requests found
...@@ -63,6 +63,13 @@ namespace hpp { ...@@ -63,6 +63,13 @@ namespace hpp {
virtual NumericalConstraintPtr_t createGraspComplement virtual NumericalConstraintPtr_t createGraspComplement
(const GripperPtr_t& gripper, std::string name) const; (const GripperPtr_t& gripper, std::string name) const;
/// Create constraint composed of grasp constraint and its complement
/// \param gripper object containing the gripper information
/// \return the composition of grasp constraint and its complement.
/// \note the 6 degrees of freedom are constrained
virtual NumericalConstraintPtr_t createGraspAndComplement
(const GripperPtr_t& gripper, std::string name) const;
/// Create constraint corresponding to a pregrasping task. /// Create constraint corresponding to a pregrasping task.
/// \param gripper object containing the gripper information /// \param gripper object containing the gripper information
/// \return the constraint of relative transformation between the handle and /// \return the constraint of relative transformation between the handle and
......
...@@ -94,21 +94,30 @@ namespace hpp { ...@@ -94,21 +94,30 @@ namespace hpp {
const std::vector<bool>& mask () const const std::vector<bool>& mask () const
{ return mask_; } { return mask_; }
/// Create constraint corresponding to a gripper grasping this object /// Create constraint corresponding to a gripper grasping this handle
/// \param gripper object containing the gripper information /// \param gripper object containing the gripper information
/// \return the constraint of relative transformation between the handle and /// \return the constraint of relative transformation between the handle
/// the gripper. /// and the gripper.
/// \note The 6 DOFs of the relative transformation are constrained. /// \note The 6 DOFs of the relative transformation are constrained.
virtual NumericalConstraintPtr_t createGrasp virtual NumericalConstraintPtr_t createGrasp
(const GripperPtr_t& gripper, std::string name) const; (const GripperPtr_t& gripper, std::string name) const;
/// Create constraint that acts on the non-constrained axis of the /// Create complement constraint of gripper grasping this handle
/// constraint generated by Handle::createGrasp.
/// \param gripper object containing the gripper information /// \param gripper object containing the gripper information
/// \return a constraints that is not doing anything. /// \return trivial constraint
/// \note for this base class, the complement constraint is trivial, i.e.
/// it is of dimension 0.
virtual NumericalConstraintPtr_t createGraspComplement virtual NumericalConstraintPtr_t createGraspComplement
(const GripperPtr_t& gripper, std::string name) const; (const GripperPtr_t& gripper, std::string name) const;
/// Create constraint composed of grasp constraint and its complement
/// \param gripper object containing the gripper information
/// \return the composition of grasp constraint and its complement.
/// \note for this base class, this constraint is the same as the grasp
/// constraint.
virtual NumericalConstraintPtr_t createGraspAndComplement
(const GripperPtr_t& gripper, std::string name) const;
/// Create constraint corresponding to a pregrasping task. /// Create constraint corresponding to a pregrasping task.
/// \param gripper object containing the gripper information /// \param gripper object containing the gripper information
/// \return the constraint of relative transformation between the handle and /// \return the constraint of relative transformation between the handle and
......
...@@ -115,6 +115,12 @@ namespace hpp { ...@@ -115,6 +115,12 @@ namespace hpp {
DoubleInequality::create (width))); DoubleInequality::create (width)));
} }
NumericalConstraintPtr_t AxialHandle::createGraspAndComplement
(const GripperPtr_t& gripper, std::string n) const
{
return Handle::createGraspAndComplement (gripper, n);
}
HandlePtr_t AxialHandle::clone () const HandlePtr_t AxialHandle::clone () const
{ {
AxialHandlePtr_t self = weakPtr_.lock (); AxialHandlePtr_t self = weakPtr_.lock ();
......
...@@ -107,16 +107,15 @@ namespace hpp { ...@@ -107,16 +107,15 @@ namespace hpp {
(const GripperPtr_t& gripper, std::string n) const (const GripperPtr_t& gripper, std::string n) const
{ {
using core::ExplicitRelativeTransformation; using core::ExplicitRelativeTransformation;
if (n.empty()) {
n = gripper->name() + "_grasps_" + name() + "_" + maskToStr (mask_);
}
// If handle is on a freeflying object, create an explicit constraint // If handle is on a freeflying object, create an explicit constraint
if (is6Dmask(mask_) && isHandleOnFreeflyer (*this)) { if (is6Dmask(mask_) && isHandleOnFreeflyer (*this)) {
if (n.empty())
n = "Explicit_relative_transform_" + name() + "_" + gripper->name();
return ExplicitRelativeTransformation::create return ExplicitRelativeTransformation::create
(n, gripper->joint ()->robot (), gripper->joint (), joint (), (n, gripper->joint ()->robot (), gripper->joint (), joint (),
gripper->objectPositionInJoint (), localPosition())->createNumericalConstraint(); gripper->objectPositionInJoint (), localPosition())->createNumericalConstraint();
} }
if (n.empty())
n = "Grasp_" + maskToStr(mask_) + "_" + name() + "_" + gripper->name();
return NumericalConstraintPtr_t return NumericalConstraintPtr_t
(NumericalConstraint::create (RelativeTransformation::create (NumericalConstraint::create (RelativeTransformation::create
(n, (n,
...@@ -129,20 +128,19 @@ namespace hpp { ...@@ -129,20 +128,19 @@ namespace hpp {
NumericalConstraintPtr_t Handle::createGraspComplement NumericalConstraintPtr_t Handle::createGraspComplement
(const GripperPtr_t& gripper, std::string n) const (const GripperPtr_t& gripper, std::string n) const
{ {
if (n.empty()) {
std::vector<bool> Cmask = complementMask(mask_);
n = gripper->name() + "_grasps_" + name() + "/complement_" +
maskToStr (Cmask);
}
core::DevicePtr_t robot = gripper->joint()->robot(); core::DevicePtr_t robot = gripper->joint()->robot();
if (is6Dmask(mask_)) { if (is6Dmask(mask_)) {
if (n.empty())
n = "GraspComp_(0,0,0,0,0,0)_" + name () + "_" + gripper->name ();
return NumericalConstraint::create ( return NumericalConstraint::create (
boost::shared_ptr <ZeroDiffFunc> (new ZeroDiffFunc ( boost::shared_ptr <ZeroDiffFunc> (new ZeroDiffFunc (
robot->configSize(), robot->numberDof (), n)) robot->configSize(), robot->numberDof (), n))
); );
} else { } else {
// TODO handle cases where rotations or translation are allowed.
std::vector<bool> Cmask = complementMask(mask_); std::vector<bool> Cmask = complementMask(mask_);
if (n.empty())
n = "Transformation_" + maskToStr(Cmask) + "_" + name ()
+ "_" + gripper->name ();
RelativeTransformationPtr_t function = RelativeTransformation::create RelativeTransformationPtr_t function = RelativeTransformation::create
(n, (n,
gripper->joint()->robot(), gripper->joint()->robot(),
...@@ -157,10 +155,35 @@ namespace hpp { ...@@ -157,10 +155,35 @@ namespace hpp {
} }
} }
NumericalConstraintPtr_t Handle::createGraspAndComplement
(const GripperPtr_t& gripper, std::string n) const
{
using boost::assign::list_of;
using core::ExplicitRelativeTransformation;
if (n.empty()) {
n = gripper->name() + "_holds_" + name();
}
// If handle is on a freeflying object, create an explicit constraint
if (isHandleOnFreeflyer (*this)) {
return ExplicitRelativeTransformation::create
(n, gripper->joint ()->robot (), gripper->joint (), joint (),
gripper->objectPositionInJoint (),
localPosition())->createNumericalConstraint();
}
return NumericalConstraintPtr_t
(NumericalConstraint::create (RelativeTransformation::create
(n,
gripper->joint()->robot(),
gripper->joint (), joint (),
gripper->objectPositionInJoint (),
localPosition(),
list_of (true)(true)(true)(true)(true)
(true))));
}
NumericalConstraintPtr_t Handle::createPreGrasp NumericalConstraintPtr_t Handle::createPreGrasp
(const GripperPtr_t& gripper, const value_type& shift, std::string n) const (const GripperPtr_t& gripper, const value_type& shift, std::string n) const
{ {
using boost::assign::list_of;
Transform3f transform = gripper->objectPositionInJoint () Transform3f transform = gripper->objectPositionInJoint ()
* Transform3f (I3, vector3_t (shift,0,0)); * Transform3f (I3, vector3_t (shift,0,0));
if (n.empty()) if (n.empty())
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment