Add a Viewer-to-Sim Snapshot channel and convert relevant messages.

The ViewerEndpoint can now send Snapshot messages to the SimEndpoint. The SimEndpoint has a new method, `get_viewer_snapshots`, to retrieve these. Thsi channel will be used for UI state needed for the simulation (e.g., `MjOption` and `StepControl`).

PiperOrigin-RevId: 940981799
Change-Id: Ib9bd6ad848cd5479bc49492a34fddd82569cb09f
This commit is contained in:
Matija Kecman
2026-07-01 03:20:32 -07:00
committed by Copybara-Service
parent 2012646711
commit a1b0d2c933
2 changed files with 22 additions and 6 deletions
@@ -113,8 +113,8 @@ class ModelEvent(Event):
@dataclasses.dataclass(frozen=True)
class OptionEvent(Event):
"""An event that transports updated MuJoCo model options."""
class MjOptionSnapshot(Snapshot):
"""A snapshot sending mjOption state from viewer to sim each frame."""
opt: mujoco.MjOption
@@ -128,8 +128,8 @@ class PerturbEvent(Event):
@dataclasses.dataclass(frozen=True)
class StepControlEvent(Event):
"""An event carrying the full step control state from the viewer to the sim."""
class StepControlSnapshot(Snapshot):
"""A snapshot sending step control state from viewer to sim each frame."""
pause_state: sim.PauseState
speed: float