underactuated
underactuated copied to clipboard
Update compass gait exercise to be compatible with GetInfeasibleConstraints
In the exercise the compass gait MultibodyPlant is translated ToAutoDiffXd in order to use the MultibodyPlant methods to build constraints for an optimization. This however makes GetInfeasibleConstraints fail because MultibodyPlant computations always returns AutoDiffXd, even when you pass them floats.
The solution is to either:
- Keep two copies of the plant around. The original
compass_gaitand thecompass_gait_autodiff = compass_gait.ToAutoDiffXd(), and use the correct one based on whetherisInstance(vars[0], AutoDiffXd). - Use
return autodiffToValueMatrix(...)for the non-autodiff case.
See also piazza post 285.