RobotLocomotion / drake

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

[multibody] MultibodyTree performance improvement epic #18442

Open sherm1 opened 1 year ago

sherm1 commented 1 year ago

Per discussion with @amcastro-tri, we would like to perform some major surgery on MultibodyTree to achieve these goals:

There is some apparent low-hanging fruit to be exploited:

Performance work should be backed by timings taken on the same computers. Cassie bench's mass matrix, inverse dynamics, and forward dynamics make good targets.

sherm1 commented 1 year ago

[Capturing a 1:1 discussion w/Alejandro]

Thoughts on how to present multibody modeling elegantly

  1. User defines Plant structure via Links and Joints, producing a directed (parent->child) graph, plus some disconnected Links. Call this LinkJointGraph.
  2. At Finalize() (or any other time by request) we produce a forest-of-spanning-trees model of the LinkJointGraph, with depth-first coordinate assignments. Call this SpanningForestModel (or some better name). Should have an API for forest info.
  3. Augment the Plant structure with additional elements (added free Joints, shadow Links, added constraints) to use as a uniform interface to those elements for users who care (we already do this with floating Joints). The augmented elements are easily removed when we remodel.
  4. Use MultibodyKernel for the tight, efficient Featherstone-ish thing that only takes basic numerical data structures and computes kinematics, inverse/forward dynamics, etc. Figure out how to make that public
    • no context!
    • no systems::

Both LinkJointGraph and SpanningForestModel have nice public APIs for users to query.

MultibodyTree should then be thought of more like MultibodyPlantImpl (consider renaming). Its job is to implement an efficient computational representation of the SpanningForest (which essentially replaces the MultibodyTopology stuff), creating a MultibodyKernel devoted entirely to fast computation.

Here is a sketch of a LinkJointGraph with a loop being modeled as a spanning tree and an augmented LinkJointGraph:

image