Skip to content
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

Add the possibility to generate animation in MeshcatVisualizer #1211

Merged
merged 1 commit into from
Oct 23, 2024

Conversation

GiulioRomualdi
Copy link
Member

Thanks to this PR it will be possible to generate animation on meshcat and eventually export the static HTML file to add to an external website how is it done in https://sites.google.com/view/dnn-mpc-walking/home-page

This PR does not change the classical usage of the visualizer it only adds a new feature. To enable the functionality the user needs to:

  1. load all the meshes in the visualizer as usual
  2. call the start_recording_animation function
  3. Set the frame associated with the transformation with set_animation_frame
  4. Set the transform as usual for all the frames
  5. Call publish_animation method

Here an example

from idyntree.visualize import MeshcatVisualizer
import numpy as np

viz = MeshcatVisualizer()
viz.load_sphere(0.5, 'sphere', color=[66/255.0, 133/255.0, 244/255.0])
viz.start_recording_animation()

for i in range(100):
    viz.set_animation_frame(i)
    orientation = np.eye(3)
    position = np.array([np.sin(i / 6.0), 0, 0])
    viz.set_primitive_geometry_transform(position, orientation, 'sphere')

viz.publish_animation()

open("website.html", "w").write(viz.viewer.static_html())

@traversaro traversaro merged commit f5af4d6 into master Oct 23, 2024
31 of 37 checks passed
@traversaro traversaro deleted the add_meshcat_animation branch October 23, 2024 08:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants