https://github.com/mujocolab/g1_spinkick_example
Train a Unitree G1 humanoid to perform a double spin kick using mjlab
https://github.com/mujocolab/g1_spinkick_example
mjlab mujoco mujoco-warp sim2real unitree-g1
Last synced: 3 months ago
JSON representation
Train a Unitree G1 humanoid to perform a double spin kick using mjlab
- Host: GitHub
- URL: https://github.com/mujocolab/g1_spinkick_example
- Owner: mujocolab
- License: apache-2.0
- Created: 2025-10-10T04:23:39.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2025-11-23T00:05:47.000Z (7 months ago)
- Last Synced: 2025-11-23T02:19:30.000Z (7 months ago)
- Topics: mjlab, mujoco, mujoco-warp, sim2real, unitree-g1
- Language: Python
- Homepage:
- Size: 2.92 MB
- Stars: 158
- Watchers: 1
- Forks: 8
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mjlab example: Unitree G1 Double Spin Kick

An example of building on top of [mjlab](https://github.com/mujocolab/mjlab) to
teach a Unitree G1 humanoid to perform a **double spin kick**. The reference
motion comes from Jason Peng's [MimicKit](https://github.com/xbpeng/MimicKit).
**This repository provides:**
- Data conversion script (MimicKit pkl → mjlab csv)
- Full training results and hyperparameters
- Pretrained ONNX checkpoint for deployment
- Deployment instructions for real hardware
> ⚠️ **Disclaimer**
>
> This repository is provided as-is for educational purposes. We do not take any
> responsibility for damage to property or injury to persons that may occur from
> attempting to replicate the results shown here. Please exercise caution and
> good judgement when working with hardware.
## Installation
```bash
git clone https://github.com/mujocolab/g1_spinkick_example.git && cd g1_spinkick_example
uv sync
```
## Data Conversion
Download the spin kick data using the link referenced in the MimicKit
[installation instructions](https://github.com/xbpeng/MimicKit?tab=readme-ov-file#installation).
The conversion script adds smooth transitions from a safe standing pose at the
start and end of the motion to ensure safe deployment. Since the motion is
cyclic, we also repeat it to reach the desired duration.
```bash
# Convert pkl to csv
uv run pkl_to_csv.py \
--pkl-file g1_spinkick.pkl \
--csv-file g1_spinkick.csv \
--duration 2.65 \
--add-start-transition \
--add-end-transition \
--transition-duration 0.5 \
--pad-duration 1.0
# Convert csv to npz
MUJOCO_GL=egl uv run -m mjlab.scripts.csv_to_npz \
--input-file g1_spinkick.csv \
--output-name mimickit_spinkick_safe \
--input-fps 60 \
--output-fps 50 \
--render True
```
This will upload the motion to your wandb registry and create a video showing
the reference motion like the one below:

## Training
Follow the registry creation instructions in the mjlab
[README](https://github.com/mujocolab/mjlab?tab=readme-ov-file#2-motion-imitation).
```bash
MUJOCO_GL=egl CUDA_VISIBLE_DEVICES=0 uv run train \
Mjlab-Spinkick-Unitree-G1 \
--registry-name {your-organization}/{registry-name}/mimickit_spinkick_safe \
--env.scene.num-envs 4096 \
--agent.max-iterations 20_000
```
For full training details and reproducibility, see the
[wandb report](https://api.wandb.ai/links/gcbc_researchers/nfi58457).
## Evaluation
To evaluate your trained policy, you'll need your wandb run path. You can find
this in the run overview. It follows the format
`{your-organization}/{project-name}/{run-id}`, where `run-id` is a unique
8-character identifier.
Once you have your run path, evaluate the policy with:
```bash
uv run play \
Mjlab-Spinkick-Unitree-G1 \
--wandb-run-path {wandb-run-path} \
--num-envs 8
```
## Deployment
We use
[motion_tracking_controller](https://github.com/HybridRobotics/motion_tracking_controller)
to deploy the trained policy. An ONNX file is provided for convenience, though
one will also be generated in your wandb artifacts. Download it and follow the
instructions in the motion_tracking_controller repo.
### Alternative Implementation
An alternative option is available through
[**RoboJuDo**](https://github.com/HansZ8/RoboJuDo), a lightweight deployment
framework designed for **onboard execution** and flexible modular integration.
RoboJuDo supports this mjlab example via the `BeyondmimicPolicy`, allowing
direct use of the provided configuration.
A minimal configuration setup is shown below:
1. **Download** the ONNX model and place it in `assets/models/g1/beyondmimic`.
2. **Edit** the `g1_beyondmimic` config in `robojudo/config/g1/g1_cfg.py` to set
policy name:
```python
@cfg_registry.register
class g1_beyondmimic(RlPipelineCfg):
robot: str = "g1"
env: G1MujocoEnvCfg = G1MujocoEnvCfg()
ctrl: list[KeyboardCtrlCfg] = [KeyboardCtrlCfg()]
policy: G1BeyondMimicPolicyCfg = G1BeyondMimicPolicyCfg(
policy_name="spinkick_safe",
max_timestep=183,
)
```
3. For **real robot deployment**, you may use the `g1_locomimic_beyondmimic` or
`g1_locomimic_beyondmimic_real` config in
`robojudo/config/g1/g1_loco_mimic_cfg.py`, which includes smooth locomotion
interpolation.