Dataset Functors#
This page lists all available dataset functors that can be used with the Dataset Manager. Dataset functors are configured using DatasetFunctorCfg and are responsible for collecting and saving episode data during environment interaction.
Recording Functors#
Functor Name |
Description |
|---|---|
|
Records episodes in LeRobot dataset format. Handles observation-action pair recording, format conversion, and episode saving. Requires LeRobot package to be installed. {"func": "LeRobotRecorder", "mode": "save",
"params": {"robot_meta": {"robot_type": "CobotMagic", "control_freq": 25},
"instruction": {"lang": "Pour water from bottle to cup"},
"extra": {"scene_type": "Commercial",
"task_description": "Pour water",
"data_type": "sim"},
"use_videos": true}}
|
LeRobotRecorder#
The LeRobotRecorder functor enables recording robot learning episodes in the LeRobot dataset format, which can be used for training with LeRobot’s imitation learning algorithms.
Features#
Records observation-action pairs during episodes
Converts data to LeRobot format automatically
Saves episodes when they complete
Supports vision sensors (camera images)
Supports robot state (qpos, qvel, qf)
Supports custom observation features
Auto-incrementing dataset naming
Parameters#
Parameter |
Description |
|---|---|
|
Root directory for saving datasets. Defaults to EmbodiChain’s default dataset root. |
|
Robot metadata for dataset (robot_type, control_freq, etc.) |
|
Optional task instruction (e.g., {“lang”: “pick the cube”}) |
|
Optional extra metadata (scene_type, task_description, episode_info) |
|
Whether to save videos (True) or images (False). Default: False. |
|
Number of threads for image writing |
|
Number of processes for image writing |
Recorded Data#
The LeRobotRecorder saves the following data for each frame:
observation.qpos: Joint positionsobservation.qvel: Joint velocitiesobservation.qf: Joint forces/torquesaction: Applied action{sensor_name}.color: Camera images (if sensors present){sensor_name}.color_right: Right camera images (for stereo cameras)
Usage Example#
from embodichain.lab.gym.envs.managers.cfg import DatasetFunctorCfg
# Example: Record episodes in LeRobot format
dataset = {
"lerobot_recorder": DatasetFunctorCfg(
func="embodichain.lab.gym.envs.managers.datasets.LeRobotRecorder",
params={
"save_path": "/path/to/dataset/root",
"robot_meta": {
"robot_type": "dexforce_w1",
"control_freq": 30,
},
"instruction": {
"lang": "pick the cube and place it on the target",
},
"extra": {
"scene_type": "table",
"task_description": "pick_and_place",
"episode_info": {
"rigid_object_physics_attributes": ["mass"],
},
},
"use_videos": False,
},
),
}
Recording Workflow#
Initialization: The Dataset Manager initializes the functor with the configured parameters
Data Collection: During episode rollout, the functor receives observations and actions
Save Trigger: When an episode completes, call the functor with
mode="save"Finalization: After all episodes, call
finalize()to save any remaining data
# Inside environment loop
if episode_done:
dataset_manager.apply(mode="save", env_ids=completed_env_ids)
# After training completes
dataset_manager.apply(mode="finalize")
Dataset Manager Modes#
The Dataset Manager supports the following modes:
save: Save completed episodes for specified environment IDsfinalize: Finalize the dataset and save any remaining data
See DatasetManager for more details.