Expert Data Expansion#

EmbodiChain supports two expert-authoring paradigms for synthetic demonstration data:

  1. Handwritten trajectories implement the expert in a registered Python task, using MotionGenerator directly or composing reusable Atomic Skills.

  2. Task Program declares the task flow in typed YAML and lets the configured environment integration lower Semantic Calls to the same Atomic Skills.

The two paradigms differ only in how the expert plan is authored. Both produce lazy DemoSegment objects, and both use the same Gym executor, env.step() path, validation rules, dataset manager, and transactional commit boundary.

Both paradigms retain an overall task instruction and a finer instruction for each semantic segment. See Task and segment language for expert data for task/program configuration, per-episode overrides, LeRobot readback, online training, and migration from recorder-owned language.

Choose an Expert-Authoring Paradigm#

Handwritten trajectories and Task Program#

Concern

Handwritten trajectory

Task Program

Authoring surface

A registered Python task module implementing create_demo_segments().

program.yaml plus a trusted integration, reusable physical environment, embodiment, execution policy, and runnable task deployment.

Planning level

Call MotionGenerator for task-specific waypoints, or construct typed SkillInvocation values for AtomicSkillEngine.

Declare Pick, Place, HandOver, registered Semantic Calls, control flow, post-policies, and validators; the adapter lowers them to Atomic Skills.

Best fit

Custom geometry, unusual control logic, experimental skills, or logic that needs unrestricted Python.

Reusable object-centric workflows whose task intent should remain independent of a particular robot and simulator assembly.

Responsibility

The task owns planning, command assembly, lazy segment boundaries, and physical validation.

The program owns intent; trusted integration and deployment components own physical identities, resources, policies, and services.

Environment entry

A task-specific registered EmbodiedEnv subclass.

A supported configuration-defined task can use the common EmbodiedEnv without a task-specific Python module.

Use handwritten Python while the behavior itself is still changing rapidly or does not have a reusable semantic contract. Use Task Program when the behavior can be expressed as stable semantic operations and should be portable across compatible embodiments. A common progression is to prototype in Python, move reusable motion behavior into Atomic Skills, and then expose stable task flows through Task Program.

The Shared Rollout Contract#

The rollout path is deliberately shared:

registered Python task                 configured Task Program
create_demo_segments()                 compile + Gym bridge
             \                           /
              +---- Iterable[DemoSegment]
                             |
                  execute_demo_episode()
                             |
                      env.step(action)
                             |
               observation/action buffers
                             |
            reset(commit) or reset(discard)
                             |
                    LeRobot dataset

A DemoSegment contains an action iterable and may also contain a stable name, target, instruction, JSON-compatible metadata, and a validator. Its actions may be lazy: the next segment can be planned only after the previous segment has executed and changed the scene.

The expert planner must not call env.step() itself. The common executor owns stepping so observations, actions, terminal signals, segment annotations, and dataset frames stay causally aligned.

Recording eligibility and component evidence#

Every environment exposes an EpisodeContext. Components report their own acceptance through a synchronous check; the context combines those reports without deciding geometry validity or task success. For example, a host can publish an already measured row mask and its evidence:

with env.episode_context.check("task/validation", env_ids) as finish:
    accepted, evidence, reasons = measure_task_acceptance(env, env_ids)
    finish(accepted=accepted, metadata=evidence, reasons=reasons)

eligible_ids = env.episode_context.filter_recordable(env_ids)
row_snapshots = env.episode_context.snapshot(env_ids)

accepted is a bool or a boolean mask in selected-row order. Metadata may be a shared JSON mapping or an integer-row-keyed mapping; reasons may be a string or a row-keyed mapping. Report exactly once before leaving the scope. Exceptions, cancellation and a missing report reject those buffers; a missing report also raises an error. Overlapping checks from the same source are rejected.

A row can be submitted only after successful reset initialization, with no pending check and no earlier rejection in its current buffers. Different sources combine by intersection. An outer check remains pending across internal resets. Replacing demo metadata, starting another demo or reseeding cannot remove a rejection; the host must successfully consume or discard the buffers and begin a new episode. Existing success/failed-episode, fragment and explicit commit policies still apply after this eligibility filter.

Reset consumes the old recording before changing physical state. A save error preserves the episode and its buffers for retry. New observations and the first frame must be registered before initialization completes. Construction alone does not create an eligible recording. close() never implicitly commits.

Read the same row snapshots through info["episode_context"] and env.get_demo_episode_metadata(row)["episode_context"]. They contain episode numbers, initialization/recording eligibility, pending sources, rejection reasons and independent source metadata. Asynchronous writers copy their data and snapshots before enqueueing.

The reset event is named ExpandSceneLayout in Python and YAML. It records layout provenance under sources["events/<configured_event_name>"]. Its name replaces RandomizeSceneLayout directly, while the configured event name and its random stream remain unchanged. See the runnable scene expansion examples for online generation, saved-layout replay and the portable tabletop assets.

Normal videos are independent files under videos/env_NNN/episode_NNNNNN_<camera>.mp4, with JSON context sidecars. Selected-row reset leaves other rows’ frames untouched. Failed writes retain an owned job and retry under the same episode identity. Explicit diagnostic exports use purpose="diagnostic" and a separate diagnostics directory; their evidence is excluded from normal datasets. Mosaics remain previews.

Paradigm 1: Handwritten Trajectories#

A handwritten expert lives beside its task’s registered Python entry point. The task owns scene queries, command timing, segment metadata, and success checks. The official stacking and RGB-ranking experts use the configured Task Program route described below; they no longer provide Python task subclasses.

Direct Motion Generator or Atomic Skills#

These are two abstraction levels, not two unrelated planning engines:

  • Use MotionGenerator.generate() directly when the task already owns the joint or Cartesian waypoints and only needs a planned joint trajectory. Wrap PlanResult.positions as a DemoSegment action iterable and combine PlanResult.success with a physical validator. See Motion Generator for the complete planning API.

  • Use AtomicSkillEngine when the behavior matches reusable skills such as PickUp, Place, MoveEndEffector, Pour, or HandOver. The engine owns the shared motion generator, command profiles, typed goals, and projected semantic context. See Atomic Skills for the action contracts.

When using MotionGenerator directly, its planned positions are ordered for the selected control_part. The actions yielded to the environment must match its active action space. If the environment controls more joints than the planned arm, merge the arm plan with hold or gripper commands before yielding it; do not silently rely on incompatible dimensions.

Return semantic demonstration segments#

create_demo_segments() is the preferred handwritten expert API. This schematic subclass method assumes an existing planner and physical validators:

from embodichain.lab.gym.envs import DemoSegment

def create_demo_segments(self, **kwargs):
    pick_actions, place_actions = self.plan_pick_and_place(**kwargs)
    yield DemoSegment(
        actions=pick_actions,
        name="pick_object",
        instruction="Grasp and lift the object.",
        validator=self.validate_lift,
    )
    yield DemoSegment(
        actions=place_actions,
        name="place_object",
        instruction="Place the object, release it, and let it settle.",
        validator=self.validate_placement,
    )

The planner must merge arm, gripper and hold commands into the environment’s active action layout. Keep release settling in the placement iterable and measure its physical outcome independently of planning success. For a multi-object episode, yield lazily so later planning reads the updated scene. See Atomic Skills for reusable Atomic Skill planning and execution.

Legacy tasks implementing create_demo_action_list() remain supported and are wrapped as one segment named legacy. New handwritten experts should provide explicit semantic segments; configured tasks should declare those boundaries in their Task Program.

Paradigm 2: Task Program#

Task Program replaces the task-specific expert method with declarative task intent. It does not introduce a second rollout or recording API: the configured adapter compiles the program, creates lazy demonstration segments, and returns them to the same executor used by handwritten tasks.

The migrated two-block stacking and RGB-ranking experts use the same configured route. For example, smoke-test stacking without writing a dataset:

embodichain run-task \
    --gym_config embodichain/extensions/tasks/configs/tasks/manipulation/tableware/stack_blocks_two/task.cobotmagic.yaml \
    --headless --filter_dataset_saving --max_episodes 1

To collect demonstrations, remove --filter_dataset_saving and configure the recorder using Configure Dataset Recording. The deployment selects the physical scene, embodiment, execution policy, and declarative program.

The current Pour Water example is a complete configuration-defined task:

  • env.yaml owns the physical scene, environment values, and dataset recorder, without any Task Program fields;

  • task.cobotmagic.yaml is the runnable deployment that selects the environment, Task Program, embodiment, and execution policy;

  • program.yaml owns embodiment-independent intent and targets;

  • integration.yaml owns task-specific contracts, scene binding, semantic defaults, action options, and allowlisted runtime services;

  • the embodiment component owns the robot, sensors, endpoints, and compatible skill profile.

Compose the deployment#

The runnable deployment is intentionally thin:

 1id: PourWater-v1
 2
 3environment:
 4  component: env.yaml
 5
 6evaluation:
 7  component: task_program/evaluation.yaml
 8
 9task_program:
10  program: task_program/program.yaml
11  integration: task_program/integration.yaml
12  execution_policy:
13    component: ../../../../components/execution_policies/trajectory_open_loop.yaml
14    overrides:
15      motion:
16        sample_count: 160
17      recovery:
18        goal_rotation_threshold: 3.141592653589793
19
20embodiment:
21  component: ../../../../components/embodiments/cobotmagic.yaml

Its selected env.yaml is reusable outside Task Program because it contains only physical simulation and ordinary Gym values:

Pour Water reusable environment
  1environment_id: pour_water
  2physics: default
  3max_episodes: 5
  4max_episode_steps: 3200
  5num_envs: 1
  6arena_space: 3.0
  7
  8render_cfg:
  9  # glTF assets require the native loader for their Y-up to Z-up conversion.
 10  renderer: hybrid
 11  tone_mapping_enabled: true
 12  tone_mapping_exposure: 1.0
 13
 14simulation:
 15  light:
 16    direct:
 17      - uid: light_1
 18        light_type: rect
 19        color: [1.0, 0.95, 0.88]
 20        intensity: 5.0
 21        init_pos: [0.35, -0.5, 2.1]
 22        direction: [0.35, 0.4, -1.0]
 23        rect_width: 1.0
 24        rect_height: 0.8
 25      - uid: fill_light
 26        light_type: rect
 27        color: [0.88, 0.94, 1.0]
 28        intensity: 1.5
 29        init_pos: [1.25, 0.6, 1.7]
 30        direction: [-0.5, -0.5, -1.0]
 31        rect_width: 0.8
 32        rect_height: 0.8
 33  background:
 34    - uid: table
 35      shape:
 36        shape_type: Mesh
 37        fpath: PourWaterAssets/table.glb
 38      attrs:
 39        mass_props:
 40          mass: 10.0
 41        material_props:
 42          static_friction: 0.95
 43          dynamic_friction: 0.9
 44          restitution: 0.01
 45      body_scale: [1, 1, 1]
 46      body_type: kinematic
 47      init_pos: [0.725, 0.0, 0.825]
 48  rigid_object:
 49    - uid: cup
 50      shape:
 51        shape_type: Mesh
 52        fpath: PourWaterAssets/cup.glb
 53        collision:
 54          approximation: convex_decomposition
 55          max_hulls: 16
 56      attrs:
 57        mass_props:
 58          mass: 0.03
 59        rigid_props:
 60          max_depenetration_velocity: 10.0
 61          min_position_iters: 32
 62          min_velocity_iters: 8
 63        collision_props:
 64          contact_offset: 0.003
 65          rest_offset: 0.001
 66        material_props:
 67          static_friction: 0.9
 68          dynamic_friction: 0.8
 69          restitution: 0.01
 70      init_pos: [0.75, 0.1, 0.921]
 71      body_scale: [1, 1, 1]
 72    - uid: bottle
 73      shape:
 74        shape_type: Mesh
 75        fpath: PourWaterAssets/bottle.glb
 76        collision:
 77          approximation: convex_decomposition
 78          max_hulls: 8
 79      attrs:
 80        mass_props:
 81          mass: 0.01
 82        rigid_props:
 83          max_depenetration_velocity: 10.0
 84          min_position_iters: 32
 85          min_velocity_iters: 8
 86        collision_props:
 87          contact_offset: 0.003
 88          rest_offset: 0.001
 89        material_props:
 90          restitution: 0.01
 91      init_pos: [0.75, -0.1, 0.962]
 92      body_scale: [1, 1, 1]
 93  rigid_object_group: []
 94  articulation: []
 95
 96env:
 97  # Update position targets at the physics cadence instead of holding each
 98  # target for four substeps, which produces in-hand acceleration impulses.
 99  target_control_frequency: 100
100  events:
101    settle_pour_objects_on_reset:
102      func: wait_for_dynamic_objects_to_settle
103      mode: reset
104      params:
105        entity_cfgs:
106          - uid: bottle
107          - uid: cup
108        min_steps: 10
109        max_steps: 180
110        check_interval_steps: 2
111        required_stable_checks: 3
112        timeout_behavior: raise
113  dataset:
114    lerobot:
115      func: LeRobotRecorder
116      mode: save
117      params:
118        robot_meta:
119          robot_type: CobotMagic
120        extra:
121          scene_type: Commercial
122          task_description: Pour water
123          data_type: sim
124        use_videos: true
125  control_parts: [left_arm, left_eef, right_arm, right_eef]

During config_to_cfg(), component paths are resolved relative to task.cobotmagic.yaml. The resolver expands the physical environment and embodiment, checks scene-binding UIDs and semantic contracts, and binds trusted provider identities into the otherwise embodiment-independent program.

Declare the semantic workflow#

The program describes Pick, transport, Pour, and Place without importing Python callables or naming simulator joints:

Pour Water Task Program
  1program_id: pour_water_with_right_arm
  2instruction: Pour water from the bottle into the cup and return the bottle to the table.
  3targets:
  4  bottle_return_pose:
  5    kind: pose
  6    position:
  7    - 0.75
  8    - -0.1
  9    - 0.962
 10    quaternion_xyzw:
 11    - 0.0
 12    - 0.0
 13    - 0.0
 14    - 1.0
 15  # Open above the support instead of driving a held bottle into the table.
 16  bottle_release_pose:
 17    kind: pose
 18    position:
 19    - 0.75
 20    - -0.1
 21    - 0.969
 22    quaternion_xyzw:
 23    - 0.0
 24    - 0.0
 25    - 0.0
 26    - 1.0
 27  cup_rest_pose:
 28    kind: pose
 29    position:
 30    - 0.75
 31    - 0.1
 32    - 0.921
 33    quaternion_xyzw:
 34    - 0.0
 35    - 0.0
 36    - 0.0
 37    - 1.0
 38program:
 39  kind: sequence
 40  items:
 41    - kind: segment
 42      name: pick_bottle
 43      instruction: Grasp and lift the bottle.
 44      contract:
 45        prerequisites:
 46          - {kind: released, ref: bottle}
 47        outcomes:
 48          - {kind: call_effect, ref: 0, assurance: projected}
 49          - {kind: held, ref: bottle}
 50          - {kind: validator, ref: 0}
 51          - {kind: unsupported, ref: physical_attachment, required: false}
 52      steps:
 53        kind: invoke
 54        call:
 55          kind: pick
 56          object: bottle
 57          grasp: bottle_grasp
 58      validators:
 59        - {kind: condition, ref: bottle_lifted}
 60    - kind: segment
 61      name: move_bottle_above_cup
 62      instruction: Move the held bottle above the cup.
 63      contract:
 64        prerequisites:
 65          - {kind: held, ref: bottle}
 66        outcomes:
 67          - {kind: call_effect, ref: 0, assurance: projected}
 68          - {kind: held, ref: bottle}
 69          - {kind: validator, ref: 0}
 70          - {kind: unsupported, ref: physical_attachment, required: false}
 71      steps:
 72        kind: invoke
 73        call:
 74          kind: registered
 75          call_id: simulation.move_held_object
 76          arguments:
 77            target: cup_pour_pose
 78      # Read the physical bottle pose before allowing the pour segment.
 79      validators:
 80        - {kind: condition, ref: bottle_above_cup}
 81    - kind: segment
 82      name: pour_water
 83      instruction: Tilt the bottle to pour water into the cup and return it upright.
 84      contract:
 85        prerequisites:
 86          - {kind: held, ref: bottle}
 87          - {kind: condition, ref: bottle_above_cup}
 88        outcomes:
 89          - {kind: call_effect, ref: 0, assurance: projected}
 90          - {kind: held, ref: bottle}
 91          - {kind: unsupported, ref: liquid_transfer, required: false}
 92      steps:
 93        kind: invoke
 94        call:
 95          kind: registered
 96          call_id: simulation.pour
 97          arguments:
 98            object: bottle
 99    - kind: segment
100      name: return_bottle
101      instruction: Place the bottle back on the table and release it.
102      contract:
103        prerequisites:
104          - {kind: held, ref: bottle}
105        outcomes:
106          - {kind: call_effect, ref: 0, assurance: projected}
107          - {kind: released, ref: bottle}
108          - {kind: post_policy, ref: 0}
109          - {kind: post_policy, ref: 1}
110          - {kind: validator, ref: 0}
111          - {kind: validator, ref: 1}
112          - {kind: unsupported, ref: physical_release, required: false}
113      steps:
114        kind: invoke
115        call:
116          kind: place
117          object: bottle
118          at:
119            kind: target_ref
120            target: bottle_release_pose
121      post:
122        - kind: wait_stable
123          entity: bottle
124        - kind: wait_stable
125          entity: cup
126      validators:
127        - kind: object_near_target
128          object: bottle
129          target: bottle_return_pose
130          position_tolerance: 0.05
131        - kind: object_near_target
132          object: cup
133          target: cup_rest_pose
134          position_tolerance: 0.002

The trusted integration maps bottle and cup to physical scene objects, selects the primary manipulator, configures action options, and allowlists the registered transport and pour lowerers:

Pour Water integration
 1integration_id: pour_water_v1
 2program_id: pour_water_with_right_arm
 3
 4requires:
 5  scene_contract: pour_water_scene_v1
 6  embodiment_contract: single_arm_parallel_gripper
 7
 8scene_binding:
 9  contract_id: pour_water_scene_v1
10  registry_id: task_program_pour_water
11  rigid_objects:
12    - entity_id: cup
13      dynamics: dynamic
14      semantic_type: cup
15    - entity_id: bottle
16      dynamics: dynamic
17      semantic_type: bottle
18      affordances:
19        - entity_id: bottle_grasp
20          kind: antipodal_grasp
21          # Wrist roll axis expressed in the bottle's grasp frame.
22          internal_axis: [0.8665034216893454, 0.49392778336146054, 0.07216068891225036]
23
24profile:
25  defaults:
26    pick_up:
27      primary: primary_manipulator
28    move_held_object:
29      primary: primary_manipulator
30    pour:
31      primary: primary_manipulator
32    place:
33      primary: primary_manipulator
34  skill_options:
35    pick:
36      kind: pick_up
37      hand_interp_steps: 44
38      grasp_settle_steps: 100
39      fixed_object_to_eef:
40        position: [0.035870254, 0.0204655528, 0.0321167707]
41        rotation_matrix:
42        - [-0.0530918874, 0.4963395894, 0.8665033579]
43        - [-0.0525476672, -0.8679134846, 0.493927747]
44        - [0.9972059727, -0.0193091929, 0.0721606836]
45    simulation.move_held_object:
46      kind: move_held_object
47    simulation.pour:
48      kind: pour
49      rotate_angle: -1.0471975511965976
50    place:
51      kind: place
52      hand_interp_steps: 44
53      release_settle_steps: 60
54      preserve_current_object_orientation: true
55  effect_monitors: {}
56
57runtime_services:
58  registered_semantic_lowerers:
59    - kind: move_held_object
60      target_id: cup_pour_pose
61      reference_entity_id: cup
62      relative_pose:
63        position: [0.027645135849048517, -0.053564902897726294, 0.18]
64        quaternion_xyzw: [0.0, 0.0, 0.0, 1.0]
65    - kind: pour
66      object_id: bottle

The program remains provider-independent. Simulation UIDs, grasp affordances, fixed object-to-end-effector transforms, and live target resolution stay in the trusted integration. For a detailed deployment walkthrough, see Configure and Run an Embodied Task Program; for constructing and compiling the language directly in Python, see Authoring a Task Program in Python.

Run the configured Task Program#

Pour Water already configures LeRobotRecorder in env.yaml, so its runnable deployment can record directly:

embodichain run-task \
    --gym_config embodichain/extensions/tasks/configs/tasks/manipulation/tableware/pour_water/task.cobotmagic.yaml \
    --headless \
    --max_episodes 1

The Task Program bridge plans and yields actions lazily. It never calls env.step(); stepping, annotations, validation, commit, retry, and discard remain owned by the shared environment rollout.

Configure Dataset Recording#

The expert paradigm and recorder configuration are independent. Add a dataset functor under env.dataset in an inline Gym config or in a reusable env.yaml environment component. The example below also declares a handwritten task’s overall goal; a Task Program declares that goal on its program root instead:

max_episodes: 5
max_episode_steps: 600

env:
  task_instruction: Pick and place the object.
  dataset:
    lerobot:
      func: LeRobotRecorder
      mode: save
      save_failed_episodes: false
      params:
        save_path: outputs/lerobot/expert_demos
        robot_meta:
          robot_type: CobotMagic
        extra:
          scene_type: tabletop
          task_description: pick_and_place
          data_type: sim
        use_videos: true

Important fields are:

  • env.task_instruction owns a handwritten task’s overall goal. Task Programs use root instruction in program.yaml. Segment instructions belong to the task’s DemoSegment values or program segments. Recorder instruction is a legacy fallback; see Task and segment language for expert data.

  • collection.target_episodes is the exact number of persisted environment rows, not the number of vector batches. The legacy max_episodes setting and --max_episodes option map to this target.

  • max_episode_steps must exceed the longest valid expert execution, including gripper holds and settling actions.

  • save_failed_episodes belongs beside func and mode. It defaults to false; when enabled, a failed or truncated attempt with recorded frames is committed with success=false metadata and counts toward collection.target_episodes.

  • params.save_path is the parent directory for auto-numbered datasets. If omitted, the default is ~/.cache/embodichain_datasets or the value of EMBODICHAIN_DATASET_ROOT.

  • params.use_videos controls RGB dataset videos. It has an effect only when image observations from configured sensors are present.

  • Dataset frequency is derived from env.step_dt and must be an integer number of frames per second for LeRobot.

The real Pour Water recorder block can be inspected directly:

 1  dataset:
 2    lerobot:
 3      func: LeRobotRecorder
 4      mode: save
 5      params:
 6        robot_meta:
 7          robot_type: CobotMagic
 8        extra:
 9          scene_type: Commercial
10          task_description: Pour water
11          data_type: sim
12        use_videos: true
13  control_parts: [left_arm, left_eef, right_arm, right_eef]

Execution, Validation, and Persistence#

Without --preview or --replay, embodichain run-task performs offline data expansion:

  1. Resolve create_demo_segments() from the handwritten task or configured Task Program bridge.

  2. Execute every yielded action through env.step(action) and record the resulting transition.

  3. Run the segment validator after its action iterable is exhausted.

  4. Check episode termination and final task success.

  5. Commit selected environment rows with an explicit reset, or discard the attempt with reset(options={"save_data": False}).

Failed attempts are discarded and retried by default, up to collection.max_attempts (with demo_max_attempts as a legacy fallback). Empty plans and exceptions are always discarded because they do not form a complete dataset transaction. With save_failed_episodes: true, a failed or truncated attempt is retained only when every selected row contains recorded frames.

collection.target_episodes controls the final dataset size and num_envs controls only the parallel width. If target_episodes=10 and num_envs=4, the runner uses three vector batches and commits only two rows from the final batch. The legacy --max_episodes option maps to the same target field.

For a configured Expansion task, keep the collection policy beside the task-facing expansion overrides:

runtime:
  num_envs: 16
  max_episode_steps: 1200
collection:
  target_episodes: 64
  max_attempts: 3
  selection:
    mode: sequential
    start_recipe_index: 0

Sequential selection consumes logical recipe IDs from the start index and automatically groups them into batches. Explicit selection is useful when a small, known set of recipes is required:

collection:
  target_episodes: 4
  selection:
    mode: explicit
    recipe_indices: [0, 16, 32, 48]

The explicit recipe list must contain exactly target_episodes entries. Recipe IDs identify logical candidates; they do not represent batch offsets.

Collection terms have one meaning across handwritten and Expansion tasks:

Collection terms#

Term

Meaning

episode

One environment row executed to completion and submitted as data.

attempt

One execution try. A failed attempt can be discarded and retried.

batch

The selected environment rows executed in one vectorized pass.

num_envs

The maximum number of rows available in one batch.

recipe_index

The stable logical ID of an Expansion candidate.

Changing num_envs changes the number of batches and the parallel capacity; it does not change target_episodes. A failed attempt and any prepare, commit, or discard reset also leave the target episode count unchanged.

Collection accounting distinguishes successful data rows from execution attempts. The expansion manifest records the target, planned, committed, and rejected episode counts, total attempts, batch count, and prepare, commit, and discard reset counts. Prepare reset runs before a batch, commit reset finalizes selected rows, and discard reset clears a failed attempt. Reset boundaries do not add episodes.

An episode is the complete task; a segment is one semantic subtask. Do not use generate_function(num_traj=...) to repeat subtasks: direct callers may pass only None or 1. Yield multiple DemoSegment objects instead so the task owns their order, live-state dependencies, and validation.

Useful modes and options are:

  • --headless disables the GUI for collection throughput.

  • --preview opens interactive inspection and does not save a dataset.

  • --filter_dataset_saving executes the expert while suppressing structured dataset writes.

  • --num_envs overrides collection parallelism.

  • --max_episodes overrides the configured collection.target_episodes.

  • collection.max_attempts controls retries for one selected batch.

See Running Tasks with run-task for preview, dataset recording, debug video, trajectory recording, and replay modes, and CLI Reference for the complete argument list.

Recorded Data#

LeRobotRecorder creates an auto-numbered dataset directory containing:

  • data/ for Parquet action, state, and annotation features;

  • videos/ for RGB observations when use_videos is enabled;

  • meta/ for LeRobot metadata, task/subtask mappings, and EmbodiChain episode metadata.

The primary fields include observation.state, action, and observation.images.{sensor_name}. Segment-aware episodes additionally record subtask_index and annotation.segment_* boundaries, plus terminal and truncation annotations. The overall goal resolves as sample["task"]; the current segment instruction resolves as sample["subtask"] through meta/subtasks.parquet. Both levels remain present in segment fragments. Depth and segmentation observations have their own numeric or configured sidecar representation; see Dataset Functors for the complete schema.

Inspect Recorded LeRobot Data#

Use EmbodiChain’s structural preview on the parent directory of auto-numbered datasets:

embodichain preview_lerobot_data \
    outputs/lerobot/expert_demos \
    --latest \
    --episode 0

For Pour Water without an explicit save_path, use the default parent:

embodichain preview_lerobot_data \
    ~/.cache/embodichain_datasets \
    --latest \
    --episode 0 \
    --expect-segments 4

The command validates frame and timestamp continuity, one episode-level task, subtask mappings, contiguous segment ranges, terminal annotations, and the EmbodiChain metadata sidecar. --expect-segments is an optional assertion; omit it when the expert’s segment count is data-dependent.

Use LeRobot’s lerobot-dataset-viz with the exact auto-numbered dataset directory when interactive Rerun plots and camera playback are needed. The EmbodiChain preview focuses on structure and annotations; it does not render images or time-series plots.

Validate and Prepare Training Data#

After finalizing collection, use the exact auto-numbered dataset root printed by the runner, rather than the parent used with preview’s --latest:

embodichain dataset validate /absolute/path/to/finalized-dataset \
    --media-frame-counts --output /tmp/expert-validation.json
embodichain dataset split /absolute/path/to/finalized-dataset \
    /tmp/expert-split.json --seed 42 --success-only

The split manifest keeps source episodes and their fragments/derivatives in one partition. Apply its episode indices explicitly in the training reader. If collection was interrupted, stop writers and diagnose commit evidence with embodichain dataset recover before requesting metadata repair.

See Validate, split, and recover expert datasets for parameters, quality evidence, provenance, report interpretation and recovery boundaries. Continue with Export expert data for LeRobot 0.6.1 to create an official LeRobot 0.6.1 language/depth dataset in a separate Python 3.12 environment.

Best Practices#

  • Keep planning and stepping separate: experts yield actions; the runner calls env.step().

  • Validate physical outcomes from live simulator state, not only planner success or projected semantic state.

  • Yield later subtasks lazily when they depend on object poses changed by earlier segments.

  • Smoke-test with --filter_dataset_saving before a long collection run, then inspect one committed episode before scaling num_envs.

  • Keep each task’s reusable environment component (or its envs/default.yaml and envs/newton.yaml variants), task.<embodiment>.yaml, and task_program/{program,integration}.yaml together so physical UIDs, contracts, and canonical IDs stay aligned. Keep task-facing expansion overrides under expansion/ and reusable embodiment and execution-policy components under configs/components/.

  • Move reusable motion behavior into Atomic Skills instead of copying task-local trajectory logic across Python tasks or registered Semantic Calls.