RobotLocomotion / drake

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

MBP has inconsistent port indexing #13530

Closed joemasterjohn closed 4 years ago

joemasterjohn commented 4 years ago

Per drake slack discussion

This gist shows two scenarios where MBP ports are declared in different orders. Specifically:

Both tests then scalar convert a diagram containg a MBP and SceneGraph and try to verify that the index of the geometry_query_input_port is the same for the double and AutoDiffXd versions of the plant. RegisterSceneGraphPreFinalize succeeds while RegisterSceneGraphPostFinalize fails.

Diagram transmogrification assumes port indices remain the same between transmogrified systems, and copies the port connections by index. The result is an invalid Diagram in the case where the transmogrified MBP<AutoDiffXd> has its ports in a different order from the MBP<double> it was converted from.

Diagram of the MBP<double>: double_diagram Subsequent diagram of the converted MBP<AutoDiffXd>: autodiff_diagram

To resolve this, MultibodyPlant should declare all its ports in a consistent order. Possibly by declaring scene graph ports in its constructor?

/cc @amcastro-tri @jwnimmer-tri @sherm1

jwnimmer-tri commented 4 years ago

I think that fixing the plant and failsafeing the framework should be two separate issue numbers.

joemasterjohn commented 4 years ago

Resolved by #13558.