RobotLocomotion / drake

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

Enhance MeshcatVisualizer to offer collision geometry checkbox #17688

Closed jwnimmer-tri closed 1 year ago

jwnimmer-tri commented 2 years ago

In #17595, we added collision geometry visualization to meldis. We should offer the likewise feature to MeshcatVisualizer (including the alpha sliders and enable/disable checkbox control).

Details to follow.

jwnimmer-tri commented 2 years ago

The current meldis implementation lives at https://github.com/RobotLocomotion/drake/blob/master/bindings/pydrake/visualization/meldis.py.

The place where we add the new feature to MeshcatVisualizer is https://github.com/RobotLocomotion/drake/blob/master/geometry/meshcat_visualizer.cc.

Or possibly a better answer would be to create two MeshcatVisualizer systems. I need to consider a few design options and then will reply again here.

RussTedrake commented 2 years ago

This would be great. For completeness: once it is implemented, we will also want to remove the manual implementation of this feature from the "authoring multibody simulation" tutorial.

jwnimmer-tri commented 2 years ago

(1) Run meldis to see how this feature works. There are tickyboxes for collision vs visual, and sliders for visual alpha and collision alpha. Do this using a simulation or example or tutorial, not the model_visualizer. Probably hardware_sim is not an awful demo to use.

(2) It's okay for the tickybox names for in the scene tree to differ between meldis and this tool. Neither tree of names is that stellar anyway currently.

(3) For how to actually implement this..

Option (a) is to teach ApplyVisualizationConfig to MeshcatVisualizer.AddToBuilder twice (plus some detritus for the sliders).

Option (b) is to teach a single MeshcatVisualizer object to publish both sets of geometries, and add the sliders itself.

I think maybe option (a) will be good enough, and in any case should be cheap to attempt. I'd like to see if that one works, as the first try.

(4) No matter (a) or (b), I think the correct place to add the alpha slider logic will be MeshcatVisualizer. It will call meshcat.AddSlider, poll for updates, and adjust the alphas to suit (see logic in meldis for a hint). Probably we add bool MeshcatVisualizerParams.add_alpha_sider = false to the params as a convenient opt-in/out toggle. Sliders could be a second PR, if we like.