RobotLocomotion / drake

Model-based design and verification for robotics.
https://drake.mit.edu
Other
3.16k stars 1.24k forks source link

Improve the error message for IK with collision. #21554

Open hongkai-dai opened 3 weeks ago

hongkai-dai commented 3 weeks ago

If the IK constructor doesn't take in the plant context, or takes in the wrong plant context, and imposes distance related constraint, then warn the user about the plant_context in the constructor.

Resolves #21541


This change is Reviewable

jwnimmer-tri commented 3 weeks ago

It seems like to me if the check and advice were done in the constraint object constructor, instead of the IK wrapper sugar, that would catch more mistakes (for users who create the constraint objects directly).

In fact, I see that they already have a CheckPlantIsConnectedToSceneGraph helper call, so I'm not sure why we're copy-pasting that logic again. Wasn't the bug just that the error message from CheckPlantIsConnectedToSceneGraph needs a bit more text?

jwnimmer-tri commented 3 weeks ago

The first thing I would try is using troubleshooting.md instead of putting so many words into the exception message.

We already have this FAQ entry: https://drake.mit.edu/troubleshooting.html#mbp-unconnected-query-object-port

Maybe we could add more detail there related to IK (including all of the kinds of examples you gave above), and add the hyperlink to the exception message instead of lots of text?