Skip to content

base

OnReloadCallback

Bases: Protocol

Called with the model once it has been generated, so a viewer can show it.

ViewerControls

Bases: Protocol

What a viewer's own buttons can ask of Reloaded. The controller implements it, so a button and the same word typed in the terminal do the same thing.

paused property

Python
paused: bool

Whether the run in progress is being held.

speed property

Python
speed: float

The playback speed: a multiple of real time, 0 for stepping by hand, or inf.

rerun

Python
rerun() -> None

Runs the last command again, if nothing is running.

Source code in src/mujoco_mojo/utils/layers/reloaded/backends/base.py
Python
def rerun(self) -> None:
    """Runs the last command again, if nothing is running."""
    ...

ConnectionInfo dataclass

Python
ConnectionInfo(
    url: str,
    tunnel_command: str | None = None,
    warning: str | None = None,
)

How to reach a browser based viewer, shown in the Reloaded terminal UI.

url instance-attribute

Python
url: str

Address to open in a browser on the machine running Reloaded.

tunnel_command class-attribute instance-attribute

Python
tunnel_command: str | None = None

Command to run on a local machine to forward the viewer's port, when Reloaded is on a remote host.

warning class-attribute instance-attribute

Python
warning: str | None = None

Standing caution about the viewer, e.g. that it listens on every network interface without authentication.

ViewerBackend

Bases: Protocol

What Reloaded needs from a viewer.

A backend only shows state. It never owns the command loop, so the terminal UI and the unit tests can drive every backend the same way.

failure property

Python
failure: str | None

Why the viewer stopped when it was not the user closing it, or None.

viewer_lock property

Python
viewer_lock: (
    Callable[[], AbstractContextManager[Any]] | None
)

Lock the RuntimeManager holds while mutating model and data, or None if the viewer works on its own copy.

attach

Python
attach(controls: ViewerControls) -> None

Hands the viewer what its own buttons may ask for. Called once, before start.

Source code in src/mujoco_mojo/utils/layers/reloaded/backends/base.py
Python
def attach(self, controls: ViewerControls) -> None:
    """Hands the viewer what its own buttons may ask for. Called once, before `start`."""
    ...

start

Python
start(state: MjState) -> None

Opens the viewer on the initial model.

Source code in src/mujoco_mojo/utils/layers/reloaded/backends/base.py
Python
def start(self, state: MjState) -> None:
    """Opens the viewer on the initial model."""
    ...

close

Python
close() -> None

Shuts the viewer down and releases its resources.

Source code in src/mujoco_mojo/utils/layers/reloaded/backends/base.py
Python
def close(self) -> None:
    """Shuts the viewer down and releases its resources."""
    ...

is_running

Python
is_running() -> bool

Whether the viewer is still alive, e.g. its window has not been closed.

Source code in src/mujoco_mojo/utils/layers/reloaded/backends/base.py
Python
def is_running(self) -> bool:
    """Whether the viewer is still alive, e.g. its window has not been closed."""
    ...

on_reload

Python
on_reload(state: MjState) -> None

Shows a new or refreshed model. Called once the model is generated and again after a run finishes.

Source code in src/mujoco_mojo/utils/layers/reloaded/backends/base.py
Python
def on_reload(self, state: MjState) -> None:
    """Shows a new or refreshed model. Called once the model is generated and again after a run finishes."""
    ...

sync_hook

Python
sync_hook(
    state: MjState,
    arrows: list[ArrowConfig],
    lines: list[LineConfig],
) -> None

Pushes the current physics state and overlays to the viewer. Called by the RuntimeManager after every step.

Source code in src/mujoco_mojo/utils/layers/reloaded/backends/base.py
Python
def sync_hook(
    self, state: MjState, arrows: list[ArrowConfig], lines: list[LineConfig]
) -> None:
    """Pushes the current physics state and overlays to the viewer. Called by the `RuntimeManager` after every step."""
    ...

pump

Python
pump() -> None

Keeps the viewer responsive while no run is stepping physics, i.e. while idle or paused.

Source code in src/mujoco_mojo/utils/layers/reloaded/backends/base.py
Python
def pump(self) -> None:
    """Keeps the viewer responsive while no run is stepping physics, i.e. while idle or paused."""
    ...

connection_info

Python
connection_info() -> ConnectionInfo | None

How to reach the viewer from a browser, or None for a native window.

Source code in src/mujoco_mojo/utils/layers/reloaded/backends/base.py
Python
def connection_info(self) -> ConnectionInfo | None:
    """How to reach the viewer from a browser, or `None` for a native window."""
    ...