Skip to content

Commit

Permalink
Fix multiple calls to add**(Target|Constraint)
Browse files Browse the repository at this point in the history
While the InverseKinematics library was designed to specify all the
targets and constraints **before** the  first call to solve,
apparently for some users it make sense to call again this method
between solve, to change some aspects of the constraints.

While this is not properly documented, this commit make sures
that if the user uses the methods in this way, everything works fine.
  • Loading branch information
traversaro committed Sep 10, 2018
1 parent 874d88d commit e8be1c4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/inverse-kinematics/src/InverseKinematics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,9 @@ namespace iDynTree {
IK_PIMPL(m_pimpl)->m_comHullConstraint_yAxisOfPlaneInWorld = yAxisOfPlaneInWorld;
IK_PIMPL(m_pimpl)->m_comHullConstraint_originOfPlaneInWorld = originOfPlaneInWorld;

// If this method is called again to reconfigure the constraint, the problem needs to be reinitialized
IK_PIMPL(m_pimpl)->m_problemInitialized = false;

return true;
}

Expand Down
8 changes: 8 additions & 0 deletions src/inverse-kinematics/src/InverseKinematicsData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ namespace kinematics {

//add the constraint to the set
std::pair<TransformMap::iterator, bool> result = m_constraints.insert(TransformMap::value_type(frameIndex, frameTransformConstraint));

// If this method is called again to reconfigure the constraint, the problem needs to be reinitialized
IK_PIMPL(m_pimpl)->m_problemInitialized = false;

return result.second;
}

Expand All @@ -195,6 +199,10 @@ namespace kinematics {
if (result.second) {
result.first->second.setTargetResolutionMode(m_defaultTargetResolutionMode);
}

// If this method is called again to reconfigure the constraint, the problem needs to be reinitialized
IK_PIMPL(m_pimpl)->m_problemInitialized = false;

return result.second;
}

Expand Down

0 comments on commit e8be1c4

Please sign in to comment.