-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Meshcat in C++ #13038
Comments
Assigning to @mntan3 for further investigation. |
@manuelli said he found that the numpy -> msgpack conversion is extremely slow out of the box (in both directions), but that this package implements a much faster alternative. fwiw, I think the right solution is probably to write our mechcat visualizer in c++. |
FTR, Erwin has a thin c++ meshcat zmq code here: https://github.com/google-research/tiny-differentiable-simulator/blob/297dc2232780396c7f63cb8be97a5c8490ebc653/examples/meshcat_zmq.h |
Planned resolution is to move to c++. |
Related to RussTedrake/manipulation#145 |
fwiw -- i'm planning to spike-test a c++ implementation over the next few days. |
I'll leave some notes here to document some of the relevant decisions. Websockets not ZMQ. meshcat-python uses a separate ZMQ server to relay between python and the browser: C++ websocket libraries. I've now explored a handful of websocket libraries that we could potentially use in drake c++. This list was helpful. Taking a number of factors, such as licensing and light dependencies, I ended up looking most closely at:
|
Basic C++ design is currently:
My current PR strategy is:
Then we can add more geometry / bells and whistles incrementally. |
This is the first of a series of PRs that will provide Meshcat as a visualizer in C++. The design and PR strategy is documented on in RobotLocomotion#13038. This is the first PR: Meshcat proof of life. Starts the server, demonstrates that clients can connect, and just sends one type of message to show that data can flow. Reviewers can focus on the build system and websocket server details. The dependencies added here are all quite lightweight, and properly licensed. And at the end of the PR train, we will likely want to deprecate meshcat-python, and eventually remove the pip dependencies that come along with it.
For a more mature testing strategy, I'm currently trying:
Alternatives could include:
|
Test strategy update: I've got the following working well with a minimal nodejs setup:
The full script is here: meshcat_test.js |
FYI My rough impression from very quick glances in the past was that node and npm were extremely difficult to make sufficiently hermetic for use Drake. You might want to de-risk that before walking too far down this path. Maybe https://github.com/bazelbuild/rules_nodejs has already resolved this by now, but I don't think we know for sure yet.
Why is this option not the best answer? We don't acceptance test |
This is the first of a series of PRs that will provide Meshcat as a visualizer in C++. The design and PR strategy is documented in RobotLocomotion#13038. This is the first PR: Meshcat proof of life. Starts the server, demonstrates that clients can connect, and just sends one type of message to show that data can flow. Reviewers can focus on the build system and websocket server details. The dependencies added here are all quite lightweight, and properly licensed. And at the end of the PR train, we will likely want to deprecate meshcat-python, and eventually remove the pip dependencies that come along with it.
This is the first of a series of PRs that will provide Meshcat as a visualizer in C++. The design and PR strategy is documented in RobotLocomotion#13038. This is the first PR: Meshcat proof of life. Starts the server, demonstrates that clients can connect, and just sends one type of message to show that data can flow. Reviewers can focus on the build system and websocket server details. The dependencies added here are all quite lightweight, and properly licensed. And at the end of the PR train, we will likely want to deprecate meshcat-python, and eventually remove the pip dependencies that come along with it.
Adds test coverage, and therefore moves Meshcat out of dev. Per discussion with jwnimmer-tri, the strategy here is to provide a reasonable coverage of the c++ code (CI runs most all of the code and verifies it doesn't segfault; avoiding coverage of the throw and join methods is fine). I explored more elaborate testing mechanisms (documented in RobotLocomotion#13038) using nodejs. This could add value downstream, but adding nodejs support to bazel might be a big upfront (and even maintenance) cost for relatively small gain. As jwnimmer-tri points out, we don't provide that level of coverage for DrakeVisualizer.
Adds test coverage, and therefore moves Meshcat out of dev. Per discussion with jwnimmer-tri, the strategy here is to provide a reasonable coverage of the c++ code (CI runs most all of the code and verifies it doesn't segfault; avoiding coverage of the throw and join methods is fine). I explored more elaborate testing mechanisms (documented in RobotLocomotion#13038) using nodejs. This could add value downstream, but adding nodejs support to bazel might be a big upfront (and even maintenance) cost for relatively small gain. As jwnimmer-tri points out, we don't provide that level of coverage for DrakeVisualizer.
Adds test coverage, and therefore moves Meshcat out of dev. Per discussion with jwnimmer-tri, the strategy here is to provide a reasonable coverage of the c++ code (CI runs most all of the code and verifies it doesn't segfault). I explored more elaborate testing mechanisms (documented in RobotLocomotion#13038) using nodejs. This could add value downstream, but adding nodejs support to bazel might be a big upfront (and even maintenance) cost for relatively small gain. As jwnimmer-tri points out, we don't provide that level of coverage for DrakeVisualizer.
Adds test coverage, and therefore moves Meshcat out of dev. Per discussion with jwnimmer-tri, the strategy here is to provide a reasonable coverage of the c++ code (CI runs most all of the code and verifies it doesn't segfault). I explored more elaborate testing mechanisms (documented in RobotLocomotion#13038) using nodejs. This could add value downstream, but adding nodejs support to bazel might be a big upfront (and even maintenance) cost for relatively small gain. As jwnimmer-tri points out, we don't provide that level of coverage for DrakeVisualizer.
This is the first of a series of PRs that will provide Meshcat as a visualizer in C++. The design and PR strategy is documented in #13038. This is the first PR: Meshcat proof of life. Starts the server, demonstrates that clients can connect, and just sends one type of message to show that data can flow. Reviewers can focus on the build system and websocket server details. The dependencies added here are all quite lightweight, and properly licensed. And at the end of the PR train, we will likely want to deprecate meshcat-python, and eventually remove the pip dependencies that come along with it.
Adds test coverage, and therefore moves Meshcat out of dev. Per discussion with jwnimmer-tri, the strategy here is to provide a reasonable coverage of the c++ code (CI runs most all of the code and verifies it doesn't segfault). I explored more elaborate testing mechanisms (documented in RobotLocomotion#13038) using nodejs. This could add value downstream, but adding nodejs support to bazel might be a big upfront (and even maintenance) cost for relatively small gain. As jwnimmer-tri points out, we don't provide that level of coverage for DrakeVisualizer.
Adds test coverage, and therefore moves Meshcat out of dev. Per discussion with jwnimmer-tri, the strategy here is to provide a reasonable coverage of the c++ code (CI runs most all of the code and verifies it doesn't segfault). I explored more elaborate testing mechanisms (documented in RobotLocomotion#13038) using nodejs. This could add value downstream, but adding nodejs support to bazel might be a big upfront (and even maintenance) cost for relatively small gain. As jwnimmer-tri points out, we don't provide that level of coverage for DrakeVisualizer.
Resolves RobotLocomotion#13038 Adds MeshcatVisualizer
Resolves RobotLocomotion#13038 Adds MeshcatVisualizer
Adds MeshcatVisualizer Resolves RobotLocomotion#13038
Adds MeshcatVisualizer Resolves RobotLocomotion#13038
Adds MeshcatVisualizer Resolves RobotLocomotion#13038
Adds MeshcatVisualizer Resolves RobotLocomotion#13038
Adds MeshcatVisualizer Resolves RobotLocomotion#13038
Adds MeshcatVisualizer Resolves RobotLocomotion#13038
Adds MeshcatVisualizer Resolves RobotLocomotion#13038
Adds MeshcatVisualizer Resolves RobotLocomotion#13038
Adds MeshcatVisualizer Resolves RobotLocomotion#13038
Adds MeshcatVisualizer Resolves RobotLocomotion#13038
Adds MeshcatVisualizer Resolves #13038
Follow-up to RobotLocomotion#13038. Also makes the meshcat_visualizer_test.py more robust (test_warnings_and_errors could fail if the default zmq_url was already consumed)
Follow-up to RobotLocomotion#13038. Also makes the meshcat_visualizer_test.py more robust (test_warnings_and_errors could fail if the default zmq_url was already consumed)
Follow-up to #13038. Also makes the meshcat_visualizer_test.py more robust (test_warnings_and_errors could fail if the default zmq_url was already consumed)
Issue Description
When visualizing a model with many links, I was seeing that meshcat was slowing down the simulator significantly and the drake visualizer doesn't. It would be nice if this were at least documented if in fact meshcat is just slower than Drake Visualizer.
Example test script and model here to replicate:
https://gist.github.com/mntan3/be02a1c410a0830f2ddb656aaf6403e2
After running the script for 10 seconds, it should print out the simulator rate. I was observing something like a rate of 0.8 for drake visualizer and 0.6 for meshcat on my computer
Initial discussions from slack:
https://drakedevelopers.slack.com/archives/C43KX47A9/p1586538504017800
sean.curtis 2 hours ago
I think you may just be victim of python loops vs C++ loops.
mntan 2 hours ago
Just to clarify, so you're saying that meshcat is written in python and drake_vis is written in c++, so that's why meshcat is going to be slower?
sean.curtis 2 hours ago
Essentially -- there may be other reasons, but that will be one wall you won't be able to get around. And the key, particularly, is the work that has to be done in a Drake System to translate Drake state to be consumed by the visualizer.
You might try collecting timing on the publish method of the mesh cat visualizer -- easy enough to do in python. I bet most of the time lost is spent right there.
eric.cousineau 1 hour ago
I think this may be good to track in an issue. @mntan Do you feel comfortable porting this to a Drake issue?
eric.cousineau 1 hour ago
My guess is it might be slow due to mesh conversion for sending it over the wire?
The text was updated successfully, but these errors were encountered: