Skip to main content

A Rerun data loader for MJCF (MuJoCo XML) files

Project description

rerun-loader-mjcf

CI

A Rerun external data loader for MJCF (MuJoCo XML) files.

https://github.com/user-attachments/assets/a9f95ed6-1441-4ce0-bef8-c3fb1e720d56

Simulating fourier_n1 and boston_dynamics_spot from mujoco_menagerie:

uv run rerun-loader-mjcf --simulate mujoco_menagerie/fourier_n1/scene.xml
uv run rerun-loader-mjcf --simulate mujoco_menagerie/boston_dynamics_spot/scene.xml

https://github.com/user-attachments/assets/36aab5aa-134f-49a3-92d4-efb6b61e9354

Loading all robots from mujoco_menagerie

Installation

pip install rerun-loader-mjcf

Usage

CLI

rerun-loader-mjcf robot.xml

To run a real-time simulation loop:

rerun-loader-mjcf robot.xml --simulate

Or run directly without installing:

uvx rerun-loader-mjcf robot.xml

Python API

import mujoco
import rerun as rr
import rerun_loader_mjcf

model = mujoco.MjModel.from_xml_path("robot.xml")
data = mujoco.MjData(model)

rr.init("mjcf_viewer", spawn=True)
logger = rerun_loader_mjcf.MJCFLogger(model)

rr.set_time("frame", sequence=0)
logger.log_model()

data.qpos[0] += 0.5
mujoco.mj_forward(model, data)

rr.set_time("frame", sequence=1)
logger.log_data(data)

Recording Simulations

For efficient batch recording of simulations, use MJCFRecorder:

import mujoco
import rerun as rr
import rerun_loader_mjcf

model = mujoco.MjModel.from_xml_path("robot.xml")
data = mujoco.MjData(model)

rr.init("simulation", spawn=True)

logger = rerun_loader_mjcf.MJCFLogger(model)
logger.log_model()

# With simulation time (default: uses duration=data.time)
with rerun_loader_mjcf.MJCFRecorder(logger) as recorder:
    while data.time < 5.0:
        mujoco.mj_step(model, data)
        recorder.record(data)

# With explicit sequence index
with rerun_loader_mjcf.MJCFRecorder(logger, timeline_name="frame") as recorder:
    for i in range(1000):
        mujoco.mj_step(model, data)
        recorder.record(data, sequence=i)

# With explicit timestamp
with rerun_loader_mjcf.MJCFRecorder(logger, timeline_name="sim_time") as recorder:
    while data.time < 5.0:
        mujoco.mj_step(model, data)
        recorder.record(data, timestamp=data.time)

Lint

uv run pre-commit run -a

Credits

Inspired by rerun-loader-python-example-urdf.

What's Next

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rerun_loader_mjcf-0.5.0.tar.gz (7.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rerun_loader_mjcf-0.5.0-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file rerun_loader_mjcf-0.5.0.tar.gz.

File metadata

  • Download URL: rerun_loader_mjcf-0.5.0.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.14

File hashes

Hashes for rerun_loader_mjcf-0.5.0.tar.gz
Algorithm Hash digest
SHA256 45d73dabf9207db1c9c448baeeb09bee0b299f4b069a3961cded4bb4c7fc73d2
MD5 b3f5ba60ece32769f0a24fddba4c7f8b
BLAKE2b-256 2fca7494f0bf85699b9244c933dc741b63d31ded42e8e0c46304675e4b7fee89

See more details on using hashes here.

File details

Details for the file rerun_loader_mjcf-0.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for rerun_loader_mjcf-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0b489c0cafb7c8b5ec558a717d8d3888837c3ac2a47e54f1f581e214500d3c11
MD5 b3d21ac36138356e6ee1c0422bb7a1c1
BLAKE2b-256 2e16c4340d0090d476418caae0e9794e0e519b6ab610111fbfdbb84ba6a05279

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page