Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ build/
*__pycache__/
*logs/
*outputs/
dataset/
models/
models/
261 changes: 150 additions & 111 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,153 +1,192 @@
# EngineAI-Lab
# T800 Huabu BoxingFrame AMP

**EngineAI Lab** is a python package for training and deploying policies for EngineAI Robots using Isaac Lab and Isaac Sim.
这个仓库当前主要用于训练 T800 的 boxing-frame 滑步 AMP 策略。

|Training| Sim2Sim |Deploy|
|--------|--------|--------|
![training](./docs/training.gif)|![sim2sim](./docs/sim2sim.gif)|<img src="./docs/deploy.gif" height="180"/>
## 环境与安装

# Structure
先按 [Isaac Lab 官方文档](https://isaac-sim.github.io/IsaacLab/) 安装兼容版本的 Isaac Sim 和 Isaac Lab,然后在仓库根目录安装本项目:

```bash
python -m pip install -e .
```
engineai-lab
├── config
├── dataset
│ ├── config
│ └── data
├── scripts
└── source
└── engineai_lab
├── algorithms
├── assets
│ └── pm01
│ ├── meshes
│ └── urdf
├── robots
├── tasks
│ └── velocity
│ ├── config
│ │ └── pm01
│ └── mdp
└── utils
```

## QUICKSTART

### 1. Create a Conda Environment

Create and activate a new environment with Python 3.11:

```bash
conda create -n engineai_lab python=3.11
conda activate engineai_lab
```

### 2. Install Prerequisites

- **Install Isaac Sim**

Follow the official installation guide: [Isaac Lab - Pip Installation](https://isaac-sim.github.io/IsaacLab/main/source/setup/installation/pip_installation.html#installing-dependencies).

*Since you've already created the engineai_lab environment, follow the guide from "Installing Dependencies" up to (but not including) the "Installing Isaac Lab" section.*
所有命令都应从仓库根目录运行。训练需要支持 CUDA 的 NVIDIA GPU;显存不足时请降低 `--num_envs`。

## 当前默认设置

- 默认训练轮数:`200000`
- 默认环境数:`4096`
- 速度命令坐标系:boxing frame
- boxing frame yaw offset:`1.03 rad`
- 命令范围:`lin_vel_x = [-2.0, 3.0]`,`lin_vel_y = 0.0`,`ang_vel_z = [-2.0, 2.0]`
- 数据集:`dataset/config/t800_dataset_huabu_forward_aligned_with_turn.yaml`,包含 forward-aligned、backward 和 turn 数据
- terrain:使用 terrain generator,但 level 锁在 `0`,不做 terrain curriculum
- domain randomization:默认关闭;`AllRand` task 打开默认 T800 随机化
- policy / critic 网络:`[512, 256, 128]`
- action distribution:默认 tanh-squashed Gaussian,raw action 范围约为 `[-3, 3]`
- reset/default pose:tj `rl_amp_huabu/ready.yaml` 的准备姿态
- entropy coef:tanh `0.008`,Gaussian `0.004`
- action target:先按关节 scale 加到 default pose,再按 URDF joint limit clip
- 双臂:live action,但 target 夹在 default `±0.2 rad`,并用强 anchor 拉住
- AMP:`no_arm_joint_vel`,100Hz 两帧 pair,单帧 36 维
- final reward:`0.7 * style + 0.3 * task`
- style weight:`6.0`
- tracking:`track_lin_vel_xy_boxing_frame_exp` weight `6.0`,sigma `4`;yaw tracking weight `4.0`,sigma `4`
- `leg_joint_position`:只在低速/静止命令下启用,阈值 `0.15`
- `foot_position` / `feet_orientation` / `foot_stumble` / `feet_slide`:权重为 `0.0`
- `feet_contact` / `feet_air_time` / `feet_air_time_dense`:关闭
- discriminator:每个 PPO iteration 更新一次,mini-batches 为 `4`,lr 跟随 policy adaptive lr,`disc_lr = clamp(0.5 * policy_lr, 1e-5, 1e-3)`

## Task

前进后退优先使用 Task 1 和 2。

| Task | 用途 |
| --- | --- |
| `Flat-AMP-T800-Huabu-BoxingFrame-ClampedArmYaw-v0` | Tanh actor,ClampedArmYaw 基线、tj ready reset/default pose、no-arm 100Hz pair AMP、turn 数据、无随机化 |
| `Flat-AMP-T800-Huabu-BoxingFrame-ClampedArmYaw-AllRand-v0` | ClampedArmYaw + 默认 T800 domain randomization |
| `Flat-AMP-T800-Huabu-BoxingFrame-ClampedUpperYaw-v0` | ClampedArmYaw 基线,但 torso/双臂/head 都按 default `±0.2 rad` target clip,并用强 anchor 拉住 |
| `Flat-AMP-T800-Huabu-BoxingFrame-SoftUpperYaw-v0` | 默认 yaw 命令采样,只把上半身改成小 action scale + tight target clip |
| `Flat-AMP-T800-Huabu-BoxingFrame-GaussianSoftUpperYaw-v0` | Gaussian actor + 默认 yaw 命令采样 + SoftUpper |
| `Flat-AMP-T800-Huabu-BoxingFrame-GaussianSoftUpperYaw-ForwardAligned-v0` | Gaussian actor + 默认 yaw 命令采样 + SoftUpper + forward_aligned 数据集 |
| `Flat-AMP-T800-Huabu-BoxingFrame-SoftUpperYaw-ForwardAligned-CmdMatched-v0` | Tanh SoftUpper + forward_aligned 数据集 + 按 `(vx, wz)` command 相似度采样 AMP expert frame |
| `Flat-AMP-T800-Huabu-BoxingFrame-SoftUpperYaw-ForwardAligned-CmdConditioned-v0` | CmdMatched + discriminator 输入额外拼接 `(vx, wz)`,即 `D(s, s', c)` |
| `Flat-AMP-T800-Huabu-BoxingFrame-SoftUpperYaw-ForwardAligned-HeadingHold-v0` | Tanh SoftUpper + forward_aligned 数据集 + 直线命令 heading hold |
| `Flat-AMP-T800-Huabu-BoxingFrame-GaussianClampedArmYaw-v0` | 标准 Gaussian actor + ClampedArmYaw |
| `Flat-AMP-T800-Huabu-BoxingFrame-GaussianClampedArmYaw-AllRand-v0` | GaussianClampedArmYaw + 默认 T800 domain randomization |

## 训练命令

Tanh ClampedArmYaw:

- **Clone & Setup Isaac Lab**

Clone the repository and switch to the recommended branch:

```bash
git clone https://github.com/isaac-sim/IsaacLab.git
cd IsaacLab
git checkout 4df6560e
./isaaclab -i rsl_rl # Install rsl-rl dependency
```

We highly recommend using the main branch`(4df6560e)` of Isaac Lab, as it can support rsl-rl-lib >= 5.0 and Isaac Sim >= 5.0 .

### 3. Install this Package
```bash
CUDA_VISIBLE_DEVICES=0 python scripts/train.py \
--task=Flat-AMP-T800-Huabu-BoxingFrame-ClampedArmYaw-v0 \
--num_envs 4096 \
--headless \
--run_name clamped_arm_yaw
```

Once the prerequisites are set up, install the package in editable mode:
Tanh ClampedArmYaw + 全随机化:

```bash
pip install -e .
CUDA_VISIBLE_DEVICES=1 python scripts/train.py \
--task=Flat-AMP-T800-Huabu-BoxingFrame-ClampedArmYaw-AllRand-v0 \
--num_envs 4096 \
--headless \
--run_name clamped_arm_yaw_allrand
```

## Usage
Tanh ClampedUpperYaw,上半身按双臂的方式约束:

### Supported Robots

This repository currently supports the following environments from the EngineAI Robots family:
```bash
CUDA_VISIBLE_DEVICES=1 python scripts/train.py \
--task=Flat-AMP-T800-Huabu-BoxingFrame-ClampedUpperYaw-v0 \
--num_envs 4096 \
--headless \
--run_name clamped_upper_yaw
```

|Robot| Task |Description|
|--------|--------|--------|
PM01|`Flat-PM01-v0`|Basic flat-terrain locomotion
PM01|`Flat-AMP-PM01-v0`|AMP-based motion imitation on flat terrain
Tanh SoftUpperYaw,默认命令采样:

*More robots and environments are coming soon!*
```bash
CUDA_VISIBLE_DEVICES=0 python scripts/train.py \
--task=Flat-AMP-T800-Huabu-BoxingFrame-SoftUpperYaw-v0 \
--num_envs 4096 \
--headless \
--run_name soft_upper_yaw
```

### Training a Policy
Gaussian SoftUpperYaw,默认命令采样:

```
python scripts/train.py --task=Flat-PM01-v0 --num_envs 4096 --headless --run_name <name>
python scripts/play.py --task=Flat-PM01-v0 --num_envs 128 --load_run <name>
```bash
CUDA_VISIBLE_DEVICES=2 python scripts/train.py \
--task=Flat-AMP-T800-Huabu-BoxingFrame-GaussianSoftUpperYaw-v0 \
--num_envs 4096 \
--headless \
--run_name gaussian_soft_upper_yaw
```

### Evaluating a Policy
Gaussian SoftUpperYaw + forward_aligned 数据集,默认命令采样:

```bash
CUDA_VISIBLE_DEVICES=2 python scripts/train.py \
--task=Flat-AMP-T800-Huabu-BoxingFrame-GaussianSoftUpperYaw-ForwardAligned-v0 \
--num_envs 4096 \
--headless \
--run_name gaussian_soft_upper_yaw_forward_aligned
```
python scripts/train.py --task=Flat-AMP-PM01-v0 --num_envs 4096 --headless --run_name <name>
python scripts/play.py --task=Flat-AMP-PM01-v0 --num_envs 128 --load_run <name>
```

Replace `<name>` with the name of your training run (found in logs/rsl_rl/).

### Deployment
Tanh SoftUpperYaw + forward_aligned 数据集,AMP expert 按 `(vx, wz)` command 相似度采样:

To deploy a trained policy on real hardware, convert it to the MNN format for efficient inference.
```bash
CUDA_VISIBLE_DEVICES=2 python scripts/train.py \
--task=Flat-AMP-T800-Huabu-BoxingFrame-SoftUpperYaw-ForwardAligned-CmdMatched-v0 \
--num_envs 4096 \
--headless \
--run_name soft_upper_yaw_forward_aligned_cmd_matched
```

#### 1. Export PyTorch Policy to ONNX
Tanh SoftUpperYaw + forward_aligned 数据集,command-matched sampling + `D(s, s', c)`:

(Ensure your training script supports ONNX export)
```bash
CUDA_VISIBLE_DEVICES=2 python scripts/train.py \
--task=Flat-AMP-T800-Huabu-BoxingFrame-SoftUpperYaw-ForwardAligned-CmdConditioned-v0 \
--num_envs 4096 \
--headless \
--run_name soft_upper_yaw_forward_aligned_cmd_conditioned
```

#### 2. Build [MNN-Converter](https://mnn-docs.readthedocs.io/en/latest/start/quickstart_cpp.html?highlight=mnn+converter)
Tanh SoftUpperYaw + forward_aligned 数据集 + 直线 heading hold:

```bash
git clone https://github.com/alibaba/mnn
cd mnn
mkdir build && cd build
cmake .. -DMNN_BUILD_CONVERTER=ON
make -j8
CUDA_VISIBLE_DEVICES=2 python scripts/train.py \
--task=Flat-AMP-T800-Huabu-BoxingFrame-SoftUpperYaw-ForwardAligned-HeadingHold-v0 \
--num_envs 4096 \
--headless \
--run_name soft_upper_yaw_forward_aligned_heading_hold
```

#### 3. Convert ONNX into MNN
Gaussian actor + ClampedArmYaw:

```bash
./MNNConvert -f ONNX \
--modelFile path_to_your_policy.onnx \
--MNNModel your_policy.mnn \
--bizCode MNN
CUDA_VISIBLE_DEVICES=2 python scripts/train.py \
--task=Flat-AMP-T800-Huabu-BoxingFrame-GaussianClampedArmYaw-v0 \
--num_envs 4096 \
--headless \
--run_name gaussian_clamped_arm_yaw
```

For detailed instructions on integrating the MNN model with EngineAI robots, see:
[engineai_robotics_native_sdk](https://github.com/engineai-robotics/engineai_robotics_native_sdk).
Gaussian actor + ClampedArmYaw + 全随机化:

## Support
```bash
CUDA_VISIBLE_DEVICES=3 python scripts/train.py \
--task=Flat-AMP-T800-Huabu-BoxingFrame-GaussianClampedArmYaw-AllRand-v0 \
--num_envs 4096 \
--headless \
--run_name gaussian_clamped_arm_yaw_allrand
```

If you have any questions about using this repository, we're here to help!
## Play 命令

- **Report Issues**: Found a bug or have a feature request. Please open a new issue on our [GitHub Issues](https://github.com/engineai-robotics/engineai_lab/issues) page.
- **Email Us**: For general inquiries or collaboration opportunities, feel free to reach out at [info@engineai.com.cn](mailto:info@engineai.com.cn).
播放 checkpoint 时使用 `--checkpoint`,不是 `--load_checkpoint`。

## License
```bash
python scripts/play.py \
--task=Flat-AMP-T800-Huabu-BoxingFrame-ClampedArmYaw-v0 \
--num_envs 1 \
--load_run <run_dir> \
--checkpoint <checkpoint_file.pt> \
--keyboard \
--keyboard_vx_step 0.1 \
--keyboard_vy_step 0.0 \
--keyboard_wz_step 0.1
```

EngineAI-Lab is released under [BSD-3 License](LICENSE).
键盘控制是增量式的:按一次增加或减少一个 step,松手后命令会保持;按 `L` 清零命令。

## Acknowledgement
## 数据

This repository is built upon the support and contributions of the following open-source projects. Special thanks to:
公开仓库包含 AMP 配置和部分 `.npz` 动作数据。数据清单位于 `dataset/config/`,路径相对于清单文件解析。

- [**IsaacLab**](https://github.com/isaac-sim/IsaacLab) — The foundational framework for training and running simulation experiments.
- [**rsl_rl**](https://github.com/leggedrobotics/rsl_rl) — High-performance reinforcement learning library for legged robots.
- [**AMP_for_hardware**](https://github.com/escontra/AMP_for_hardware) — Implementation of Adversarial Motion Priors (AMP) for sim-to-real transfer.
- [**BeyondMimic**](https://github.com/HybridRobotics/whole_body_tracking) — Inspiration for project structure and valuable feature implementations.
- [**MNN**](https://github.com/alibaba/mnn) — Lightweight, high-performance inference engine for on-device deployment.
- [**engineai_robotics_native_sdk**](https://github.com/engineai-robotics/engineai_robotics_native_sdk) — Official SDK for deploying policies on EngineAI robotic hardware.
发布或再分发动作数据、机器人 URDF/mesh 之前,请确认你拥有公开这些内容的权利,并在需要时补充独立的数据或资产许可证。
2 changes: 0 additions & 2 deletions dataset/config/dataset.yaml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
motions:
- folder: ../data/forward_aligned
- folder: ../data/huabu_Fast_B_npz_0609_tran
- folder: ../data/npz_turn_0602_1_30hz
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed dataset/data/locomotion.npz
Binary file not shown.
Binary file added dataset/data/npz_turn_0602_1_30hz/Turn_L_105.npz
Binary file not shown.
Binary file added dataset/data/npz_turn_0602_1_30hz/Turn_L_120.npz
Binary file not shown.
Binary file added dataset/data/npz_turn_0602_1_30hz/Turn_L_135.npz
Binary file not shown.
Binary file added dataset/data/npz_turn_0602_1_30hz/Turn_L_15.npz
Binary file not shown.
Binary file added dataset/data/npz_turn_0602_1_30hz/Turn_L_150.npz
Binary file not shown.
Binary file added dataset/data/npz_turn_0602_1_30hz/Turn_L_165.npz
Binary file not shown.
Binary file added dataset/data/npz_turn_0602_1_30hz/Turn_L_180.npz
Binary file not shown.
Binary file added dataset/data/npz_turn_0602_1_30hz/Turn_L_30.npz
Binary file not shown.
Binary file added dataset/data/npz_turn_0602_1_30hz/Turn_L_45.npz
Binary file not shown.
Binary file added dataset/data/npz_turn_0602_1_30hz/Turn_L_60.npz
Binary file not shown.
Binary file added dataset/data/npz_turn_0602_1_30hz/Turn_L_75.npz
Binary file not shown.
Binary file added dataset/data/npz_turn_0602_1_30hz/Turn_L_90.npz
Binary file not shown.
Binary file added dataset/data/npz_turn_0602_1_30hz/Turn_R_105.npz
Binary file not shown.
Binary file added dataset/data/npz_turn_0602_1_30hz/Turn_R_120.npz
Binary file not shown.
Binary file added dataset/data/npz_turn_0602_1_30hz/Turn_R_135.npz
Binary file not shown.
Binary file added dataset/data/npz_turn_0602_1_30hz/Turn_R_15.npz
Binary file not shown.
Binary file added dataset/data/npz_turn_0602_1_30hz/Turn_R_150.npz
Binary file not shown.
Binary file added dataset/data/npz_turn_0602_1_30hz/Turn_R_165.npz
Binary file not shown.
Binary file added dataset/data/npz_turn_0602_1_30hz/Turn_R_180.npz
Binary file not shown.
Binary file added dataset/data/npz_turn_0602_1_30hz/Turn_R_30.npz
Binary file not shown.
Binary file added dataset/data/npz_turn_0602_1_30hz/Turn_R_45.npz
Binary file not shown.
Binary file added dataset/data/npz_turn_0602_1_30hz/Turn_R_60.npz
Binary file not shown.
Binary file added dataset/data/npz_turn_0602_1_30hz/Turn_R_75.npz
Binary file not shown.
Binary file added dataset/data/npz_turn_0602_1_30hz/Turn_R_90.npz
Binary file not shown.
Loading