maniskill-elirobots 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- maniskill_elirobots-0.1.0/PKG-INFO +274 -0
- maniskill_elirobots-0.1.0/README.md +247 -0
- maniskill_elirobots-0.1.0/pyproject.toml +96 -0
- maniskill_elirobots-0.1.0/pyproject.toml.orig +92 -0
- maniskill_elirobots-0.1.0/src/maniskill_elirobots/__init__.py +5 -0
- maniskill_elirobots-0.1.0/src/maniskill_elirobots/assets/__init__.py +3 -0
- maniskill_elirobots-0.1.0/src/maniskill_elirobots/assets/dual_ec63/dual_ec63_description.urdf +676 -0
- maniskill_elirobots-0.1.0/src/maniskill_elirobots/assets/dual_ec63/meshes/base_link.STL +0 -0
- maniskill_elirobots-0.1.0/src/maniskill_elirobots/assets/dual_ec63/meshes/link1.STL +0 -0
- maniskill_elirobots-0.1.0/src/maniskill_elirobots/assets/dual_ec63/meshes/link2.STL +0 -0
- maniskill_elirobots-0.1.0/src/maniskill_elirobots/assets/dual_ec63/meshes/link3.STL +0 -0
- maniskill_elirobots-0.1.0/src/maniskill_elirobots/assets/dual_ec63/meshes/link4.STL +0 -0
- maniskill_elirobots-0.1.0/src/maniskill_elirobots/assets/dual_ec63/meshes/link5.STL +0 -0
- maniskill_elirobots-0.1.0/src/maniskill_elirobots/assets/dual_ec63/meshes/link6.STL +0 -0
- maniskill_elirobots-0.1.0/src/maniskill_elirobots/assets/ec63/ec63_description.urdf +361 -0
- maniskill_elirobots-0.1.0/src/maniskill_elirobots/assets/ec63/meshes/base_link.STL +0 -0
- maniskill_elirobots-0.1.0/src/maniskill_elirobots/assets/ec63/meshes/link1.STL +0 -0
- maniskill_elirobots-0.1.0/src/maniskill_elirobots/assets/ec63/meshes/link2.STL +0 -0
- maniskill_elirobots-0.1.0/src/maniskill_elirobots/assets/ec63/meshes/link3.STL +0 -0
- maniskill_elirobots-0.1.0/src/maniskill_elirobots/assets/ec63/meshes/link4.STL +0 -0
- maniskill_elirobots-0.1.0/src/maniskill_elirobots/assets/ec63/meshes/link5.STL +0 -0
- maniskill_elirobots-0.1.0/src/maniskill_elirobots/assets/ec63/meshes/link6.STL +0 -0
- maniskill_elirobots-0.1.0/src/maniskill_elirobots/assets/fonts/UbuntuSansMono-Regular.ttf +0 -0
- maniskill_elirobots-0.1.0/src/maniskill_elirobots/jobs/__init__.py +0 -0
- maniskill_elirobots-0.1.0/src/maniskill_elirobots/jobs/celery_app.py +13 -0
- maniskill_elirobots-0.1.0/src/maniskill_elirobots/jobs/celery_tasks.py +28 -0
- maniskill_elirobots-0.1.0/src/maniskill_elirobots/jobs/redis_worker.py +26 -0
- maniskill_elirobots-0.1.0/src/maniskill_elirobots/main.py +0 -0
- maniskill_elirobots-0.1.0/src/maniskill_elirobots/optimize/__init__.py +0 -0
- maniskill_elirobots-0.1.0/src/maniskill_elirobots/optimize/cleanrl.py +137 -0
- maniskill_elirobots-0.1.0/src/maniskill_elirobots/robots/__init__.py +4 -0
- maniskill_elirobots-0.1.0/src/maniskill_elirobots/robots/dual_ec63.py +167 -0
- maniskill_elirobots-0.1.0/src/maniskill_elirobots/robots/ec63.py +241 -0
- maniskill_elirobots-0.1.0/src/maniskill_elirobots/robots/panda.py +264 -0
- maniskill_elirobots-0.1.0/src/maniskill_elirobots/runner/__init__.py +0 -0
- maniskill_elirobots-0.1.0/src/maniskill_elirobots/runner/runner.py +105 -0
- maniskill_elirobots-0.1.0/src/maniskill_elirobots/tasks/__init__.py +5 -0
- maniskill_elirobots-0.1.0/src/maniskill_elirobots/tasks/flip_coin_ec.py +513 -0
- maniskill_elirobots-0.1.0/src/maniskill_elirobots/tasks/pick_cube_ec.py +211 -0
- maniskill_elirobots-0.1.0/src/maniskill_elirobots/tasks/push_cube_ec.py +297 -0
- maniskill_elirobots-0.1.0/src/maniskill_elirobots/tasks/scene_builder/__init__.py +0 -0
- maniskill_elirobots-0.1.0/src/maniskill_elirobots/tasks/scene_builder/actors.py +75 -0
- maniskill_elirobots-0.1.0/src/maniskill_elirobots/trainer/__init__.py +0 -0
- maniskill_elirobots-0.1.0/src/maniskill_elirobots/trainer/ppo2.py +471 -0
- maniskill_elirobots-0.1.0/src/maniskill_elirobots/trainer/ppo_cleanrl.py +484 -0
- maniskill_elirobots-0.1.0/src/maniskill_elirobots/trainer/ppo_rllib.py +106 -0
- maniskill_elirobots-0.1.0/src/maniskill_elirobots/trainer/ppo_skrl.py +200 -0
- maniskill_elirobots-0.1.0/src/maniskill_elirobots/utils/__init__.py +3 -0
- maniskill_elirobots-0.1.0/src/maniskill_elirobots/utils/agent.py +69 -0
- maniskill_elirobots-0.1.0/src/maniskill_elirobots/utils/analyze.py +16 -0
- maniskill_elirobots-0.1.0/src/maniskill_elirobots/utils/cli.py +121 -0
- maniskill_elirobots-0.1.0/src/maniskill_elirobots/utils/env_photo.py +95 -0
- maniskill_elirobots-0.1.0/src/maniskill_elirobots/utils/episode_logger.py +750 -0
- maniskill_elirobots-0.1.0/src/maniskill_elirobots/utils/eval.py +151 -0
- maniskill_elirobots-0.1.0/src/maniskill_elirobots/utils/maniskill_vector_env.py +171 -0
- maniskill_elirobots-0.1.0/src/maniskill_elirobots/utils/math.py +96 -0
- maniskill_elirobots-0.1.0/src/maniskill_elirobots/wrappers/__init__.py +0 -0
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: maniskill-elirobots
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary:
|
|
5
|
+
Author: Felipe Gomes de Melo
|
|
6
|
+
License: MIT
|
|
7
|
+
Requires-Dist: torch>=2.10.0,<3.0.0
|
|
8
|
+
Requires-Dist: mani-skill>=3.0.1,<4.0.0
|
|
9
|
+
Requires-Dist: setuptools==81.0.0
|
|
10
|
+
Requires-Dist: tensorboard>=2.20.0
|
|
11
|
+
Requires-Dist: pytest>=9.0.2,<10.0.0
|
|
12
|
+
Requires-Dist: moviepy>=2.2.1
|
|
13
|
+
Requires-Dist: quatorch>=0.3.0
|
|
14
|
+
Requires-Dist: rq>=2.10.0
|
|
15
|
+
Requires-Dist: rq-dashboard>=0.9.0
|
|
16
|
+
Requires-Dist: celery>=5.6.3
|
|
17
|
+
Requires-Dist: flower>=2.0.1
|
|
18
|
+
Requires-Dist: redis>=8.0.1
|
|
19
|
+
Requires-Dist: skrl[torch]>=2.1.0
|
|
20
|
+
Requires-Dist: optuna>=4.9.0
|
|
21
|
+
Requires-Dist: pandas>=2.3.3
|
|
22
|
+
Requires-Dist: optuna-dashboard>=0.20.0
|
|
23
|
+
Requires-Dist: sqlalchemy>=2.0.51
|
|
24
|
+
Requires-Dist: psycopg>=3.3.4
|
|
25
|
+
Requires-Python: >=3.11, <3.15
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
|
|
28
|
+
# ManiSkill with Elite robots
|
|
29
|
+
|
|
30
|
+
Reinforcement learning research project for robot manipulation built on top of [ManiSkill](https://maniskill.ai/).
|
|
31
|
+
It registers custom robot agents and manipulation environments for the **EC63** arm (a 6-DOF arm with a two-finger claw gripper), plus a dual-arm variant, and trains PPO policies that run on massively parallel GPU simulation.
|
|
32
|
+
|
|
33
|
+
## Features
|
|
34
|
+
|
|
35
|
+
- **Custom ManiSkill agents** registered with `@register_agent`:
|
|
36
|
+
- `ec63` — 6-DOF arm + 2-finger claw gripper (URDF + STL meshes under `src/maniskill_elirobots/assets/`).
|
|
37
|
+
- `dual_ec63` — two EC63 arms mounted on a shared base.
|
|
38
|
+
- `panda` — a copy of the standard Panda used for baseline comparisons.
|
|
39
|
+
- **Custom tasks** registered with `@register_env` (see [Tasks](#tasks)).
|
|
40
|
+
- **CleanRL-style PPO** trainer with MLP actor-critic, GAE, checkpointing, video recording, early stopping and TensorBoard/W&B logging.
|
|
41
|
+
- **Massively parallel training** using ManiSkill's GPU (`physx_cuda`) simulation with up to 1024+ parallel environments.
|
|
42
|
+
- **Hyperparameter search** via Optuna backed by PostgreSQL.
|
|
43
|
+
- **Distributed job queues** (Celery + RQ) to sweep many seeds across worker machines.
|
|
44
|
+
- **Dev container** definitions for CPU, NVIDIA CUDA and AMD ROCm hosts, plus a GitHub Actions workflow that publishes a CUDA image to GHCR.
|
|
45
|
+
|
|
46
|
+
## Repository layout
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
src/maniskill_elirobots/
|
|
50
|
+
├── assets/ # URDF + STL meshes for ec63 and dual_ec63
|
|
51
|
+
├── robots/ # Agent definitions: ec63.py, dual_ec63.py, panda.py
|
|
52
|
+
├── tasks/ # Environments: flip_coin_ec.py, pick_cube_ec.py, push_cube_ec.py
|
|
53
|
+
│ └── scene_builder/ # Custom actor builders (two-color coin, transparent sphere, ...)
|
|
54
|
+
├── trainer/ # ppo_cleanrl.py (main), ppo_skrl.py, ppo_rllib.py, ppo2.py
|
|
55
|
+
├── optimize/ # Optuna study entrypoint (cleanrl.py)
|
|
56
|
+
├── jobs/ # Celery app/tasks and RQ worker scripts
|
|
57
|
+
├── runner/ # Minimal checkpoint-inference example
|
|
58
|
+
├── utils/ # Agent class, RecordEpisode wrapper, math, eval/analysis scripts
|
|
59
|
+
└── __init__.py # Re-exports EC63, DualEC63, FlipCoinEnv, PushCubeEcEnv
|
|
60
|
+
|
|
61
|
+
train/ # fish shell scripts that launch training runs
|
|
62
|
+
vendor/ManiSkill # git submodule: fork of haosulab/ManiSkill (editable install)
|
|
63
|
+
.devcontainer/ # CPU / gpu-cuda / gpu-rocm devcontainer definitions
|
|
64
|
+
tests/ # pytest suite (CUDA availability smoke test)
|
|
65
|
+
runs/ # TensorBoard logs + checkpoints (gitignored)
|
|
66
|
+
pth/ # exported checkpoints (gitignored)
|
|
67
|
+
eval/ # evaluation videos / trajectories (gitignored)
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Tasks
|
|
71
|
+
|
|
72
|
+
| Env ID | Robot(s) | Description |
|
|
73
|
+
|---|---|---|
|
|
74
|
+
| `FlipCoin-v1` | `ec63` | Grasp a two-color coin and flip it to the opposite orientation over the table. |
|
|
75
|
+
| `PickCubeEc-v1` | `panda`, `fetch`, `xarm6_robotiq`, `so100`, `widowxai`, `ec63` | Grasp a cube and move it to a target goal position (adapted from ManiSkill's `PickCube`). |
|
|
76
|
+
| `PushCubeEc-v1` | `panda`, `fetch`, `ec63` | Push a cube to a red/white goal region on the table (adapted from ManiSkill's `PushCube`). |
|
|
77
|
+
|
|
78
|
+
All tasks use dense/normalized-dense rewards and support state observations as well as visual observations.
|
|
79
|
+
|
|
80
|
+
## Installation
|
|
81
|
+
|
|
82
|
+
The project is managed with [uv](https://docs.astral.sh/uv/) and requires Python >= 3.11.
|
|
83
|
+
ManiSkill is pinned as a git submodule and installed editable from `vendor/ManiSkill`.
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
# 1. Clone with submodules (or update them after a regular clone)
|
|
87
|
+
git clone --recurse-submodules git@github.com:FelipeGdM/maniskill_elirobots.git
|
|
88
|
+
# or: git submodule update --init --recursive
|
|
89
|
+
|
|
90
|
+
# 2. Install dependencies
|
|
91
|
+
uv sync
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Dev containers
|
|
95
|
+
|
|
96
|
+
Three ready-made development containers are provided under `.devcontainer/`:
|
|
97
|
+
|
|
98
|
+
- `cpu` — CPU-only (LLVMpipe / Intel rendering).
|
|
99
|
+
- `gpu-cuda` — NVIDIA CUDA (uses `pytorch/pytorch:2.10.0-cuda12.8-cudnn9-runtime`).
|
|
100
|
+
- `gpu-rocm` — AMD ROCm.
|
|
101
|
+
|
|
102
|
+
`postCreateCommand` runs `uv sync --inexact`. The GPU-CUDA image is rebuilt and published to GHCR on every push to `main` via `.github/workflows/docker-publish.yml`.
|
|
103
|
+
|
|
104
|
+
### Optional: Optuna PostgreSQL storage
|
|
105
|
+
|
|
106
|
+
The `docker-compose.yml` starts a PostgreSQL 18 container (`devuser`/`devpass`, database `optuna`) used by the Optuna study storage:
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
docker compose up -d db
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Quick start
|
|
113
|
+
|
|
114
|
+
Visualize the EC63 robot under random actions:
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
uv run show-robot
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Train a PPO policy on the flip-coin task with the EC63:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
python src/maniskill_elirobots/trainer/ppo_cleanrl.py \
|
|
124
|
+
--env_id="FlipCoin-v1" \
|
|
125
|
+
--robot_uid="ec63" \
|
|
126
|
+
--exp_name="flipcoin-ec63-01"
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Evaluate a checkpoint:
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
python src/maniskill_elirobots/trainer/ppo_cleanrl.py \
|
|
133
|
+
--env_id="FlipCoin-v1" \
|
|
134
|
+
--evaluate \
|
|
135
|
+
--checkpoint="runs/<run>/ckpt_8192000.pt"
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Watch training in TensorBoard:
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
tensorboard --bind_all --logdir ./runs
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Training scripts
|
|
145
|
+
|
|
146
|
+
The `train/` directory contains fish scripts for common configurations, e.g.:
|
|
147
|
+
|
|
148
|
+
```fish
|
|
149
|
+
set -e DISPLAY
|
|
150
|
+
python src/maniskill_elirobots/trainer/ppo_cleanrl.py \
|
|
151
|
+
--env_id="FlipCoin-v1" \
|
|
152
|
+
--exp_name="flipcoin-ec63-(date +%s)-(git rev-parse --short HEAD)"
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## Training configuration
|
|
156
|
+
|
|
157
|
+
All hyperparameters are exposed via the `CliArgs` dataclass in `src/maniskill_elirobots/utils/cli.py` and can be overridden as CLI flags. Notable defaults:
|
|
158
|
+
|
|
159
|
+
| Flag | Default | Description |
|
|
160
|
+
|---|---|---|
|
|
161
|
+
| `--env_id` | `FlipCoin-v1` | Environment ID |
|
|
162
|
+
| `--robot_uid` | `ec63` | Robot unique ID |
|
|
163
|
+
| `--total_timesteps` | `8_192_000` | Total training timesteps |
|
|
164
|
+
| `--num_envs` | `1024` | Number of parallel environments |
|
|
165
|
+
| `--num_eval_envs` | `32` | Number of parallel eval environments |
|
|
166
|
+
| `--control_mode` | `pd_joint_delta_pos` | Arm controller (delta joint position) |
|
|
167
|
+
| `--learning_rate` | `3e-4` | Adam learning rate |
|
|
168
|
+
| `--gamma` / `--gae_lambda` | `0.8` / `0.9` | Discount / GAE lambda |
|
|
169
|
+
| `--update_epochs` | `10` | PPO update epochs |
|
|
170
|
+
| `--clip_coef` | `0.2` | PPO surrogate clipping |
|
|
171
|
+
| `--ent_coef` | `1e-2` | Entropy coefficient |
|
|
172
|
+
| `--eval_freq` | `16` | Evaluate every N iterations |
|
|
173
|
+
| `--early_stop` | `False` | Stop when eval success reaches 100% |
|
|
174
|
+
| `--capture_video` | `True` | Record eval (and optionally train) videos |
|
|
175
|
+
| `--track` | `False` | Log to Weights & Biases |
|
|
176
|
+
| `--tensorboard_folder` | `runs` | Root folder for TensorBoard data |
|
|
177
|
+
|
|
178
|
+
The trainer (`ppo_cleanrl.py`) uses the `normalized_dense` reward mode, seeds everything deterministically, saves checkpoints to `{tensorboard_folder}/{run_name}/ckpt_{step}.pt` and returns evaluation metrics that Optuna consumes.
|
|
179
|
+
|
|
180
|
+
## Hyperparameter optimization
|
|
181
|
+
|
|
182
|
+
`src/maniskill_elirobots/optimize/cleanrl.py` defines an Optuna study (`flipcoin_ppo_how_long`) that sweeps over seeds and returns the total timesteps needed to solve the task. It stores trials in the PostgreSQL database from `docker-compose.yml`:
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
uv run optimize # entrypoint defined in pyproject.toml
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
`dash.sh` launches the Optuna dashboard:
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
./dash.sh
|
|
192
|
+
# optuna-dashboard postgresql+psycopg://devuser:devpass@<host>:5432/optuna
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
## Distributed training queues
|
|
196
|
+
|
|
197
|
+
Multiple training runs can be distributed via task queues:
|
|
198
|
+
|
|
199
|
+
- **Celery** (`jobs/celery_app.py`, `jobs/celery_tasks.py`) — queue a batch of seeds:
|
|
200
|
+
```bash
|
|
201
|
+
./celery.sh # start a worker (concurrency 1, one GPU run at a time)
|
|
202
|
+
./flower.sh # Flower monitoring dashboard on port 5555
|
|
203
|
+
python -m maniskill_elirobots.jobs.celery_tasks # enqueue seed jobs
|
|
204
|
+
```
|
|
205
|
+
- **RQ** (`jobs/redis_worker.py`) — alternative queue-based sweep (Redis-backed).
|
|
206
|
+
|
|
207
|
+
Both assume a Redis broker; the addresses can be adjusted in the respective files.
|
|
208
|
+
|
|
209
|
+
## Evaluation & analysis utilities
|
|
210
|
+
|
|
211
|
+
- `utils/eval.py` — load a checkpoint, run episodes on `PushCubeEc-v1`, record videos via `RecordEpisode` and dump observations to `output.csv`.
|
|
212
|
+
- `utils/analyze.py` — read `output.csv` and compare raw actions vs. target joint positions (used to validate the delta-position controller behavior).
|
|
213
|
+
- `utils/env_photo.py` — run a checkpoint and save rendered frames / sensor images.
|
|
214
|
+
- `utils/episode_logger.py` — a `RecordEpisode` gym wrapper for saving trajectories (`.h5` + `.json`) and videos.
|
|
215
|
+
- `utils/maniskill_vector_env.py` — an alternative Gymnasium `VectorEnv` implementation for ManiSkill GPU envs with episode metrics (`success_once`, `success_at_end`, ...).
|
|
216
|
+
|
|
217
|
+
## Observations
|
|
218
|
+
|
|
219
|
+
State observations are provided as a nested dict (`obs_mode="state_dict"`):
|
|
220
|
+
|
|
221
|
+
```python
|
|
222
|
+
from torch import Tensor
|
|
223
|
+
|
|
224
|
+
data = {
|
|
225
|
+
"agent": {
|
|
226
|
+
"qpos": Tensor([[0.0000, -2.3562, 1.9635, -1.1781, 1.5708, 0.0000, 0.0000, 0.0000]]), # 8
|
|
227
|
+
"qvel": Tensor([[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]]), # 8
|
|
228
|
+
},
|
|
229
|
+
"extra": {
|
|
230
|
+
# {x, y, z, q1, q2, q3, q4} => 7
|
|
231
|
+
"tcp_pose": Tensor([[-2.5641e-01, 1.0300e-01, 2.3089e-01, -2.6125e-06, -7.0711e-01, 7.0711e-01, -7.7824e-08]]),
|
|
232
|
+
# {x, y, z} => 3
|
|
233
|
+
"goal_pos": Tensor([[0.1792, 0.0844, 0.0010]]),
|
|
234
|
+
# {x, y, z, q1, q2, q3, q4} => 7
|
|
235
|
+
"obj_pose": Tensor([[-0.0208, 0.0844, 0.0200, 1.0000, 0.0000, 0.0000, 0.0000]]),
|
|
236
|
+
},
|
|
237
|
+
}
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
With `obs_mode="state"` the dict is flattened into a vector, which is what the MLP policy consumes.
|
|
241
|
+
|
|
242
|
+
## Lessons learned
|
|
243
|
+
|
|
244
|
+
- In `PDJointPosControllerConfig`, the option `normalize_action` means that the action produced by the agent will be clipped to [-1,1] and then scaled to the min and max of the controller.
|
|
245
|
+
- The output action of the agent may be any real number, `normalize_action=True` means that the action space is better used.
|
|
246
|
+
- For thin objects, setting `lower=None` on the gripper mimic controller is a trick to keep grasp force even when the object is thin.
|
|
247
|
+
- A large `found_lost_pairs_capacity` and `max_rigid_patch_count` in the GPU sim config helps avoid memory errors when many environments run in parallel.
|
|
248
|
+
|
|
249
|
+
## Development
|
|
250
|
+
|
|
251
|
+
Lint and type-check:
|
|
252
|
+
|
|
253
|
+
```bash
|
|
254
|
+
uv run ruff check src tests
|
|
255
|
+
uv run basedpyright src
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
Run tests:
|
|
259
|
+
|
|
260
|
+
```bash
|
|
261
|
+
uv run pytest tests
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
> Note: `tests/test_gpu.py` asserts that CUDA is available, so it only passes on a GPU host.
|
|
265
|
+
|
|
266
|
+
## TODO
|
|
267
|
+
|
|
268
|
+
See `TODO.md`:
|
|
269
|
+
|
|
270
|
+
- Write a numpy render wrapper to render videos with SB3.
|
|
271
|
+
|
|
272
|
+
## License
|
|
273
|
+
|
|
274
|
+
MIT — see `pyproject.toml`. ManiSkill is a third-party dependency (git submodule under `vendor/ManiSkill`).
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
# ManiSkill with Elite robots
|
|
2
|
+
|
|
3
|
+
Reinforcement learning research project for robot manipulation built on top of [ManiSkill](https://maniskill.ai/).
|
|
4
|
+
It registers custom robot agents and manipulation environments for the **EC63** arm (a 6-DOF arm with a two-finger claw gripper), plus a dual-arm variant, and trains PPO policies that run on massively parallel GPU simulation.
|
|
5
|
+
|
|
6
|
+
## Features
|
|
7
|
+
|
|
8
|
+
- **Custom ManiSkill agents** registered with `@register_agent`:
|
|
9
|
+
- `ec63` — 6-DOF arm + 2-finger claw gripper (URDF + STL meshes under `src/maniskill_elirobots/assets/`).
|
|
10
|
+
- `dual_ec63` — two EC63 arms mounted on a shared base.
|
|
11
|
+
- `panda` — a copy of the standard Panda used for baseline comparisons.
|
|
12
|
+
- **Custom tasks** registered with `@register_env` (see [Tasks](#tasks)).
|
|
13
|
+
- **CleanRL-style PPO** trainer with MLP actor-critic, GAE, checkpointing, video recording, early stopping and TensorBoard/W&B logging.
|
|
14
|
+
- **Massively parallel training** using ManiSkill's GPU (`physx_cuda`) simulation with up to 1024+ parallel environments.
|
|
15
|
+
- **Hyperparameter search** via Optuna backed by PostgreSQL.
|
|
16
|
+
- **Distributed job queues** (Celery + RQ) to sweep many seeds across worker machines.
|
|
17
|
+
- **Dev container** definitions for CPU, NVIDIA CUDA and AMD ROCm hosts, plus a GitHub Actions workflow that publishes a CUDA image to GHCR.
|
|
18
|
+
|
|
19
|
+
## Repository layout
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
src/maniskill_elirobots/
|
|
23
|
+
├── assets/ # URDF + STL meshes for ec63 and dual_ec63
|
|
24
|
+
├── robots/ # Agent definitions: ec63.py, dual_ec63.py, panda.py
|
|
25
|
+
├── tasks/ # Environments: flip_coin_ec.py, pick_cube_ec.py, push_cube_ec.py
|
|
26
|
+
│ └── scene_builder/ # Custom actor builders (two-color coin, transparent sphere, ...)
|
|
27
|
+
├── trainer/ # ppo_cleanrl.py (main), ppo_skrl.py, ppo_rllib.py, ppo2.py
|
|
28
|
+
├── optimize/ # Optuna study entrypoint (cleanrl.py)
|
|
29
|
+
├── jobs/ # Celery app/tasks and RQ worker scripts
|
|
30
|
+
├── runner/ # Minimal checkpoint-inference example
|
|
31
|
+
├── utils/ # Agent class, RecordEpisode wrapper, math, eval/analysis scripts
|
|
32
|
+
└── __init__.py # Re-exports EC63, DualEC63, FlipCoinEnv, PushCubeEcEnv
|
|
33
|
+
|
|
34
|
+
train/ # fish shell scripts that launch training runs
|
|
35
|
+
vendor/ManiSkill # git submodule: fork of haosulab/ManiSkill (editable install)
|
|
36
|
+
.devcontainer/ # CPU / gpu-cuda / gpu-rocm devcontainer definitions
|
|
37
|
+
tests/ # pytest suite (CUDA availability smoke test)
|
|
38
|
+
runs/ # TensorBoard logs + checkpoints (gitignored)
|
|
39
|
+
pth/ # exported checkpoints (gitignored)
|
|
40
|
+
eval/ # evaluation videos / trajectories (gitignored)
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Tasks
|
|
44
|
+
|
|
45
|
+
| Env ID | Robot(s) | Description |
|
|
46
|
+
|---|---|---|
|
|
47
|
+
| `FlipCoin-v1` | `ec63` | Grasp a two-color coin and flip it to the opposite orientation over the table. |
|
|
48
|
+
| `PickCubeEc-v1` | `panda`, `fetch`, `xarm6_robotiq`, `so100`, `widowxai`, `ec63` | Grasp a cube and move it to a target goal position (adapted from ManiSkill's `PickCube`). |
|
|
49
|
+
| `PushCubeEc-v1` | `panda`, `fetch`, `ec63` | Push a cube to a red/white goal region on the table (adapted from ManiSkill's `PushCube`). |
|
|
50
|
+
|
|
51
|
+
All tasks use dense/normalized-dense rewards and support state observations as well as visual observations.
|
|
52
|
+
|
|
53
|
+
## Installation
|
|
54
|
+
|
|
55
|
+
The project is managed with [uv](https://docs.astral.sh/uv/) and requires Python >= 3.11.
|
|
56
|
+
ManiSkill is pinned as a git submodule and installed editable from `vendor/ManiSkill`.
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
# 1. Clone with submodules (or update them after a regular clone)
|
|
60
|
+
git clone --recurse-submodules git@github.com:FelipeGdM/maniskill_elirobots.git
|
|
61
|
+
# or: git submodule update --init --recursive
|
|
62
|
+
|
|
63
|
+
# 2. Install dependencies
|
|
64
|
+
uv sync
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Dev containers
|
|
68
|
+
|
|
69
|
+
Three ready-made development containers are provided under `.devcontainer/`:
|
|
70
|
+
|
|
71
|
+
- `cpu` — CPU-only (LLVMpipe / Intel rendering).
|
|
72
|
+
- `gpu-cuda` — NVIDIA CUDA (uses `pytorch/pytorch:2.10.0-cuda12.8-cudnn9-runtime`).
|
|
73
|
+
- `gpu-rocm` — AMD ROCm.
|
|
74
|
+
|
|
75
|
+
`postCreateCommand` runs `uv sync --inexact`. The GPU-CUDA image is rebuilt and published to GHCR on every push to `main` via `.github/workflows/docker-publish.yml`.
|
|
76
|
+
|
|
77
|
+
### Optional: Optuna PostgreSQL storage
|
|
78
|
+
|
|
79
|
+
The `docker-compose.yml` starts a PostgreSQL 18 container (`devuser`/`devpass`, database `optuna`) used by the Optuna study storage:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
docker compose up -d db
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Quick start
|
|
86
|
+
|
|
87
|
+
Visualize the EC63 robot under random actions:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
uv run show-robot
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Train a PPO policy on the flip-coin task with the EC63:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
python src/maniskill_elirobots/trainer/ppo_cleanrl.py \
|
|
97
|
+
--env_id="FlipCoin-v1" \
|
|
98
|
+
--robot_uid="ec63" \
|
|
99
|
+
--exp_name="flipcoin-ec63-01"
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Evaluate a checkpoint:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
python src/maniskill_elirobots/trainer/ppo_cleanrl.py \
|
|
106
|
+
--env_id="FlipCoin-v1" \
|
|
107
|
+
--evaluate \
|
|
108
|
+
--checkpoint="runs/<run>/ckpt_8192000.pt"
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Watch training in TensorBoard:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
tensorboard --bind_all --logdir ./runs
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Training scripts
|
|
118
|
+
|
|
119
|
+
The `train/` directory contains fish scripts for common configurations, e.g.:
|
|
120
|
+
|
|
121
|
+
```fish
|
|
122
|
+
set -e DISPLAY
|
|
123
|
+
python src/maniskill_elirobots/trainer/ppo_cleanrl.py \
|
|
124
|
+
--env_id="FlipCoin-v1" \
|
|
125
|
+
--exp_name="flipcoin-ec63-(date +%s)-(git rev-parse --short HEAD)"
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Training configuration
|
|
129
|
+
|
|
130
|
+
All hyperparameters are exposed via the `CliArgs` dataclass in `src/maniskill_elirobots/utils/cli.py` and can be overridden as CLI flags. Notable defaults:
|
|
131
|
+
|
|
132
|
+
| Flag | Default | Description |
|
|
133
|
+
|---|---|---|
|
|
134
|
+
| `--env_id` | `FlipCoin-v1` | Environment ID |
|
|
135
|
+
| `--robot_uid` | `ec63` | Robot unique ID |
|
|
136
|
+
| `--total_timesteps` | `8_192_000` | Total training timesteps |
|
|
137
|
+
| `--num_envs` | `1024` | Number of parallel environments |
|
|
138
|
+
| `--num_eval_envs` | `32` | Number of parallel eval environments |
|
|
139
|
+
| `--control_mode` | `pd_joint_delta_pos` | Arm controller (delta joint position) |
|
|
140
|
+
| `--learning_rate` | `3e-4` | Adam learning rate |
|
|
141
|
+
| `--gamma` / `--gae_lambda` | `0.8` / `0.9` | Discount / GAE lambda |
|
|
142
|
+
| `--update_epochs` | `10` | PPO update epochs |
|
|
143
|
+
| `--clip_coef` | `0.2` | PPO surrogate clipping |
|
|
144
|
+
| `--ent_coef` | `1e-2` | Entropy coefficient |
|
|
145
|
+
| `--eval_freq` | `16` | Evaluate every N iterations |
|
|
146
|
+
| `--early_stop` | `False` | Stop when eval success reaches 100% |
|
|
147
|
+
| `--capture_video` | `True` | Record eval (and optionally train) videos |
|
|
148
|
+
| `--track` | `False` | Log to Weights & Biases |
|
|
149
|
+
| `--tensorboard_folder` | `runs` | Root folder for TensorBoard data |
|
|
150
|
+
|
|
151
|
+
The trainer (`ppo_cleanrl.py`) uses the `normalized_dense` reward mode, seeds everything deterministically, saves checkpoints to `{tensorboard_folder}/{run_name}/ckpt_{step}.pt` and returns evaluation metrics that Optuna consumes.
|
|
152
|
+
|
|
153
|
+
## Hyperparameter optimization
|
|
154
|
+
|
|
155
|
+
`src/maniskill_elirobots/optimize/cleanrl.py` defines an Optuna study (`flipcoin_ppo_how_long`) that sweeps over seeds and returns the total timesteps needed to solve the task. It stores trials in the PostgreSQL database from `docker-compose.yml`:
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
uv run optimize # entrypoint defined in pyproject.toml
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
`dash.sh` launches the Optuna dashboard:
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
./dash.sh
|
|
165
|
+
# optuna-dashboard postgresql+psycopg://devuser:devpass@<host>:5432/optuna
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Distributed training queues
|
|
169
|
+
|
|
170
|
+
Multiple training runs can be distributed via task queues:
|
|
171
|
+
|
|
172
|
+
- **Celery** (`jobs/celery_app.py`, `jobs/celery_tasks.py`) — queue a batch of seeds:
|
|
173
|
+
```bash
|
|
174
|
+
./celery.sh # start a worker (concurrency 1, one GPU run at a time)
|
|
175
|
+
./flower.sh # Flower monitoring dashboard on port 5555
|
|
176
|
+
python -m maniskill_elirobots.jobs.celery_tasks # enqueue seed jobs
|
|
177
|
+
```
|
|
178
|
+
- **RQ** (`jobs/redis_worker.py`) — alternative queue-based sweep (Redis-backed).
|
|
179
|
+
|
|
180
|
+
Both assume a Redis broker; the addresses can be adjusted in the respective files.
|
|
181
|
+
|
|
182
|
+
## Evaluation & analysis utilities
|
|
183
|
+
|
|
184
|
+
- `utils/eval.py` — load a checkpoint, run episodes on `PushCubeEc-v1`, record videos via `RecordEpisode` and dump observations to `output.csv`.
|
|
185
|
+
- `utils/analyze.py` — read `output.csv` and compare raw actions vs. target joint positions (used to validate the delta-position controller behavior).
|
|
186
|
+
- `utils/env_photo.py` — run a checkpoint and save rendered frames / sensor images.
|
|
187
|
+
- `utils/episode_logger.py` — a `RecordEpisode` gym wrapper for saving trajectories (`.h5` + `.json`) and videos.
|
|
188
|
+
- `utils/maniskill_vector_env.py` — an alternative Gymnasium `VectorEnv` implementation for ManiSkill GPU envs with episode metrics (`success_once`, `success_at_end`, ...).
|
|
189
|
+
|
|
190
|
+
## Observations
|
|
191
|
+
|
|
192
|
+
State observations are provided as a nested dict (`obs_mode="state_dict"`):
|
|
193
|
+
|
|
194
|
+
```python
|
|
195
|
+
from torch import Tensor
|
|
196
|
+
|
|
197
|
+
data = {
|
|
198
|
+
"agent": {
|
|
199
|
+
"qpos": Tensor([[0.0000, -2.3562, 1.9635, -1.1781, 1.5708, 0.0000, 0.0000, 0.0000]]), # 8
|
|
200
|
+
"qvel": Tensor([[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]]), # 8
|
|
201
|
+
},
|
|
202
|
+
"extra": {
|
|
203
|
+
# {x, y, z, q1, q2, q3, q4} => 7
|
|
204
|
+
"tcp_pose": Tensor([[-2.5641e-01, 1.0300e-01, 2.3089e-01, -2.6125e-06, -7.0711e-01, 7.0711e-01, -7.7824e-08]]),
|
|
205
|
+
# {x, y, z} => 3
|
|
206
|
+
"goal_pos": Tensor([[0.1792, 0.0844, 0.0010]]),
|
|
207
|
+
# {x, y, z, q1, q2, q3, q4} => 7
|
|
208
|
+
"obj_pose": Tensor([[-0.0208, 0.0844, 0.0200, 1.0000, 0.0000, 0.0000, 0.0000]]),
|
|
209
|
+
},
|
|
210
|
+
}
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
With `obs_mode="state"` the dict is flattened into a vector, which is what the MLP policy consumes.
|
|
214
|
+
|
|
215
|
+
## Lessons learned
|
|
216
|
+
|
|
217
|
+
- In `PDJointPosControllerConfig`, the option `normalize_action` means that the action produced by the agent will be clipped to [-1,1] and then scaled to the min and max of the controller.
|
|
218
|
+
- The output action of the agent may be any real number, `normalize_action=True` means that the action space is better used.
|
|
219
|
+
- For thin objects, setting `lower=None` on the gripper mimic controller is a trick to keep grasp force even when the object is thin.
|
|
220
|
+
- A large `found_lost_pairs_capacity` and `max_rigid_patch_count` in the GPU sim config helps avoid memory errors when many environments run in parallel.
|
|
221
|
+
|
|
222
|
+
## Development
|
|
223
|
+
|
|
224
|
+
Lint and type-check:
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
uv run ruff check src tests
|
|
228
|
+
uv run basedpyright src
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
Run tests:
|
|
232
|
+
|
|
233
|
+
```bash
|
|
234
|
+
uv run pytest tests
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
> Note: `tests/test_gpu.py` asserts that CUDA is available, so it only passes on a GPU host.
|
|
238
|
+
|
|
239
|
+
## TODO
|
|
240
|
+
|
|
241
|
+
See `TODO.md`:
|
|
242
|
+
|
|
243
|
+
- Write a numpy render wrapper to render videos with SB3.
|
|
244
|
+
|
|
245
|
+
## License
|
|
246
|
+
|
|
247
|
+
MIT — see `pyproject.toml`. ManiSkill is a third-party dependency (git submodule under `vendor/ManiSkill`).
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "maniskill-elirobots"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = ""
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.11,<3.15"
|
|
7
|
+
dependencies = [
|
|
8
|
+
"torch>=2.10.0,<3.0.0",
|
|
9
|
+
"mani-skill>=3.0.1,<4.0.0",
|
|
10
|
+
"setuptools==81.0.0",
|
|
11
|
+
"tensorboard>=2.20.0",
|
|
12
|
+
"pytest>=9.0.2,<10.0.0",
|
|
13
|
+
"moviepy>=2.2.1",
|
|
14
|
+
"quatorch>=0.3.0",
|
|
15
|
+
"rq>=2.10.0",
|
|
16
|
+
"rq-dashboard>=0.9.0",
|
|
17
|
+
"celery>=5.6.3",
|
|
18
|
+
"flower>=2.0.1",
|
|
19
|
+
"redis>=8.0.1",
|
|
20
|
+
"skrl[torch]>=2.1.0",
|
|
21
|
+
"optuna>=4.9.0",
|
|
22
|
+
"pandas>=2.3.3",
|
|
23
|
+
"optuna-dashboard>=0.20.0",
|
|
24
|
+
"sqlalchemy>=2.0.51",
|
|
25
|
+
"psycopg>=3.3.4",
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
[[project.authors]]
|
|
29
|
+
name = "Felipe Gomes de Melo"
|
|
30
|
+
|
|
31
|
+
[project.license]
|
|
32
|
+
text = "MIT"
|
|
33
|
+
|
|
34
|
+
[project.scripts]
|
|
35
|
+
show-robot = "maniskill_elirobots.robots.ec63:_script"
|
|
36
|
+
optimize = "maniskill_elirobots.optimize.cleanrl:entrypoint"
|
|
37
|
+
|
|
38
|
+
[tool.uv]
|
|
39
|
+
exclude-dependencies = ["torch"]
|
|
40
|
+
|
|
41
|
+
[tool.uv.config-settings]
|
|
42
|
+
editable_mode = "compat"
|
|
43
|
+
|
|
44
|
+
[tool.uv.sources.mani-skill]
|
|
45
|
+
path = "./vendor/ManiSkill"
|
|
46
|
+
editable = true
|
|
47
|
+
|
|
48
|
+
[tool.ruff]
|
|
49
|
+
line-length = 256
|
|
50
|
+
indent-width = 4
|
|
51
|
+
exclude = ["vendor/**"]
|
|
52
|
+
|
|
53
|
+
[tool.ruff.lint]
|
|
54
|
+
select = ["ALL"]
|
|
55
|
+
ignore = [
|
|
56
|
+
"D",
|
|
57
|
+
"ANN",
|
|
58
|
+
"ERA",
|
|
59
|
+
"RUF012",
|
|
60
|
+
"T201",
|
|
61
|
+
"C408",
|
|
62
|
+
]
|
|
63
|
+
|
|
64
|
+
[tool.ruff.per-file-ignores]
|
|
65
|
+
"tests/**/*.py" = [
|
|
66
|
+
"INP001",
|
|
67
|
+
"S101",
|
|
68
|
+
"ARG",
|
|
69
|
+
"FBT",
|
|
70
|
+
"PLR2004",
|
|
71
|
+
"S311",
|
|
72
|
+
]
|
|
73
|
+
fixable = ["ALL"]
|
|
74
|
+
unfixable = []
|
|
75
|
+
|
|
76
|
+
[tool.basedpyright]
|
|
77
|
+
ignore = ["vendor/**"]
|
|
78
|
+
reportUnannotatedClassAttribute = false
|
|
79
|
+
reportUnknownVariableType = false
|
|
80
|
+
reportUnknownMemberType = false
|
|
81
|
+
reportArgumentType = false
|
|
82
|
+
reportUntypedClassDecorator = false
|
|
83
|
+
reportMissingTypeStubs = false
|
|
84
|
+
reportIncompatibleVariableOverride = false
|
|
85
|
+
reportUnknownParameterType = false
|
|
86
|
+
reportUnknownArgumentType = false
|
|
87
|
+
reportMissingParameterType = false
|
|
88
|
+
reportIncompatibleMethodOverride = false
|
|
89
|
+
reportMissingTypeArgument = false
|
|
90
|
+
reportPrivateImportUsage = false
|
|
91
|
+
reportExplicitAny = false
|
|
92
|
+
reportAny = false
|
|
93
|
+
|
|
94
|
+
[build-system]
|
|
95
|
+
requires = ["uv_build>=0.10.9,<0.11.0"]
|
|
96
|
+
build-backend = "uv_build"
|