robolab_motionplanning / docs /motion_planning.md
yqi19's picture
Upload RoboLab motion-planning code only
81c7a5f verified
|
Raw
History Blame Contribute Delete
7.05 kB
# RoboLab Motion Planning
This checkout includes a RoboLab-native motion-planning baseline in `robolab_mp/`.
It follows the ManiSkill example layout at a practical level: a reusable planner,
task-level solution inference, a runner, recorded videos, and a verifier. It does
not use SAPIEN.
## What It Does
- Registers requested RoboLab tasks with `DroidIKActionCfg` absolute Cartesian IK.
- Infers simple pick/place plans from each task's success termination
(`object` plus `container`, `surface`, or `reference_object`).
- Executes top-down Cartesian waypoints: pregrasp, descend, close, lift,
transfer, place, open, settle, retreat.
- Reads simulation ground truth (`world.get_pose`, `world.get_bbox`, contact
predicates) for object yaw, pose diagnostics, and final success debugging.
- Records combined sensor/viewport MP4s and per-camera MP4s with RoboLab's
existing `VideoWriter`.
- Writes one `motion_planning_result.json` per task and a combined
`motion_planning_summary.json`.
- Optionally verifies videos are readable, have enough frames, valid dimensions,
and nonblank sampled frames.
## Run Three Example Tasks
From the RoboLab repo root:
```bash
cd /home/horde/robolab_mp/RoboLab
python examples/run_motion_planning.py --headless --video-mode all --verify-videos
```
Use the RoboLab/Isaac Python environment. In this workspace that is:
```bash
/home/horde/miniconda3/bin/conda run -n env_uwlab python examples/run_motion_planning.py \
--headless --video-mode all --verify-videos
```
If Isaac Sim has not been launched in this environment before, it may prompt for
the NVIDIA Omniverse EULA. Accept that prompt yourself, or run with
`OMNI_KIT_ACCEPT_EULA=YES` only if you have already reviewed and accepted the
EULA:
```bash
OMNI_KIT_ACCEPT_EULA=YES python examples/run_motion_planning.py \
--headless --video-mode all --verify-videos
```
The default tasks are:
- `BananaInBowlTask`
- `RubiksCubeTask`
- `MustardInLeftBinTask`
Outputs are written to:
```text
/home/horde/robolab_mp/RoboLab/output/motion_planning/
```
Each task gets a directory containing MP4 files and `motion_planning_result.json`.
The combined summary is:
```text
output/motion_planning/motion_planning_summary.json
```
## Run Specific Tasks
```bash
python examples/run_motion_planning.py \
--headless \
--task BananaInBowlTask RubiksCubeTask MustardInLeftBinTask \
--video-mode viewport \
--output-dir output/mp_smoke \
--verify-videos
```
Useful options:
- `--task ...`: RoboLab task class names.
- `--video-mode all|sensor|viewport|none`: choose videos to record. `all`
writes combined sensor/viewport videos plus individual camera videos such as
`*_mp_sensor_over_shoulder_left_camera.mp4`, `*_mp_sensor_wrist_cam.mp4`,
and `*_mp_viewport_egocentric_mirrored_camera.mp4`.
- `--max-steps 420`: cap planner execution.
- `--seed 1`: environment seed.
- `--no-save-videos`: run planning without MP4 output.
- `--verify-videos`: sanity-check generated MP4s after each task.
- `--record-hdf5`: also export RoboLab HDF5 episode data; off by default for MP video runs.
## Verify Existing Videos
```bash
python examples/verify_motion_planning_videos.py \
--summary output/motion_planning/motion_planning_summary.json
```
Or verify explicit files:
```bash
python examples/verify_motion_planning_videos.py \
output/motion_planning/*/*_mp_viewport.mp4
```
The verifier checks that each MP4 opens through OpenCV, contains at least eight
frames, has positive dimensions, and has nonblank sampled frames.
## Verified Workspace Run
The following EULA-approved headless Isaac/RoboLab run was executed in this workspace:
```bash
OMNI_KIT_ACCEPT_EULA=YES /home/horde/miniconda3/bin/conda run -n env_uwlab \
python examples/run_motion_planning.py \
--headless \
--task BananaInBowlTask MustardInLeftBinTask \
--video-mode all \
--output-dir output/mp_yaw_camera_verified \
--max-steps 380 \
--verify-videos
```
Verified task results:
- `BananaInBowlTask`: `task_success=true`, success at step 260. Final ground truth reports `in_target_open_top=true`, `object_target_contact=true`, and `object_gripper_contact=false`.
- `MustardInLeftBinTask`: `task_success=true`, success at step 196. The first waypoint is `mustard:pregrasp_yaw_0.000_offset_1.571`, so the grasp command includes the object yaw from simulation plus a z-axis grasp offset.
Verified rendered MP4 outputs are under `output/mp_yaw_camera_verified/`. Each task directory contains:
- `*_mp_sensor.mp4`: combined sensor strip.
- `*_mp_sensor_over_shoulder_left_camera.mp4`: front/over-shoulder camera view.
- `*_mp_sensor_wrist_cam.mp4`: wrist/in-hand camera view.
- `*_mp_viewport.mp4`: combined viewport video.
- `*_mp_viewport_egocentric_mirrored_camera.mp4`: viewport egocentric camera.
All MP4 files in this run passed the OpenCV video verifier. The summary JSON is
`output/mp_yaw_camera_verified/motion_planning_summary.json`; each task also
writes `motion_planning_result.json` with `planner_tuning`, `ground_truth`,
waypoint targets, and actual end-effector poses.
## Export GR00T Dataset
Motion-planning outputs can be converted to the GR00T LeRobot-v2 layout used by
NVIDIA Isaac-GR00T:
```bash
python examples/export_motion_planning_gr00t.py \
--input output/mp_yaw_camera_verified \
--output output/mp_yaw_camera_verified_gr00t \
--fps 15
```
The exporter writes:
- `meta/info.json`, `meta/episodes.jsonl`, `meta/tasks.jsonl`, `meta/modality.json`, `meta/stats.json`, and `meta/relative_stats.json`.
- `data/chunk-000/episode_*.parquet` with `observation.state`, `action`, timestamps, task annotations, episode indices, and terminal flags.
- `videos/chunk-000/observation.images.front/episode_*.mp4` for the over-shoulder/front camera.
- `videos/chunk-000/observation.images.wrist/episode_*.mp4` for the wrist/in-hand camera.
- `videos/chunk-000/observation.images.ego_view/episode_*.mp4` for the viewport egocentric camera.
The state/action vector is `[x, y, z, qw, qx, qy, qz, gripper]` from the MP
end-effector trajectory. `meta/modality.json` splits this into `eef_position`,
`eef_quaternion_wxyz`, and `gripper`, and maps videos to the GR00T keys
`front`, `wrist`, and `ego_view`.
The verified workspace export is:
```text
output/mp_yaw_camera_verified_gr00t/
```
It contains two successful episodes: Banana-in-bowl and Mustard-in-left-bin.
## Extending Plans
The generic solver lives in `robolab_mp/solutions.py`. For standard placement
tasks, it reads the success predicate params and generates a plan automatically.
For harder RoboLab tasks, add a task-specific solution function that returns a
list of `CartesianWaypoint` objects from `robolab_mp.types` and call it from
`run_one_task`.
The low-level follower is `robolab_mp/planner.py`. It sends absolute
`[x, y, z, qw, qx, qy, qz, gripper]` actions through RoboLab's existing
absolute differential IK controller. Targets are expressed in `eef_frame`; the
planner converts orientation commands to the `base_link` frame expected by
`DroidIKActionCfg`.