Search code examples
drake

How to Temporarily Fix Certain Joints in Plant


Partially related to this post, suppose I have a robot with both fixed joints and free joints (ex: separate legs and arms), and I only want to solve InverseKinematics for one of the legs while keeping the other leg and arms fixed as obstacles.

My initial attempt to "fix" the other legs/arms was the following:

  • Ignore their self-collisions, which assumes their current joint configurations were valid
  • AddBoundingBoxConstraint on those joints tightly around their current joint configurations

This works, but significantly increases the runtime. Is there any way to modify the plant/internal tree to do this instead? This should really be speeding up the optimization rather than slowing it down.


Solution

  • Nonlinear programs are finicky, but I also would have thought that both adding bounding box constraints to fix joints, and removing collision constraints should speed up inverse kinematics.

    We do have a few open issues about runtime remodeling of multibodyplant. https://github.com/RobotLocomotion/drake/issues/13291 and https://github.com/RobotLocomotion/drake/issues/12703, for instance.

    Short of that, we did introduce the ability to lock / unlock joints and free-bodies for simulation. It would be a reasonable PR / request to also use MultibodyPlant::EvalJointLockingIndices in the inverse kinematics code to avoid making those decision variables entirely. But I fear that the difference between this and the bounding box constraints should not be very big; probably fixing the joint is putting you into a more troublesome part of the optimization landscape?