Skip to content

About

A MuJoCo-based MJLab development environment and simulation toolkit for ROBOTIS robots.

Resources

Stars

6 stars

Watchers

0 watching

Forks

Repository files navigation

cyclo_mjlab

MuJoCo MJLab Python Linux platform License

Overview

cyclo_mjlab is a research-oriented repository built on MJLab and MuJoCo. It provides reinforcement learning environments, task configurations, and motion-processing tools for developing locomotion and motion-imitation policies for the ROBOTIS K1 humanoid robot.

The repository currently provides:

  • Velocity: flat-ground velocity-tracking locomotion
  • Mimic: Dance1 and Dance2 reference-motion tracking
  • Automatic generation of params/sim2real.yaml when training starts
  • Automatic export of exported/policy.onnx and exported/policy.pt during play

Important

This repository currently uses MJLab 1.6.1, MuJoCo 3.11.0, and Python 3.12.

Locomotion

Locomotion demo

Motion imitation

Motion-imitation demo

Installation (Docker)

Docker provides a consistent environment with the required Python packages, MuJoCo libraries, and GPU configuration pre-installed. Conda and a host Python environment are not required.

Prerequisites

  • Docker Engine with Docker Compose
  • NVIDIA GPU with an appropriate NVIDIA driver
  • NVIDIA Container Toolkit
  • Git and access to this repository

Steps

  1. Clone the repository with its submodules:

    git clone --recurse-submodules git@github.com:ROBOTIS-GIT/cyclo_mjlab.git
    cd cyclo_mjlab

    If the repository was cloned without submodules, initialize them separately:

    git submodule update --init --recursive
  2. Build the Docker image when needed and start the container:

    ./docker/container.sh start
  3. Enter the running container:

    ./docker/container.sh enter

After entering the container, the training and playback commands below can be run directly from /workspace/cyclo_mjlab.

Docker commands

Command Description
./docker/container.sh build Build or update the image using the build cache
./docker/container.sh start Build if missing, check image compatibility, and start and verify the container
./docker/container.sh recreate Check the current image, recreate the container, and verify its runtime and CUDA
./docker/container.sh enter Open an interactive shell in the running container
./docker/container.sh stop Stop the container
./docker/container.sh logs Follow the container logs
./docker/container.sh clean Remove the container and image while preserving cache volumes

The Docker image includes:

  • Python 3.12
  • MJLab 1.6.1
  • MuJoCo and MuJoCo Warp 3.11.0
  • Warp 1.14.0
  • Runtime dependencies pinned with hashes in requirements.lock

The default image/container names are cyclo-mjlab:latest and cyclo_mjlab. The image carries LABEL version="1.0.0" to identify its release. This label is metadata; compatibility checks use the actual installed runtime versions.

The project source and logs/ directory are shared with the host, so training results remain available after the container is removed.

Upgrading an existing Docker environment

Release 1.0.0 requires Python 3.12 and MJLab 1.6.1. Images built for the previous Python 3.11/MJLab 1.2 environment are incompatible. Updating the checkout does not update an existing image, even when its tag is latest.

After updating the checkout, finish or stop any training or playback before replacing the container, then run on the host:

git submodule update --init --recursive
./docker/container.sh build
./docker/container.sh recreate
./docker/container.sh enter

build updates the image using the build cache; recreate replaces the container using that image. Recreating preserves the source bind mount, training logs, and named cache volumes, but discards changes stored only in the old container's writable layer. Keep the same CYCLO_MJLAB_IMAGE and CYCLO_MJLAB_CONTAINER overrides, if used.

Both start and recreate check the image against this checkout's pyproject.toml before changing containers. An incompatible image causes the command to fail with rebuild instructions. After startup, the container's runtime and CUDA are checked again; failures are reported without declaring the environment ready. Driver or GPU-access failures require fixing the host's NVIDIA setup rather than simply rebuilding the image.

To run checks manually inside the container:

python docker/check_environment.py        # Runtime versions and imports
python docker/check_environment.py --gpu  # Also execute a CUDA tensor operation

These checks verify the runtime, not training convergence or individual tasks.

Try Examples

Velocity

Train

python scripts/reinforcement_learning/train.py Cyclo-Velocity-Flat-K1-Rev1-v0 \
  --env.scene.num-envs 4096

Play

python scripts/reinforcement_learning/play.py Cyclo-Velocity-Flat-K1-Rev1-v0 \
  --checkpoint-file logs/rsl_rl/k1_velocity/<run>/model_<iteration>.pt \
  --num-envs 1

Mimic

Train Dance1

python scripts/reinforcement_learning/train.py Cyclo-Mimic-K1-Rev1-Dance1 \
  --env.scene.num-envs 4096

Train Dance2

python scripts/reinforcement_learning/train.py Cyclo-Mimic-K1-Rev1-Dance2 \
  --env.scene.num-envs 4096

Play Dance1

python scripts/reinforcement_learning/play.py Cyclo-Mimic-K1-Rev1-Dance1 \
  --checkpoint-file logs/rsl_rl/k1_mimic/<run>/model_<iteration>.pt \
  --num-envs 1

To display the reference trajectory next to the trained policy during playback:

python scripts/reinforcement_learning/play.py Cyclo-Mimic-K1-Rev1-Dance1 \
  --checkpoint-file logs/rsl_rl/k1_mimic/<run>/model_<iteration>.pt \
  --num-envs 1 \
  --reference-ghost-offset 1.4,0,0

Play Dance2

python scripts/reinforcement_learning/play.py Cyclo-Mimic-K1-Rev1-Dance2 \
  --checkpoint-file logs/rsl_rl/k1_mimic/<run>/model_<iteration>.pt \
  --num-envs 1

Replace <run> and <iteration> with the timestamped run directory and model iteration to use.

Motion Utilities

The motion tools convert K1 CSV motion data into the MuJoCo-ordered NPZ format and validate or replay the converted trajectory:

python scripts/tools/motion/csv_to_npz.py --help
python scripts/tools/motion/replay_npz.py --help

License

This repository is licensed under the Apache License 2.0.

Third-party components

About

A MuJoCo-based MJLab development environment and simulation toolkit for ROBOTIS robots.

Resources

Stars

6 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages