Skip to content
Snippets Groups Projects
Commit 94157409 authored by Florent Lamiraux's avatar Florent Lamiraux
Browse files

[ProblemSolver] Do not create explicit constraint for contact surfaces

  when robot contact surfaces are not on a freeflying object.
parent 96a3fb55
No related branches found
No related tags found
No related merge requests found
...@@ -244,6 +244,7 @@ namespace hpp { ...@@ -244,6 +244,7 @@ namespace hpp {
(const std::string& name, const StringList_t& surface1, (const std::string& name, const StringList_t& surface1,
const StringList_t& surface2, const value_type& margin) const StringList_t& surface2, const value_type& margin)
{ {
bool explicit_(true);
if (!robot_) throw std::runtime_error ("No robot loaded"); if (!robot_) throw std::runtime_error ("No robot loaded");
JointAndShapes_t floorSurfaces, objectSurfaces, l; JointAndShapes_t floorSurfaces, objectSurfaces, l;
for (StringList_t::const_iterator it1 = surface1.begin (); for (StringList_t::const_iterator it1 = surface1.begin ();
...@@ -251,7 +252,19 @@ namespace hpp { ...@@ -251,7 +252,19 @@ namespace hpp {
if (!robot_->jointAndShapes.has (*it1)) if (!robot_->jointAndShapes.has (*it1))
throw std::runtime_error ("First list of triangles not found."); throw std::runtime_error ("First list of triangles not found.");
l = robot_->jointAndShapes.get (*it1); l = robot_->jointAndShapes.get (*it1);
objectSurfaces.insert(objectSurfaces.end(), l.begin(), l.end()); for(auto js : l){
JointPtr_t j(js.first);
// If one robot contact surface is not on a freeflying object,
// The contact constraint cannot be expressed by an explicit
// constraint.
if ((j->parentJoint()) ||
((*j->configurationSpace()!=*pinocchio::LiegroupSpace::SE3()) &&
(*j->configurationSpace()!=*pinocchio::LiegroupSpace::R3xSO3())))
{
explicit_ = false;
}
objectSurfaces.insert(objectSurfaces.end(), l.begin(), l.end());
}
} }
for (StringList_t::const_iterator it2 = surface2.begin (); for (StringList_t::const_iterator it2 = surface2.begin ();
...@@ -266,28 +279,45 @@ namespace hpp { ...@@ -266,28 +279,45 @@ namespace hpp {
floorSurfaces.insert(floorSurfaces.end(), l.begin(), l.end()); floorSurfaces.insert(floorSurfaces.end(), l.begin(), l.end());
} }
typedef hpp::constraints::explicit_::ConvexShapeContact Constraint_t; if (explicit_){
Constraint_t::Constraints_t constraints typedef hpp::constraints::explicit_::ConvexShapeContact Constraint_t;
(Constraint_t::createConstraintAndComplement Constraint_t::Constraints_t constraints
(name, robot_, floorSurfaces, objectSurfaces, margin)); (Constraint_t::createConstraintAndComplement
(name, robot_, floorSurfaces, objectSurfaces, margin));
addNumericalConstraint(std::get<0>(constraints)->function().name(),
std::get<0>(constraints)); addNumericalConstraint(std::get<0>(constraints)->function().name(),
addNumericalConstraint(std::get<1>(constraints)->function().name(), std::get<0>(constraints));
std::get<1>(constraints)); addNumericalConstraint(std::get<1>(constraints)->function().name(),
addNumericalConstraint(std::get<2>(constraints)->function().name(), std::get<1>(constraints));
std::get<2>(constraints)); addNumericalConstraint(std::get<2>(constraints)->function().name(),
// Set security margin to contact constraint std::get<2>(constraints));
assert(HPP_DYNAMIC_PTR_CAST(constraints::ConvexShapeContact, // Set security margin to contact constraint
std::get<0>(constraints)->functionPtr())); assert(HPP_DYNAMIC_PTR_CAST(constraints::ConvexShapeContact,
constraints::ConvexShapeContactPtr_t contactFunction std::get<0>(constraints)->functionPtr()));
(HPP_STATIC_PTR_CAST(constraints::ConvexShapeContact, constraints::ConvexShapeContactPtr_t contactFunction
std::get<0>(constraints)->functionPtr())); (HPP_STATIC_PTR_CAST(constraints::ConvexShapeContact,
contactFunction->setNormalMargin(margin); std::get<0>(constraints)->functionPtr()));
constraintsAndComplements.push_back ( contactFunction->setNormalMargin(margin);
ConstraintAndComplement_t (std::get<0>(constraints), constraintsAndComplements.push_back (
std::get<1>(constraints), ConstraintAndComplement_t (std::get<0>(constraints),
std::get<2>(constraints))); std::get<1>(constraints),
std::get<2>(constraints)));
} else{
using constraints::ComparisonTypes_t;
using constraints::Implicit;
using constraints::Equality;
using constraints::EqualToZero;
std::pair<hpp::constraints::ConvexShapeContactPtr_t,
hpp::constraints::ConvexShapeContactComplementPtr_t>
functions(constraints::ConvexShapeContactComplement::createPair
(name, robot_, floorSurfaces, objectSurfaces));
functions.first->setNormalMargin(margin);
addNumericalConstraint(functions.first->name(),
Implicit::create(functions.first, 5*EqualToZero));
addNumericalConstraint(functions.second->name(),
Implicit::create(functions.second, ComparisonTypes_t
(functions.second->outputSize(), Equality)));
}
} }
void ProblemSolver::createPrePlacementConstraint void ProblemSolver::createPrePlacementConstraint
......
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