unilab.visualization

Visualization and playback helpers.

class unilab.visualization.SnapshotPlaybackSession[source]

Bases: object

Cache physics snapshots during a trial; render them to video afterwards.

Parameters:
__init__(env, *, frame_state_getter=None, overlay_getter=None, render_spacing=None, width=1280, height=720, num_processes=8)[source]
Parameters:
property snapshots: tuple[ndarray, ...]

The cached physics states, in capture order.

snapshot()[source]

Cache one physics snapshot (and the current overlays, if configured).

Return type:

ndarray

clear()[source]

Drop all cached snapshots and overlays (call between trials).

Return type:

None

render_snapshots(*, output_video, overlay_getter=None, camera=None, fps=None, on_frame=None)[source]

Render cached snapshots to output_video and return its path.

overlay_getter here is evaluated once per cached frame at render time and overrides the snapshot-time overlays captured through the constructor getter; prefer the constructor overlay_getter for state-coupled overlays. camera is normalized through CameraCfg.from_kwargs() (unknown keys fail closed). on_frame receives (frame_index, frame) after rendering and may return a modified frame. Returns None when the host cannot render off-screen (a warning is printed by the renderer).

Parameters:
Return type:

str | None

unilab.visualization.camera_cfg_from_training(training_cfg)[source]

Assemble the typed playback camera config from a training owner config.

Hydra training.cam_* fields keep their names; this helper is the single normalization point so unknown keys fail closed at the unisim boundary instead of being silently ignored.

Parameters:

training_cfg (Any)

Return type:

CameraCfg

unilab.visualization.render_play_mode(env, *, sim_backend, initialize, step, num_steps, output_video=None, render_spacing=None, render_offset_mode=None, headless=None, record_video=None, frame_state_getter=None, camera_kwargs=None, debug_overlay_getter=None, on_frame=None)[source]

Run playback through the env/backend playback contract.

sim_backend is retained for older call sites; backend selection now belongs to env.run_playback() and concrete backend implementations.

Parameters:
  • sim_backend (str)

  • initialize (Callable[[], ObsT])

  • step (Callable[[ObsT], ObsT])

  • num_steps (int | None)

  • output_video (str | Path | None)

  • render_spacing (float | None)

  • render_offset_mode (str | None)

  • headless (bool | None)

  • record_video (bool | None)

  • frame_state_getter (Callable[[], np.ndarray] | None)

  • camera_kwargs (CameraCfg | dict[str, Any] | None)

  • debug_overlay_getter (DebugOverlayGetter | None)

  • on_frame (Callable[[int, np.ndarray], np.ndarray | None] | None)

Return type:

str | None

Modules

debug_primitives

Interactive-viewer injection for unisim.backend.base.DebugPrimitive.

interactive_playback

Shared core for interactive policy playback entrypoints.

playback

Playback rendering compatibility entrypoint.

playback_session

Embeddable snapshot-cache + deferred-render playback session.

teaser

Render the packaged MotrixSim teaser scene.