Skip to content

MJCF Support

rerun.mjcf

MjcfBody

An MJCF body, which has a frame named after it.

name property
name: str

Name of the body. Unnamed bodies are called body_<id>, and the root is called world.

parent property
parent: str | None

Name of the parent body, or None for the world body.

quaternion_xyzw property
quaternion_xyzw: tuple[float, float, float, float]

Rotation relative to the parent body, when all joints are at their reference value.

A unit quaternion in xyzw order, as Quaternion takes it, unlike MuJoCo's wxyz.

translation property
translation: tuple[float, float, float]

Translation relative to the parent body, when all joints are at their reference value.

joints
def joints() -> list[MjcfJoint]

The joints that move this body relative to its parent, in the order MuJoCo applies them.

MjcfJoint

Bases: _KinematicJoint

An MJCF joint with properties and transform computation.

A joint moves its body relative to the body's parent. A body can have several joints, which MuJoCo applies in order. Each of them moves a frame of its own: a body b with joints j1, j2 and j3 has the intermediate frames b::j1 and b::j2, so that the transforms of its joints chain up from the parent body to b.

Its value is an angle in radians for hinge joints, and a distance in meters for slide joints, like MuJoCo's qpos.

anchor property
anchor: tuple[float, float, float]

The point the joint rotates about, in the body's frame.

axis property

Unit axis of the joint, in the body's frame.

body property
body: str

Name of the body this joint moves.

joint_type property
joint_type: str

Type of the joint (hinge, slide, ball or free).

name property
name: str

Name of the joint. Unnamed joints are called joint_<id>.

parent_body property
parent_body: str | None

Name of the parent of the body this joint moves.

range property
range: tuple[float, float] | None

The lower and upper limit, or None if the joint is not limited.

reference property
reference: float

The value at which the body is in its reference pose (MJCF ref).

compute_transform
def compute_transform(
    value: float, clamp: bool = True
) -> Transform3D

Compute a Transform3D for this joint at the given value.

PARAMETER DESCRIPTION
value

Joint value: an angle in radians for rotating joints, or a distance in meters for sliding joints. Values outside limits are clamped with a warning if clamp is True.

TYPE: float

clamp

Whether to clamp & warn about values outside joint limits.

TYPE: bool DEFAULT: True

RETURNS DESCRIPTION
Transform3D

Transform with rotation, translation, parent_frame, and child_frame ready to log.

compute_transform_columns
def compute_transform_columns(
    values: Sequence[float], *, clamp: bool = True
) -> ComponentColumnList

Compute transforms for this joint at multiple values, returning columnar data for use with send_columns.

PARAMETER DESCRIPTION
values

Joint values: angles in radians for rotating joints, or distances in meters for sliding joints. Values outside limits are clamped with a warning if clamp is True.

TYPE: Sequence[float]

clamp

Whether to clamp & warn about values outside joint limits.

TYPE: bool DEFAULT: True

RETURNS DESCRIPTION
ComponentColumnList

Columnar transform data ready for use with rerun.send_columns.

MjcfTree

Bases: _KinematicTree

An MJCF model with bodies and joints.

The model's name is its model attribute, or else its file name.

Use log_to_recording to log the full model (geometry + static transforms), then animate individual joints by logging archetypes.Transform3D computed via MjcfJoint.compute_transform.

frame_prefix property
frame_prefix: str | None

The frame prefix, if set.

name property
name: str

Name of the model.

bodies
def bodies() -> list[MjcfBody]

Get all bodies, parents before children.

compute_joint_transform_batches
def compute_joint_transform_batches(
    names: Array, values: Array, *, clamp: bool = False
) -> Array

Compute batches of 3D transform components from Arrow list arrays containing joint names and values.

names must be a ListArray with Utf8 values. values must be a ListArray with values castable to Float64.

The output is a ListArray with translation, quaternion, parent_frame, and child_frame fields and the same outer row count as the inputs. Each output row has one transform per named joint, in order.

Note: this is intended as a helper for lens pipelines, where you would usually pipe this output through an additional lens that scatters each batch into final Transform3D component rows.

PARAMETER DESCRIPTION
names

Joint names for each row.

TYPE: Array

values

Joint values for each row.

TYPE: Array

clamp

Whether to clamp & warn about values outside joint limits.

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
Array

Transform batches with one outer row for each input row.

from_file_path staticmethod
def from_file_path(
    path: str | Path,
    entity_path_prefix: str | None = None,
    *,
    frame_prefix: str | None = None,
    static_transform_entity_path: str | None = None,
) -> MjcfTree

Load an MJCF file (.mjcf or .xml) from the given path, along with the files it includes.

PARAMETER DESCRIPTION
path

Path to the MJCF file.

TYPE: str | Path

entity_path_prefix

Optional entity path prefix.

TYPE: str | None DEFAULT: None

frame_prefix

Optional prefix for all frame IDs. Use to load the same model multiple times with unique frames.

TYPE: str | None DEFAULT: None

static_transform_entity_path

Optional entity path to use when logging static transforms. If omitted, defaults to /tf_static. This path is not affected by entity_path_prefix.

TYPE: str | None DEFAULT: None

get_body_by_name
def get_body_by_name(body_name: str) -> MjcfBody | None

Get a body by name.

PARAMETER DESCRIPTION
body_name

Name of the body.

TYPE: str

get_collision_geometry_paths
def get_collision_geometry_paths(
    body: str | MjcfBody,
) -> list[str]

Get the entity paths for all collision geometries of the given body, if any.

PARAMETER DESCRIPTION
body

The body for which to get collision geometry paths, either by name or as an MjcfBody instance.

TYPE: str | MjcfBody

get_joint_body
def get_joint_body(joint: MjcfJoint) -> MjcfBody

Get the body that a joint moves.

PARAMETER DESCRIPTION
joint

The joint whose body to retrieve.

TYPE: MjcfJoint

get_joint_by_name
def get_joint_by_name(joint_name: str) -> MjcfJoint | None

Get a joint by name.

PARAMETER DESCRIPTION
joint_name

Name of the joint.

TYPE: str

get_visual_geometry_paths
def get_visual_geometry_paths(
    body: str | MjcfBody,
) -> list[str]

Get the entity paths for all visual geometries of the given body, if any.

PARAMETER DESCRIPTION
body

The body for which to get visual geometry paths, either by name or as an MjcfBody instance.

TYPE: str | MjcfBody

joints
def joints() -> list[MjcfJoint]

Get all joints in the model.

log_to_recording
def log_to_recording(
    recording: RecordingStream | None = None,
) -> None

Log the full model (geometry + static transforms) to a recording stream.

This can be used as alternative to rerun.log_file_from_path, especially in cases where you need the extra configuration options of loading the model yourself (e.g. frame_prefix for multi-robot setups).

PARAMETER DESCRIPTION
recording

The recording stream to log to. If None, the current active recording is used.

TYPE: RecordingStream | None DEFAULT: None

root_body
def root_body() -> MjcfBody

Get the world body, which is the root of the body tree.

stream
def stream(
    *, include_joint_transforms: bool = True
) -> LazyChunkStream

Return a lazy stream over chunks emitted from this model.

PARAMETER DESCRIPTION
include_joint_transforms

Whether to include the static joint transforms of the model's reference configuration.

TYPE: bool DEFAULT: True