RobotLocomotion / drake

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

[multibody] Remove duplicated free body APIs #19269

Open xuchenhan-tri opened 1 year ago

xuchenhan-tri commented 1 year ago

MultibodyPlant has a list of "free body" APIs that used to be the preferred way to interact with free bodies. This has changed since #18390 introduced a floating joint between world and all free bodies. With that, we should interact with free bodies using the associated joint's API as we do with all other MultibodyPlant degrees of freedom because the dual body/joint representation can be error prone (e.g. #19106 fixed by #19230). Instead, MultibodyPlant can provide sugar that retrieves the floating joint associated with the body if it is indeed floating.

This idea originated from a discussion in #19230. cc @jwnimmer-tri @sherm1 @joemasterjohn

jwnimmer-tri commented 1 year ago

To expand a little bit -- there are lot of functions available for joints, e.g., configuring locking, damping, limits, etc. At the moment, only a fraction of those appear in the MbP's "free body" APIs section. Rather than offer an incomplete subset of the Joint functions on MbP directly, we should separate the concerns. MbP should be able to give the user the Joint associated with a free body, and then the user can call any and all Joint functions directly.

While doing this porting if we find that there is a very common use case where the two function calls instead of one makes a big difference, we can consider keeping the extra sugar. The nominal choice, though, should be to deprecate and remove all of the extra functions, unless there is a specific reason why not.