Collect Demonstrations#
This tutorial explains how to use metasim/scripts/collect_demo.py
to collect expert demonstrations for imitation learning in RoboVerse.
๐ Overview#
collect_demo.py
is a utility script that replays pre-defined trajectories (from traj_filepath
) and records observations, actions, and metadata into a structured dataset. The collected demos are used for training behavior cloning or other imitation learning models.
โ๏ธ 1. Basic Usage#
Example#
To collect demonstrations for pick_cube
task, run the following command:
python collect_demo.py \
--task pick_cube \
--robot franka \
--sim isaaclab \
--num_envs 2 \
--headless True \
--run_unfinished
Important: You must include exactly one of the following collection modes:
--run_all
: Collect all demos from scratch (overwrite existing ones)
--run_unfinished
: Only collect demos that are missing or incomplete โ recommended
--run_failed
: Retry demos that previously failed
Argument Reference#
Argument |
Description |
---|---|
|
Task name (e.g., |
|
Robot platform (e.g., |
|
Simulator backend ( |
|
Choose exactly one |
|
Number of parallel environments |
|
Disable rendering window for faster collection |
๐ 2. Where is data saved?#
Demo data is stored in:
roboverse_demo/demo_<sim>/<TaskName>-Level<level>[-<cust_name>]/robot-<robot>/demo_XXXX/
Each folder contains:
A sequence of observations and actions
status.txt
indicatingsuccess
orfailed
You can use --cust_name
to customize the folder name:
--cust_name my_experiment_name
๐๏ธ 3. Advanced Options#
Argument |
Description |
---|---|
|
Index of the first demo to collect |
|
Maximum demo index to collect |
|
Number of times to retry a failed demo |
|
Extra steps to collect after success (default: 20) |
|
Whether to add a table object in the scene |
|
Optional scene name |
|
Render config (camera, resolution, etc.) |
|
Domain randomization config |
Example:
python collect_demo.py \
--task plug_charger \
--run_all True \
--num_envs 4 \
--cust_name vision_exp \
--retry_num 2 \
--headless True \
--tot_steps_after_success 20
๐ง 4. Notes#
The script reads pre-recorded trajectories via
task.traj_filepath
If a demo fails N times (
retry_num
), it is marked as failed and skippedSuccessful demos are skipped unless
--run_all
is setParallelism helps speed up collection but increases GPU load
Currently uses global variables for tracking progress (e.g.
tot_success
) โ future refactor may move to aProgressManager
๐งผ 5. Cleanup and Inspection#
Demos that have a
status.txt
file with the contentfailed
will be retried automatically when using--run_failed
. There is no need to delete these folders manually.You can visualize collected observations or use them for training downstream agents.
โ Summary#
Use
collect_demo.py
to automate demonstration collection.Start with
--run_unfinished
or--run_all
.Use
--cust_name
to organize your datasets.Ensure
traj_filepath
is valid in your task config.