Search code examples
drake

Meshcat takes time to load simple geometries


This might be a very silly thing but whenever I run the meshcat visualizer it takes quite a bit of time (~ 1-2 mins) to load up simple geometries like a robot and a block, before actually demonstrating the visualization. Often, if the main python script execution finishes, I don't see the final trajectory visualisation as the meshcat server is no longer up. I have put various sleeps and user inputs to make the script persist, but I was wondering if there was anything I should be aware of in the browser settings/meshcat params that I may not be doing optimally.

Thanks for your support.


Solution

  • The first thing to try is to use meldis. Its primary benefit in this regard is that you can run your simulation once (albeit for a brief time), get all of the loading done, and then if you run the simulation again, meldis persists its state and get down to running the simulation state.

    To do this:

    1. Make sure you configure visualization using some variant of AddDefaultVisualization() or ApplyVisualizationConfig. This will configure Drake to dispatch LCM messages.
    2. Launch meldis in an external process. This documentation provides several alternate means of doing so.

    Then it's a case of running your simulation enough to load the geometry, killing it, and then restarting it.