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
with rerun_loader_mjcf.MJCFRecorder(logger) as recorder:
    while data.time < 5.0:
        mujoco.mj_step(model, data)
        recorder.record(data)

# Without time (uses frame sequence instead)
with rerun_loader_mjcf.MJCFRecorder(logger, timeline_name="frame") as recorder:
    for _ in range(1000):
        mujoco.mj_step(model, data)
        recorder.record(data, log_time=False)

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.4.0.tar.gz (7.8 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.4.0-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for rerun_loader_mjcf-0.4.0.tar.gz
Algorithm Hash digest
SHA256 b1811912e41caff1efb945f25daf2c6976e12b8af34e083615777b58d29d9cd2
MD5 f6ac4462d5ab385dc3a9b13698d800e3
BLAKE2b-256 93f64b30dd130c744859643aef6fa65f9647938af69f509b10e1d76f6314b167

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rerun_loader_mjcf-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1d8cb4b0314806b074e441d90f466b2f6de5b4809c59260853275f101d2cae06
MD5 70840b74cb986c3d34307aac5da5798e
BLAKE2b-256 49d7904680b0903732e7735609a34f2c652abfafc150cf7e3c77879350aa3ce6

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