Skip to main content

MuJoPy

Table of Contents

Project Motivation

MuJoPy provides pythonic access to MuJoCo models by wrapping the low-level structs of the model in dataclasses and by this deriving a navigable graph of bodies, joints and geoms. By this, downstream usage of robot models, e.g. feature extraction is faster without the need of custom parsing logic for the MuJoCo models.

With RobotGraph() the package also exposes an example of using the MuJoPy wrapper by providing a graph representation alongside of a feature matrix of the model.

Installation

Install the package together with its MuJoCo dependency:

pip install mujopy

For development work inside this repository, install in editable mode with the testing extras:

pip install -e ".[test]"

File Descriptions

  • mujopy/src/mujopy_model/: Core wrappers (Body, Joint, Geom, MuJoPyModel) that expose MuJoCo fields as Python properties.
  • mujopy/src/robot_graph/: Graph utilities built on top of NetworkX, including the RobotGraph and feature extraction pipeline.
  • tests/: PyTest-based unit tests and fixtures covering the main APIs.
  • pyproject.toml: Packaging metadata, dependencies, and tool configuration.

Usage

from pathlib import Path
from mujopy import MuJoPyModel, RobotGraph

# Load a MuJoCo XML and register the default property packs
model = MuJoPyModel(
    xml_path=str(Path("path/to/model.xml")),
    include_world_body=True,
    include_free_joints=False,
)
model.register_default_properties()

# Inspect bodies, joints, and geoms
trunk = model.body(0)
print(trunk.name, trunk.children_ids, trunk.primitive_geoms)

# Build a graph with feature vectors
graph = RobotGraph(
    xml_path=Path("path/to/model.xml"),
    feature_config_path=Path("path/to/feature_config.yml"),
)
print(graph.number_of_nodes(), graph.feature_matrix.shape)

Each wrapper exposes the underlying MuJoCo struct through the mujoco_view attribute—use it when you need direct access to raw MuJoCo fields:

body_view = trunk.mujoco_view  # mujoco.MjDataView for the body
print(body_view.pos)

Registering Custom Properties

Extend the core wrappers with your own read-only properties by registering callables on MuJoPyModel:

from mujopy import MuJoPyModel

def _body_is_not_root(body: Body) -> bool:
        return int(np.asarray(body.mujoco_view.parentid).item()) != body.id

model = MuJoPyModel(xml_path="path/to/model.xml")
MuJoPyModel.register_body_property("_body_is_not_root", is_not_root)
model.register_default_properties()

print(model.body(0).is_not_root)

Licensing

This project is distributed under the MIT License—see the license text in pyproject.toml for details.

Metadata

Release files for mujopy 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mujopy 0.0.1
File Size Uploaded
mujopy-0.0.1.tar.gz 10.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mujopy 0.0.1
File Interpreter ABI Platform
mujopy-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 23.0 kB

Release files / mujopy-0.0.1.tar.gz

Download URL mujopy-0.0.1.tar.gz
Size 10.6 kB
Tags Source
SHA-256 checksum
How to use checksums
f6c45dc90ccb8320f4d67e5b4df3740ed3c18448e82e6fb96f701e4ec127dcfe
BLAKE2b-256 checksum
How to use checksums
2b2d2e80d6bce49558ee565cc0245b4ccf541ab54267bdc942f453b80d6598c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.1

Release files / mujopy-0.0.1-py3-none-any.whl

Download URL mujopy-0.0.1-py3-none-any.whl
Size 12.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
12d18756fc76b10e55d65ee75a57679b7d2255f847a8f9ced3f152d6f77584b7
BLAKE2b-256 checksum
How to use checksums
eb33f74c66def7735f63522f7e31941e22b37eef2c66f52a27128e7e727d1474
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.1

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page