🚀 Latest News: A new release (v1.2) just dropped! 🎉
New: LocoMuJoCo now includes SuperMimic and supports real-robot deployment on the AgiBot X2 Ultra and the Unitree G1 through LocoMuJoCo Real.
LocoMuJoCo is an imitation learning benchmark specifically designed for whole-body control.
It features a diverse set of environments, including quadrupeds, humanoids, and (musculo-)skeletal human models,
each provided with comprehensive datasets.
Although primarily focused on imitation learning, LocoMuJoCo also supports custom reward function classes,
making it suitable for pure reinforcement learning as well.
Key Advantages
✅ Supports MuJoCo (single environment) and MJX/MJWarp (parallel environments)
✅ Includes 12 humanoid and 4 quadruped environments, featuring 4 biomechanical human models
✅ Clean single-file JAX algorithms for quick benchmarking (SuperMimic, PPO, GAIL, AMP, DeepMimic)
✅ Combined training and environment into one JIT‑compiled function for lightning‑fast training 🚀
✅ Motion capture datasets (AMASS, LAFAN1, native LocoMuJoCo) retargeted for each humanoid
✅ Robot-to-robot retargeting allows to retarget any existing dataset from one robot to another
✅ Powerful trajectory comparison metrics including dynamic time warping and discrete Fréchet distance, all in JAX
✅ Built-in domain and terrain randomization
✅ Real-robot deployment with LocoMuJoCo Real: deployable training setups for PPO and SuperMimic, and the tools to take a policy to the robot
✅ Modular design: define, swap, and reuse components like observation types, reward functions, terminal state handlers, and domain randomization
✅ Documentation
Installation
LocoMuJoCo requires Python 3.10 or newer. We recommend a fresh environment, for example with conda:
conda create -n loco-mujoco python=3.11
conda activate loco-mujoco
Clone this repo and do an editable installation:
git clone https://github.com/robfiras/loco-mujoco.git
cd loco-mujoco
pip install -e .
By default, this installs the CPU version of JAX. If you want to use JAX on the GPU, you need to install the following:
pip install "jax[cuda12]<=0.10.1,!=0.10.0"
JAX 0.10.0 and 0.10.2 fail to compile SuperMimic's training function on the GPU, so LocoMuJoCo
currently requires jax<=0.10.1,!=0.10.0.
The robot models (about 200 MB) are downloaded automatically the first time you create an environment
and cached in ~/.loco-mujoco-caches/robot_models. On a cluster or in a container you can fetch them ahead of time:
loco-mujoco-download-models
To use a local copy instead, for example on a machine without network access, point LOCOMUJOCO_ROBOT_MODELS_PATH
to the loco_mujoco_models folder of the models repository.
Datasets
LocoMuJoCo provides three sources of motion capture (mocap) data for humanoid environments: default (provided by us), LAFAN1, and AMASS. The first two datasets are available on the LocoMuJoCo HuggingFace dataset repository and will be downloaded and cached automatically for you. AMASS needs to be downloaded and installed separately due to their licensing. See here for more information about the installation.
Other datasets can be used as well. LocoMuJoCo Real shows how to load your own trajectories and how to convert and train on BONES-SEED.
This is how you can visualize the datasets:
from loco_mujoco.task_factories import ImitationFactory, LAFAN1DatasetConf, DefaultDatasetConf, AMASSDatasetConf
# # example --> you can add as many datasets as you want in the lists!
env, traj = ImitationFactory.make("UnitreeH1",
default_dataset_conf=DefaultDatasetConf(["squat"]),
lafan1_dataset_conf=LAFAN1DatasetConf(["dance2_subject4", "walk1_subject1"]),
# if SMPL and AMASS are installed, you can use the following:
#amass_dataset_conf=AMASSDatasetConf(["DanceDB/DanceDB/20120911_TheodorosSourmelis/Capoeira_Theodoros_v2_C3D_poses"])
)
env.play_trajectory(n_episodes=3, n_steps_per_episode=500, render=True)
Speeding up Dataset Loading
LocoMuJoCo only stores datasets with joint positions and velocities to save memory. All other attributes are calculated using forward kinematics upon loading. If you want to speed up the dataset loading, you can define caches for the datasets. This will store the forward kinematics results in a cache file, which will be loaded on the next run:
loco-mujoco-set-all-caches --path <path to cache>
For instance, you could run:
loco-mujoco-set-all-caches --path "$HOME/.loco-mujoco-caches"
Using MJX with the MjWarp backend
LocoMuJoCo’s MJX environments can run either on the standard MJX backend or on the MjWarp backend. Switching to MjWarp can further accelerate parallel simulation on compatible GPUs.
- From the low-level MJX API, pass
use_mjwarp=True(and optionallynconmax/njmax) when creating anMjxenv:
from loco_mujoco.core import Mjx
mjx_env = Mjx(
spec=spec,
actuation_spec=action_spec,
observation_spec=observation_spec,
horizon=1000,
gamma=0.99,
n_envs=100,
use_mjwarp=True, # switch MJX to the MjWarp backend
nconmax=3000, # optional: max number of contacts for warp
njmax=None, # optional: max number of constraints for warp
)
- From high-level factories (e.g.
ImitationFactory), you can forward the same flag:
from loco_mujoco import ImitationFactory
env, traj = ImitationFactory.make(
"MjxUnitreeG1",
default_dataset_conf=dict(task="stepinplace1"),
use_mjwarp=True,
)
For a complete example, see examples/tutorials/02_creating_mjx_env.py.
Real Robot Deployment
LocoMuJoCo Real is the companion repository for taking policies trained in LocoMuJoCo to a real robot. It currently covers the Unitree G1 and the AgiBot X2 Ultra and provides:
- deployable training setups: for each robot an environment with the observations, rewards and sim-to-real randomization it needs, and ready-to-run training configs for motion tracking with PPO and with SuperMimic,
- deployment tools: export of a trained policy to a bundle that runs with only
numpyandmujoco, validation of the bundle against the training environment, rollouts in plain MuJoCo, sim-to-sim over the robot's middleware, and the controller that runs on the robot.
python training/<robot>/train.py # PPO
python training/<robot>/train_supermimic.py # SuperMimic
The video shows a SuperMimic tracking policy on the AgiBot X2 Ultra, on the robot and in simulation. The configs for
training such a policy are in that repository, for the X2
(training/x2/supermimic.yaml)
and for the G1 (training/g1/supermimic.yaml).
The real robot deployment tutorial explains the stages from training to the robot.
Environments
You want a quick overview of all environments available? You can find it here and more detailed in the Documentation.
And stay tuned! There are many more to come ...
Tutorials
We provide a set of tutorials to help you get started with LocoMuJoCo. You can find them in the tutorials folder or with more explanation in the documentation.
If you want to check out training examples of a PPO, GAIL, AMP, or DeepMimic agent, you can find them in the training examples folder. For instance, here is an example of a DeepMimic agent you can train to achieve a human-like walking in all directions, which was trained in 36 min on an RTX 3080 Ti:
Citation
@inproceedings{alhafez2023b,
title={LocoMuJoCo: A Comprehensive Imitation Learning Benchmark for Locomotion},
author={Firas Al-Hafez and Guoping Zhao and Jan Peters and Davide Tateo},
booktitle={6th Robot Learning Workshop, NeurIPS},
year={2023}
}
Metadata
Release files for loco-mujoco 1.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| loco_mujoco-1.2.0.tar.gz | 348.1 kB | Without provenance | Details for loco_mujoco-1.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| loco_mujoco-1.2.0-py3-none-any.whl | Python 3 | none | any | Details for loco_mujoco-1.2.0-py3-none-any.whl |
Total release size: 767.9 kB
Release files / loco_mujoco-1.2.0.tar.gz
| Download URL | loco_mujoco-1.2.0.tar.gz |
|---|---|
| Size | 348.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a5ab1d5003ad072d4862969bef5e6691c660e03f06478162967a666a4d5a2305
|
|
BLAKE2b-256 checksum How to use checksums |
4e5a13e53a7e149ef82fc0fb144c07e9d4cde02259508df6bed4799c3f9afdb8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.4
|
Release files / loco_mujoco-1.2.0-py3-none-any.whl
| Download URL | loco_mujoco-1.2.0-py3-none-any.whl |
|---|---|
| Size | 419.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9736e27f0594e4e8df7c29995f6f61803580bbbef1a74883cba1b7280186da84
|
|
BLAKE2b-256 checksum How to use checksums |
7a1f359c6054f9e6fefb0c38452dfd8e1d81339b072aeeefd861b9dbca34244c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.4
|
Security for loco-mujoco 1.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.