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 realtime rate chart to meldis #17661

Closed
Tracked by #16486
jwnimmer-tri opened this issue Aug 1, 2022 · 2 comments · Fixed by #21534
Closed
Tracked by #16486

Add realtime rate chart to meldis #17661

jwnimmer-tri opened this issue Aug 1, 2022 · 2 comments · Fixed by #21534
Assignees
Labels
component: geometry illustration What and how geometry gets communicated to external visualizers priority: medium type: feature request

Comments

@jwnimmer-tri
Copy link
Collaborator

When a MeshcatVisualizer is connected directly to a Simulator, it can show a nice realtime rate chart (see #16981 for a screencap video).

We should enhance meldis to display the same chart, using the LCM message times to populate the rate.

@jwnimmer-tri jwnimmer-tri added type: feature request priority: low component: geometry illustration What and how geometry gets communicated to external visualizers labels Aug 1, 2022
@jwnimmer-tri jwnimmer-tri self-assigned this Aug 1, 2022
@jwnimmer-tri jwnimmer-tri added this to Backlog (80%) in #dynamics-dev Aug 1, 2022
@jwnimmer-tri jwnimmer-tri removed this from Backlog (80%) in #dynamics-dev Aug 9, 2022
@DamrongGuoy
Copy link
Contributor

Thank you! Now I also understand the 73 rtr% means 73% realtime rate.

This feature would be very helpful when we try to speed up our simulators or evaluate new codes.

@jwnimmer-tri jwnimmer-tri added this to Backlog (20%) in #dynamics-dev Jan 24, 2023
@jwnimmer-tri jwnimmer-tri moved this from Backlog (20%) to Backlog in #dynamics-dev Jan 30, 2023
@jwnimmer-tri
Copy link
Collaborator Author

jwnimmer-tri commented Feb 14, 2023

FYI a solution outline (untested):

--- a/bindings/pydrake/visualization/_meldis.py
+++ b/bindings/pydrake/visualization/_meldis.py
@@ -143,6 +143,13 @@ class _ViewerApplet:
             link_path = f"{self._path}/{robot_num}/{link_name}"
             pose = self._to_pose(message.position[i], message.quaternion[i])
             self._meshcat.SetTransform(path=link_path, X_ParentPath=pose)
+        sim_time = message.timestamp * 1e-6
+        wall_time = time.time()
+        if self._prior_times is not None:
+            sim_delta = sim_time - self._prior_times(0)
+            wall_delta = wall_time - self._prior_times(1)
+            self._meshcat.SetRealtimeRate(sim_delta / wall_delta)
+        self._prior_times = (sim_time, wall_time)
         if self._waiting_for_first_draw_message:
             self._waiting_for_first_draw_message = False
             self._build_links()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: geometry illustration What and how geometry gets communicated to external visualizers priority: medium type: feature request
Projects
Archived in project
4 participants