Index
runtime
¶
GeneralLoad
¶
Bases: VectorForce, VectorTorque
A 6-DOF force/torque applier.
name
instance-attribute
¶
name: str
Name of the forcing function. Used in data output column naming.
active
class-attribute
instance-attribute
¶
active: bool = True
Whether or not this force should be active.
action_site
instance-attribute
¶
Site on which the forcing function acts.
rel_to_site
class-attribute
instance-attribute
¶
Frame of reference for the calculated force. If None, uses worldbody.
xtion_body
class-attribute
instance-attribute
¶
Body on which the load should be acted on. If None the world will be used.
get_visuals
¶
get_visuals(
mj_model: MjModel, mj_data: MjData
) -> list[ArrowConfig]
Returns a list of arrow configurations for the renderer.
Source code in src/mujoco_mojo/runtime/load.py
Load
¶
Bases: MojoBaseModel, ABC
Base class to build forcing functions off of.
name
instance-attribute
¶
name: str
Name of the forcing function. Used in data output column naming.
active
class-attribute
instance-attribute
¶
active: bool = True
Whether or not this force should be active.
action_site
instance-attribute
¶
Site on which the forcing function acts.
rel_to_site
class-attribute
instance-attribute
¶
Frame of reference for the calculated force. If None, uses worldbody.
resolve_ids
¶
Caches the integer IDs from the compiled MuJoCo model.
calculate
abstractmethod
¶
Calculate the force for the timestep.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mj_model
|
MjModel
|
description |
required |
mj_data
|
MjData
|
description |
required |
Returns:
| Type | Description |
|---|---|
tuple[ndarray, ndarray]
|
tuple[np.ndarray, np.ndarray]: The force and toque vector output. |
Source code in src/mujoco_mojo/runtime/load.py
get_visuals
¶
get_visuals(
mj_model: MjModel, mj_data: MjData
) -> list[ArrowConfig]
Returns a list of arrow configurations for the renderer.
Source code in src/mujoco_mojo/runtime/load.py
PointToPointForce
¶
Bases: Load
Acts along the line-of-sight between two sites.
name
instance-attribute
¶
name: str
Name of the forcing function. Used in data output column naming.
active
class-attribute
instance-attribute
¶
active: bool = True
Whether or not this force should be active.
action_site
instance-attribute
¶
Site on which the forcing function acts.
rel_to_site
class-attribute
instance-attribute
¶
Frame of reference for the calculated force. If None, uses worldbody.
xtion_site
instance-attribute
¶
Site on which the forcing function will apply a reation force. Leave as None to use the worldbody.
This is called xtion to limit confusion between "reaction" and "relative".
magnitude_func
instance-attribute
¶
Func(distance, velocity, initial distance, MjModel, MjData) -> scalar_force. Can be a regular function, lambda, etc.
resolve_ids
¶
Caches the integer IDs from the compiled MuJoCo model.
Source code in src/mujoco_mojo/runtime/load.py
| Python | |
|---|---|
get_visuals
¶
get_visuals(
mj_model: MjModel, mj_data: MjData
) -> list[ArrowConfig]
Returns a list of arrow configurations for the renderer.
Source code in src/mujoco_mojo/runtime/load.py
ideal_spring
classmethod
¶
ideal_spring(
name: str,
action_site: AnySite,
xtion_site: AnySite,
stiffness: float | NamedValue[float] = 0.0,
damping: float | NamedValue[float] = 0.0,
rest_length: float = 0.0,
) -> Self
Standard linear spring-damper (works in both tension and compression).
Source code in src/mujoco_mojo/runtime/load.py
stroke_compression_spring
classmethod
¶
stroke_compression_spring(
name: str,
action_site: AnySite,
xtion_site: AnySite,
stiffness: float | NamedValue[float] = 0.0,
damping: float | NamedValue[float] = 0.0,
preload: float | NamedValue[float] = 0.0,
max_stroke: float | NamedValue[float] = 0.1,
) -> Self
Creates a spring-damper that only acts when the runtime length is between rest_length and (rest_legnth + stroke_length)
Source code in src/mujoco_mojo/runtime/load.py
compression_spring
classmethod
¶
compression_spring(
name: str,
action_site: AnySite,
xtion_site: AnySite,
stiffness: float | NamedValue[float] = 0.0,
damping: float | NamedValue[float] = 0.0,
rest_length: float = 0.0,
) -> Self
Creates a spring-damper that only acts when compressed (dist < rest_length). Useful for bumpers, feet, push-off springs, or end-stops.
Source code in src/mujoco_mojo/runtime/load.py
tension_spring
classmethod
¶
tension_spring(
name: str,
action_site: AnySite,
xtion_site: AnySite,
stiffness: float | NamedValue[float] = 0.0,
damping: float | NamedValue[float] = 0.0,
rest_length: float = 0.0,
) -> Self
Creates a spring-damper that only acts when extended (dist > rest_length). Useful for cables, bungees, or tendons.
Source code in src/mujoco_mojo/runtime/load.py
ScalarForce
¶
Bases: BodyReactionForce
Applies a scalar force along the local X-axis of the action_site.
name
instance-attribute
¶
name: str
Name of the forcing function. Used in data output column naming.
active
class-attribute
instance-attribute
¶
active: bool = True
Whether or not this force should be active.
action_site
instance-attribute
¶
Site on which the forcing function acts.
rel_to_site
class-attribute
instance-attribute
¶
Frame of reference for the calculated force. If None, uses worldbody.
xtion_body
class-attribute
instance-attribute
¶
Body on which the load should be acted on. If None the world will be used.
scalar_func
class-attribute
instance-attribute
¶
scalar_func: Callable[
[float, ndarray, MjModel, MjData], float
] = lambda t, unit_vec, m, d: 0.0
Func(time, action_site x axis unit vector, MjModel, MjData) -> scalar force value.
get_visuals
¶
get_visuals(
mj_model: MjModel, mj_data: MjData
) -> list[ArrowConfig]
Returns a list of arrow configurations for the renderer.
Source code in src/mujoco_mojo/runtime/load.py
ScalarTorque
¶
Bases: BodyReactionForce
Applies a scalar torque along the local X-axis of the action_site.
name
instance-attribute
¶
name: str
Name of the forcing function. Used in data output column naming.
active
class-attribute
instance-attribute
¶
active: bool = True
Whether or not this force should be active.
action_site
instance-attribute
¶
Site on which the forcing function acts.
rel_to_site
class-attribute
instance-attribute
¶
Frame of reference for the calculated force. If None, uses worldbody.
xtion_body
class-attribute
instance-attribute
¶
Body on which the load should be acted on. If None the world will be used.
scalar_func
class-attribute
instance-attribute
¶
scalar_func: Callable[
[float, ndarray, MjModel, MjData], float
] = lambda t, unit_vec, m, d: 0.0
Func(time, action_site x-axis unit vector, MjModel, MjData) -> scalar torque value.
get_visuals
¶
get_visuals(
mj_model: MjModel, mj_data: MjData
) -> list[ArrowConfig]
Returns a list of arrow configurations for the renderer.
Source code in src/mujoco_mojo/runtime/load.py
RuntimeManager
dataclass
¶
RuntimeManager(
signal_manager: SignalManager | None = None,
loads: list[Load] = list(),
proximities: list[Proximity] = list(),
video_recorders: list[VideoRecorder] = list(),
playback_speed: float = 1.0,
_sync_hook: SyncHook | None = None,
_skip_recording: bool = False,
_resolved: bool = False,
)
__exit__
¶
Ensure all telemetry is flushed even if the simulation crashed. Also saves recordings
Source code in src/mujoco_mojo/runtime/runtime_manager.py
resolve
¶
Call this once after mj_loadXML to prime the caches.
step
¶
Calculates forces, integratess physics, and handles telemetry.
Source code in src/mujoco_mojo/runtime/runtime_manager.py
SignalManager
dataclass
¶
SignalManager(
export_path: Path,
batch_size: int = 1000,
record_decimation: int = 1,
_buffer_row_idx: int = 0,
_step_count: int = -1,
_n_cols: int = 0,
)
batch_size
class-attribute
instance-attribute
¶
batch_size: int = 1000
Number of steps before flushing to disk.
record_decimation
class-attribute
instance-attribute
¶
record_decimation: int = 1
How many steps between each recording should be performed.
post
¶
post(
value: float,
category: SignalCategory | str,
subgroups: tuple[str, ...] = (),
*,
attr: str | None = None,
)
Injects a value into the telemetry ledger using a hierarchical namespace.
This method constructs a structured key that the dashboard uses to build a navigable tree view. The naming convention follows a folder-like structure to group related signals (e.g., all axes of a body's position).
Format
Category/Subgroup:Attribute (e.g., "Bodies/Link_1:xpos_x")
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
float
|
The numeric data to record. |
required |
category
|
SignalCategory | str
|
Top level category (e.g., "Bodies") |
required |
subgroups
|
tuple[str, ...]
|
The second-level organizational folders. Defaults to an empty tuple. |
()
|
attr
|
str | None
|
The specific signal or component name (e.g., "qpos" or "x"). Defaults to None. |
None
|
Examples:
| Python Console Session | |
|---|---|
| Python Console Session | |
|---|---|
Source code in src/mujoco_mojo/runtime/signal_manager.py
record
¶
Executes all samplers and advances the buffer index. Flushes if due.
Source code in src/mujoco_mojo/runtime/signal_manager.py
flush
¶
Commits the memory buffer to the output file.
Source code in src/mujoco_mojo/runtime/signal_manager.py
VideoRecorder
dataclass
¶
VideoRecorder(
path: Path,
camera_name: CameraName,
show_loads: bool = False,
show_net_force: bool = False,
show_contacts: bool = False,
show_proximities: bool = False,
fps: int = 30,
width: int = 640,
height: int = 480,
_frames: list = list(),
)
capture_frame
¶
capture_frame(
mj_model: MjModel,
mj_data: MjData,
custom_arrows: list[ArrowConfig],
custom_lines: list[LineConfig],
)
Captures the current state as a video frame.
Source code in src/mujoco_mojo/runtime/video_recorder.py
save
¶
Writes the captured frames to a video file.