RobotLocomotion / drake

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

[visualization] Poor hydroelastic contact visualization performance #13665

Closed SeanCurtis-TRI closed 3 years ago

SeanCurtis-TRI commented 4 years ago

Problem

Visualization of hydroelastic contact surfaces in drake_visualizer is painfully slow. While part of this may be attributed to compactness of LCM messages or inefficient mesh topologies (e.g., duplicate vertices), the primary cause comes down to how the mesh is expressed to VTK: as a bunch of individual polygons.

Diagnosis

By registering each mesh triangle as its own VTK entity, the rendering of the mesh becomes CPU bound instead of GPU bound. More meshes are more VTK objects where each is processed in a large generic fashion. Instead, if all vertex- and triangle-data were stored as a single mesh, it would be a single object and the GPU would be doing all the heavy lifting.

Solution

Use the data in the LCM message to populate the polydata of a single polygonal object.

DamrongGuoy commented 3 years ago

On my Puget, this example

bazel run //geometry/profiling:contact_surface_rigid_bowl_soft_ball

was captured in these three movies to show how contact visualization performs right now. In the first movie with both contact pressure and contact mesh, I saw only one frame for the entire 10s sim. In the second movie with only contact mesh no pressure, the movie has more frames to show. The third movie hides the contact surface and shows the real time factor about 1.0X.

https://user-images.githubusercontent.com/42557859/104661600-b7d4a800-567d-11eb-8f9b-49a58023f9b2.mp4

https://user-images.githubusercontent.com/42557859/104661604-ba370200-567d-11eb-906f-d1760495a43a.mp4

https://user-images.githubusercontent.com/42557859/104661610-bc995c00-567d-11eb-9bcc-6f9d81423da2.mp4

DamrongGuoy commented 3 years ago

Thanks to @xuchenhan-tri for planning to work on it.

SeanCurtis-TRI commented 3 years ago

Resolved by #14622