Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

srb agent collect — Collect Demonstrations

Use srb agent collect to record teleoperation, policy, or built-in random/zero demonstrations. Pass the resulting dataset to srb agent learn for offline imitation learning.

Usage

srb agent collect --env peg_in_hole --num_episodes 50

This uses the environment’s teleoperation default, or keyboard if none is configured. For other collection sources, see Collection Modes.

srb agent collect --env ENV_ID [options] is the general form.

For native input, srb real_agent collect --collector human supports ROS, SpaceMouse, or haptic input and requires generated COMMAND_MAPPING metadata. ROS is the default. ROS and haptic have no manual save, discard, or reset controls; environment termination or --horizon can finish an episode. Scalar RealEnv steps retain the existing batch axes in HDF5, with split=real and controller=human. See the native direct-input contract.

Options | Shared Agent Options

OptionDescriptionDefault
Collection
--collector SOURCEData source: human, policy, random, or zero. If omitted, SRB uses policy when --algo or --model is present and human otherwise.inferred
--num_episodes NNumber of episodes to collect100
--horizon NMaximum number of steps per episode. An episode ended by this limit, or by closing the simulator mid-episode, is recorded as a truncation (truncated=True, done=True) at its last row, so it is distinguishable from a terminal success or failure.400
--success_onlySave successful episodes. Uses the configured success termination term, or the ending episode’s success flag (including horizon truncation) if no term exists or the environment has reset. Autonomous collection fails after the first episode if neither signal exists; teleoperation discards keyboard-saved demos. See tips.False
Teleop (default mode)
--teleop_device [DEV …]Input device(s) (keyboard, spacemouse, ros, gamepad, haptic)env default, else [keyboard]
--pos_sensitivity VALTranslation sensitivity1.0
--rot_sensitivity VALRotation sensitivityπ (≈3.14)
--invert_controls, --invertIn manipulation environments, invert only the first two translational controls; --invert is an alias for --invert_controlsTrue
Policy rollout
--algo ALGOPolicy algorithm of the trained policy (RL or imitation learning)
--model MODELPath to a raw policy checkpoint or SRB model artifact
--obs {state,visual}Observation modality of the rolled-out policy: selects the agent-config variant and the log tree searched for its latest checkpointstate

Collection Modes

1. Teleoperation (default)

Without --algo or --model, the command records teleoperation actions and observations.

2. Policy Rollout

Pass --algo or --model (or both) to record policy trajectories. Supported labels include dreamer, tdmpc2, rsl_rl_ppo, sb3_*, sbx_*, skrl_ppo, skrl_sac, skrl_ppo_rnn, other skrl labels that pass preflight, and robomimic_*; skrl_amp remains fail-closed.

srb agent collect --env peg_in_hole --algo sbx_ppo --num_episodes 200

Without --model, collection loads the latest checkpoint from the algorithm’s standard training logdir, including framework-native layouts such as RSL-RL’s model_*.pt and TD-MPC2’s models/*.pt.

--model accepts a raw checkpoint or SRB model artifact directory. Portable artifacts may include config.yaml for stateful or config-heavy adapters such as Dreamer, TD-MPC2, and RSL-RL when replayed outside the original run.

For an SRB model artifact, dataset metadata records the resolved checkpoint (model) and source artifact directory (model_artifact).

3. Built-in Sources

Use --collector random or --collector zero to collect baseline datasets without a human operator or trained checkpoint.

srb agent collect --env peg_in_hole --collector random --num_episodes 20
srb agent collect --env excavation --collector zero --num_episodes 5 --horizon 200

random samples the environment’s action space from a generator seeded with the environment seed (env.seed), so repeating a run with the same seed records the same actions.

The collection source is independent of the split: real-world data can use split=real and retain controller=random, zero, human or policy in metadata.

Output

Datasets are robomimic-compatible HDF5 files under ${SRB_LOGS_DIR}/<env_id>/collect/<timestamp>/datasets/ or, for policy rollouts, under the policy run directory. Run metadata records the collection source and settings. The printed dataset path can be passed to srb agent learn --dataset.

No saved episodes fails with no episodes were saved after N attempt(s) and writes no dataset. A shortfall keeps the dataset and reports both counts; autonomous collection tries up to three times per requested episode. Collection stops when the simulator closes.

When available, the environment step rate is recorded as nominal fps in the SRB sidecar. See the dataset publication requirements for the required source rate for LeRobot v3 export.

Observation format:

  • Observation leaves use contract shapes, e.g. [D] for state or [H, W, C] for images. Interrupted collection publishes saved episodes with masks and the SRB sidecar.
  • success is one flag per demo; exports return it on the demo’s final row only, and LeRobot exports write it as a Boolean success column.
  • Simulated depth is normalized uint8; real-camera depth is metric float32. The two are not interchangeable.
  • Datasets do not record whether a policy acted deterministically. Check the training framework’s policy configuration when deterministic inference matters.

Tips

  • Human collection with keyboard teleop needs the GUI: with --headless it fails before collecting, so pick another --teleop_device or drop --headless.
  • Collection requires env.num_envs=1 in every mode.
  • For an immersive viewpoint while teleoperating, combine with --xr (see Extended Reality).

See Also