A general Python interface class for robot simulations using MuJoCo.
Project description
MuJoCo Robot
A general Python interface for robot simulations using MuJoCo. Its public API
mirrors pybullet_robot so that controllers written
against that backend can be run here with minimal changes. MujocoRobot is a single object to
load, introspect, control, and read state from a robot, implemented directly on MjModel +
MjData.
Installation
Requires Python >= 3.10 and
mujoco >= 3.2.
pip install mujoco_robot
pip install "mujoco_robot[ik]" # optional whole-body IK backend (mink)
From source:
git clone https://github.com/justagist/mujoco_robot && cd mujoco_robot
pip install -e .
Quickstart
import numpy as np
from mujoco_robot import MujocoRobot
from mujoco_robot.utils.robot_loader_utils import get_mjcf_from_awesome_robot_descriptions
robot = MujocoRobot(
mjcf_path=get_mjcf_from_awesome_robot_descriptions("panda_mj_description"),
ee_names=["hand"],
run_async=False, # step manually
render=True, # launch the passive viewer (needs a display)
)
robot.set_position_control_mode()
target = robot.get_actuated_joint_positions()
target[0] += 0.5
while robot.is_viewer_running():
robot.set_joint_positions(target)
robot.step()
Features
- Load an MJCF/URDF file, or wrap an existing
(model, data); assemble a world (ground, light, props, force-torque sensors) with theMjSpechelpers inmujoco_robot.utils.model_builder. - Introspect: name<->id maps for bodies, joints, actuators, sites, geoms, and sensors, with
per-joint
qpos/dofaddressing. - Lifecycle: manual
step()or a background stepping thread, an optional passive viewer, joint/base resets, and place-on-ground. - State: joint, base, and link/site pose and velocity (quaternions as
[x, y, z, w]), the geometric Jacobian, gravity-compensation torques, and aget_robot_statessnapshot. - Control: position control via the model's actuators, and torque/impedance control via
data.qfrc_applied, with a PVT-PD command and position/torque mode switching. - Contacts and force-torque sensing, plus cosmetics / domain-randomisation helpers (transparency, per-geom collision, dynamics editing).
- Inverse kinematics:
differential_ikfor a single frame (from mujoco_robot.ik import differential_ik);minkfor whole-body (optional[ik]).
Examples
Runnable demos in examples/ (each takes --headless to run without the viewer):
Joint Position Control
KUKA iiwa14 follows a joint-space sinusoid (position control).
Task Space Control
Panda traces a circle with Cartesian impedance control.
Measuring Contact Forces using FT Sensor
Contact wrench visualised as the robot presses on a block.
Single arm Inverse Kinematics
UR5e tracks a moving target with differential_ik.
Whole body IK (via mink -- needs pip install "mujoco_robot[ik]")
Go1 whole-body squat demo by doing IK for all four feet and body simultaneously.
Design notes
- Quaternions: the external API uses
[x, y, z, w](scipy convention); values are converted to MuJoCo's[w, x, y, z]only at the boundary. - Angles: joint positions, velocities, and limits are in radians (a compiled model always
stores radians, regardless of the MJCF
compiler anglesetting). - Control: writes
data.ctrlwhen the model has actuators, otherwise falls back todata.qfrc_appliedwith a Python PD loop. - Fixed vs floating base: a structural free joint (added via
MjSpec), not a load-time flag. - Sensors: force-torque sensors are declared up front (
ft_sensor_links); the toggle only gates reading, since MuJoCo sensors are compile-time.
Development
pip install -e ".[dev]" # test + lint + build tooling
ruff check .
pytest -q
License
MIT (c) Saif Sidhik
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 mujoco_robot-0.1.0.tar.gz.
File metadata
- Download URL: mujoco_robot-0.1.0.tar.gz
- Upload date:
- Size: 34.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b6634278d174af83254c9893498dceac1b3c5929576e69d8865cbb420503706
|
|
| MD5 |
f286afe67b707a34b7f813a96107e936
|
|
| BLAKE2b-256 |
be7be82ed77f2d883dbd3d0296ec2e96532e78a5a08f8e23b9df1c279ff3569c
|
Provenance
The following attestation bundles were made for mujoco_robot-0.1.0.tar.gz:
Publisher:
publish.yml on justagist/mujoco_robot
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mujoco_robot-0.1.0.tar.gz -
Subject digest:
1b6634278d174af83254c9893498dceac1b3c5929576e69d8865cbb420503706 - Sigstore transparency entry: 2084300701
- Sigstore integration time:
-
Permalink:
justagist/mujoco_robot@efcdb73f9c21afc532d3efdd5874ec458c187ae5 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/justagist
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@efcdb73f9c21afc532d3efdd5874ec458c187ae5 -
Trigger Event:
push
-
Statement type:
File details
Details for the file mujoco_robot-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mujoco_robot-0.1.0-py3-none-any.whl
- Upload date:
- Size: 26.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
20bf0bef5b110e77fc017f190e55236d6f941bda0fed300b9a0f3f8ab6e8d9d5
|
|
| MD5 |
4ae8ccef461740ae9c138e96621df324
|
|
| BLAKE2b-256 |
7e30b2e14eda468f811ebb63fc43075bc0bb47ac05c06f4364177f0e56b41dda
|
Provenance
The following attestation bundles were made for mujoco_robot-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on justagist/mujoco_robot
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mujoco_robot-0.1.0-py3-none-any.whl -
Subject digest:
20bf0bef5b110e77fc017f190e55236d6f941bda0fed300b9a0f3f8ab6e8d9d5 - Sigstore transparency entry: 2084300715
- Sigstore integration time:
-
Permalink:
justagist/mujoco_robot@efcdb73f9c21afc532d3efdd5874ec458c187ae5 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/justagist
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@efcdb73f9c21afc532d3efdd5874ec458c187ae5 -
Trigger Event:
push
-
Statement type: