RobotLocomotion / drake

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

Default visualization of simulator graphviz #21068

Open jwnimmer-tri opened 4 months ago

jwnimmer-tri commented 4 months ago

Is your feature request related to a problem? Please describe.

Drake offers a nice function System::GetGraphvizOutput that allows users to view how a Diagram is wired up, e.g., it can show pictures like this:

image

For some kinds of exploration and debugging, this is a critical aid to understanding which is very different than other tools we offer (3D scene viewer, camera image viewer, plots, logs, etc.). It helps explain the data flow, which is especially helpful when simulating and debugging simulations and especially the sim setup code.

Even though this nice tool is available, it can be hard to discover and hard to use. Like all other kinds of visualization we offer, it should be enabled by default, without the user needing to change their code at all.

Anytime there is a problem with a simulation, a user should be able to immediately pull up a picture like this to take a look. They should not need to run a separate program, or change command line flags, or etc.

Describe the solution you'd like

Some tool like AddDefaultVisualization should gain logic to offer this picture easily, without further edits to the code.

If the user could just open http://localhost:7000/simulator.png via Meshcat to see the picture, that would be ideal.

The mechanism doesn't really matter too much. The key point is that it's possible (somehow) without code changes.

Describe alternatives you've considered

Serving the #13874 would be even better (we could make it an interactive debugging), but for now even a single static image would still be a lot better than nothing.

Additional context

Here's an example where we had to add a special command line flag for this, because it wasn't built-in:

https://github.com/RobotLocomotion/drake/blob/d07c3206c3a78f7c7b0937e0c5ce7fb5c6b7718c/examples/hardware_sim/hardware_sim.py#L201-L204

sherm1 commented 4 months ago

Would be nice if MultibodyPlant could be made to use the "split" option always because of the huge number of ports, though I don't think that would be helpful for most other systems. Maybe systems could specify their default options for Graphviz.