A Modern Simulation Wrapper for Google DeepMind’s MuJoCo
⚠️ WARNING
This package is currently in its zero-release stage. Class methods and APIs may change without prior notice. Please review the documentation and changelog after each update to stay informed about any modifications.
Add -U flag to upgrade pre-existing library
pip install mujoco-toolboxpip install git+https://github.com/MGross21/mujoco-toolbox.git@mainClick to Expand
Place the following in your requirements.txt or pyproject.toml file.
Expect less frequent, stable releases.
mujoco-toolbox
Expect frequent rolling releases.
git+https://github.com/MGross21/mujoco-toolbox.git@main#egg=mujoco-toolbox
FFMPEG
Required for mediapy dependency
Windows
winget install ffmpeg
ffmpeg -versionLinux
Debian/Ubuntu
sudo apt update && sudo apt install ffmpeg
ffmpeg -versionArch Linux
sudo pacman -Syu ffmpeg
ffmpeg -versionMacOS
Using Homebrew
brew install ffmpeg
ffmpeg -versionUsing MacPorts
sudo port install ffmpeg
ffmpeg -versionBare minimum to run MuJoCo simulation and display result
import mujoco_toolbox as mjtb
mjtb.Simulation("path/to/your/xml").run(render=True).save()The following controllers are available out-of-the-box:
sincossteprandomreal_time(recommended controller for digital twins)
You can import them as follows:
import mujoco_toolbox.controllers as ctrldef foo(model: MjModel, data: MjData,**kwargs):
# Perform logic based on model/data objects
# ie. PID Controllerimport mujoco_toolbox as mjtb
from mujoco_toolbox.controllers import real_time
with mjtb.Simulation("path/to/xml", controller=real_time) as digitaltwin:
digitaltwin.launch(show_menu=False) # Open the simulation window
while True:
digitaltwin.controller(digitaltwin.model, digitaltwin.data, {"mjdata_kwargs": value})See MjData objects here
import mujoco_toolbox as mjtb
mjtb.Simulation("path/to/xml").show()import mujoco_toolbox as mjtb
mjtb.Simulation("path/to/urdf", meshdir="path/to/mesh/files").show() # supports *.stl or *.objSupports full <mujoco>...</mujoco> and <robot>...</robot> structure as well as complete sub-tree structures.
import mujoco_toolbox as mjtb
# Merges: XML & URDF Files, XML & URDF Strings, Sub Tree Structures
mjtb.Simulation("path/to/xml_1", string_xml_var, ..., "path/to/xml_n").show()
⚠️ WARNING
Duplicate sub-tree items with the same name will cause MuJoCo to throw aFatalError.



