Pythonic wrappers for MuJoCo models and Graph representations.
Project description
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 theRobotGraphand 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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mujopy-0.0.1.tar.gz.
File metadata
- Download URL: mujopy-0.0.1.tar.gz
- Upload date:
- Size: 10.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f6c45dc90ccb8320f4d67e5b4df3740ed3c18448e82e6fb96f701e4ec127dcfe
|
|
| MD5 |
9308e9d6657f2a0bd9f55c9a5c57fd68
|
|
| BLAKE2b-256 |
2b2d2e80d6bce49558ee565cc0245b4ccf541ab54267bdc942f453b80d6598c8
|
File details
Details for the file mujopy-0.0.1-py3-none-any.whl.
File metadata
- Download URL: mujopy-0.0.1-py3-none-any.whl
- Upload date:
- Size: 12.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
12d18756fc76b10e55d65ee75a57679b7d2255f847a8f9ced3f152d6f77584b7
|
|
| MD5 |
5a1bd491fd58551344e41e2a9f02f23c
|
|
| BLAKE2b-256 |
eb33f74c66def7735f63522f7e31941e22b37eef2c66f52a27128e7e727d1474
|