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
[visualization] Support animation playback of hydroelastic contact patches in MeshCat #19142
Comments
With @SeanCurtis-TRI 's help, I looked around Drake and rdeits/meshcat. This is what I found:
I think we will need to combine features from the above code together. There's still an open question of whether we could change the mesh across time. The animation2.html uses a fixed mesh. As I learn more about meshcat, I'll have better ideas. |
I will update hydroelastic_basics.ipynb when we fix this issue of contact-patch playback. |
@dmcconachie-tri said the attached mp4 in the issue description didn't play for him. I attached the GIF file of the same content here. |
@dmcconachie-tri also reported the same symptom in Animations Playbak. The contact patches drifted. They are the very thin sliver of red rectangles, which are hard to see without zooming into the GIF a lot. |
There is also a better idea than #20866 that Jeremy suggested in https://drakedevelopers.slack.com/archives/C43KX47A9/p1706836298149919?thread_ts=1706810068.483669&cid=C43KX47A9
|
Here's an outline of how I recommend to implement this... C++ class Meshcat can operate in three modes:
Any given operation on C++ class Meshcat comes in
We want to maintain the following invariants:
Now imagine the operation SetObject(path=/foo, shape=shape). I'll use the Shape overload as an example, but the same reasoning applies to the other overloads as well (e.g., point cloud, in-memory mesh, line, etc). We want to allow the user to make timed calls to SetObject:
However, the animation concept in threejs doesn't allow timed object addition. Instead, we must add the object untimed and use timing to change the visibility property. Here's the trick: WHEN RECORDING and a timed SetObject is requested, add it to the scene at
Remember that any calls without a Compared to our invariants, this bends the rules a little bit: the SceneNode tree browser will be slightly different when an animation has timed setobject calls, but only in places that users do not typically unfold. It might help to show the above sequence as untimed vs timed operations:
Final note: remember that times are not floats. They are integers where the time is truncated to a specific frame number (based on the fps). We should plan to use those integers in the paths (not the time as a float) to avoid weird round-off and precision problems. We should also only do the property-setting operations in frames that actually change something; there's no need to reset the object in frames where it didn't actually change. I think that proposal meets the invariants. Someone should check me. |
Yes, I believe you're right. |
@jwnimmer-tri, thank you for the idea again. To help me understand better, I have drafted the code in #20959. I'll ask some questions in Reviewable. |
Is your feature request related to a problem? Please describe.
It is very helpful in dynamic simulation that we can playback animation faster or slower after the simulation finishes. Currently we can playback hydroelastic force and moment, but we do not support playback animation of contact patches. It is mentioned as a TODO here.
Describe the solution you'd like
Add
time
parameter to Meshcat::SetTriangleColorMesh(..., time) , so we can change these lines toDescribe alternatives you've considered
Additional context
Right now, the animation playback looks like this. The contact patch (white circle) of the last time step persists and move around the white cylinder in the playback, which is very confusing. It's like we have a ghost contact patch moving around.
2023-04-05_contact_patch_ghost.mp4
The text was updated successfully, but these errors were encountered: