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.
quaternion_xyzw
property
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 relative to the parent body, when all joints are at their reference value.
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
The point the joint rotates about, in the body's frame.
range
property
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
TYPE:
|
clamp
|
Whether to clamp & warn about values outside joint limits.
TYPE:
|
| 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
|
Whether to clamp & warn about values outside joint limits.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ComponentColumnList
|
Columnar transform data ready for use with |
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.
compute_joint_transform_batches
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:
|
values
|
Joint values for each row.
TYPE:
|
clamp
|
Whether to clamp & warn about values outside joint limits.
TYPE:
|
| 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. |
entity_path_prefix
|
Optional entity path prefix.
TYPE:
|
frame_prefix
|
Optional prefix for all frame IDs. Use to load the same model multiple times with unique frames.
TYPE:
|
static_transform_entity_path
|
Optional entity path to use when logging static transforms.
If omitted, defaults to
TYPE:
|
get_body_by_name
Get a body by name.
| PARAMETER | DESCRIPTION |
|---|---|
body_name
|
Name of the body.
TYPE:
|
get_collision_geometry_paths
get_joint_body
Get the body that a joint moves.
| PARAMETER | DESCRIPTION |
|---|---|
joint
|
The joint whose body to retrieve.
TYPE:
|
get_joint_by_name
Get a joint by name.
| PARAMETER | DESCRIPTION |
|---|---|
joint_name
|
Name of the joint.
TYPE:
|
get_visual_geometry_paths
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
TYPE:
|
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:
|