Bring Your Own Hardware to Robot Lab

This guide explains how to add a new robot to Robot Lab. Robot Lab is based on LeRobot, so each hardware integration starts with LeRobot’s standard Robot, Teleoperator, and Camera interfaces. Robot Lab then adds a standardized record/replay workflow so each robot can be operated with the same commands:

uv run lerobot-record --record.type your_robot --dataset-root /path/to/dataset --task "task text"
uv run lerobot-replay --replay.type your_robot --root /path/to/dataset --episode 0

Keep hardware-specific code inside each robot module. Keep recording, dataset writing, and replay behavior consistent across the lab.

Prerequisites

Before writing Robot Lab code, make sure the robot can already be controlled from Python:

If the robot uses Feetech or Dynamixel motors, prefer LeRobot’s existing FeetechMotorsBus and DynamixelMotorsBus. For other hardware, use the vendor SDK or write a small Python wrapper around the device protocol.

Integration Layers

To use Robot Lab’s standard CLI workflow, implement the layers needed by lerobot-record and lerobot-replay:

  1. Cameras, if the robot needs a new camera SDK.
  2. A follower Robot.
  3. A Teleoperator, such as a leader arm, gamepad, keyboard, joystick, VR device, or another robot.
  4. A robot-specific Record subclass and LeRobot v2.1 dataset schema.
  5. A robot-specific Replay subclass.

Implement Cameras

If the robot needs a new camera backend, add:

src/lerobot/cameras/your_camera/
  __init__.py
  configuration_your_camera.py
  camera_your_camera.py

The config inherits from CameraConfig and registers a type:

from dataclasses import dataclass

from lerobot.cameras.configs import CameraConfig, ColorMode


@CameraConfig.register_subclass("your_camera")
@dataclass
class YourCameraConfig(CameraConfig):
    serial: str | None = None
    fps: int | None = 30
    width: int | None = 640
    height: int | None = 480
    color_mode: ColorMode = ColorMode.RGB

The camera class inherits from Camera and implements find_cameras(), is_connected, connect(), read_latest(), and disconnect(). For high-rate cameras, import the vendor SDK lazily, start a background capture thread in connect(), store the newest frame in a small thread-safe buffer, and make read_latest() return that buffered frame.

Expose both classes from __init__.py:

from .camera_your_camera import YourCamera
from .configuration_your_camera import YourCameraConfig

__all__ = ["YourCamera", "YourCameraConfig"]

Implement the Robot

The robot is the controlled device. It reads observations and receives actions.

src/lerobot/robots/your_robot/
  __init__.py
  config_your_robot.py
  your_robot.py
from dataclasses import dataclass, field

from lerobot.cameras import CameraConfig
from lerobot.robots.config import RobotConfig


@RobotConfig.register_subclass("your_robot")
@dataclass
class YourRobotConfig(RobotConfig):
    port: str = "/dev/ttyUSB0"
    cameras: dict[str, CameraConfig] = field(default_factory=dict)
from lerobot.cameras import make_cameras_from_configs
from lerobot.robots.robot import Robot

from .config_your_robot import YourRobotConfig


class YourRobot(Robot):
    config_class = YourRobotConfig
    name = "your_robot"

    def __init__(self, config: YourRobotConfig):
        super().__init__(config)
        self.config = config
        self.cameras = make_cameras_from_configs(config.cameras)
        self.sdk = None

    @property
    def observation_features(self) -> dict:
        return {
            "joint_1": float,
            "joint_2": float,
            "gripper": float,
            **{name: (cam.height, cam.width, 3) for name, cam in self.cameras.items()},
        }

    @property
    def action_features(self) -> dict:
        return {"joint_1": float, "joint_2": float, "gripper": float}

    @property
    def is_connected(self) -> bool:
        return self.sdk is not None and all(cam.is_connected for cam in self.cameras.values())

    @property
    def is_calibrated(self) -> bool:
        return True

    def connect(self, calibrate: bool = True) -> None:
        self.sdk = open_robot_sdk(self.config.port)
        for camera in self.cameras.values():
            camera.connect()
        if calibrate and not self.is_calibrated:
            self.calibrate()
        self.configure()

    def calibrate(self) -> None:
        pass

    def configure(self) -> None:
        configure_control_mode_and_gains(self.sdk)

    def get_observation(self) -> dict:
        observation = read_robot_state(self.sdk)
        for name, camera in self.cameras.items():
            observation[name] = camera.read_latest()
        return observation

    def send_action(self, action: dict) -> dict:
        sent_action = apply_safety_limits(action)
        send_robot_command(self.sdk, sent_action)
        return sent_action

    def disconnect(self) -> None:
        for camera in self.cameras.values():
            camera.disconnect()
        close_robot_sdk(self.sdk)
        self.sdk = None

observation_features and action_features must work before connecting hardware. get_observation() must return keys that match observation_features. send_action() must accept keys that match action_features and return the final action actually sent, especially if the robot clips, scales, smooths, or safety-limits commands.

Implement the Teleoperator

The teleoperator produces human control actions.

src/lerobot/teleoperators/your_teleop/
  __init__.py
  config_your_teleop.py
  your_teleop.py
from dataclasses import dataclass

from lerobot.teleoperators.config import TeleoperatorConfig


@TeleoperatorConfig.register_subclass("your_teleop")
@dataclass
class YourTeleopConfig(TeleoperatorConfig):
    port: str = "/dev/ttyUSB1"

The teleoperator class inherits from Teleoperator and implements action_features, feedback_features, is_connected, connect(), disconnect(), is_calibrated, calibrate(), configure(), get_action(), and send_feedback(). For leader-follower robots, get_action() should usually produce the same action keys that the follower robot expects in send_action(). If feedback is not supported, return {} from feedback_features and make send_feedback() a no-op.

Implement Standardized Recording

Robot Lab does not put every teleoperation script under scripts/. Each robot implements a Record subclass, and the shared CLI calls it through --record.type.

src/lerobot/recording/your_robot_record/
  __init__.py
  config_your_robot_record.py
  your_robot_record.py
from dataclasses import dataclass

from lerobot.recording.config import RecordConfig


@RecordConfig.register_subclass("your_robot")
@dataclass(kw_only=True)
class YourRobotRecordConfig(RecordConfig):
    home_time: float = 4.0

The file and class names are part of automatic discovery:

Define the dataset schema beside the record class:

from lerobot.recording.utils import (
    LerobotV21CameraSchema,
    LerobotV21ColumnSchema,
    LerobotV21DatasetSchema,
)


DATASET_SCHEMA = LerobotV21DatasetSchema(
    robot_type="your_robot",
    vector_names=("joint_1", "joint_2", "joint_3", "gripper"),
    cameras=(
        LerobotV21CameraSchema(name="cam_front", width=640, height=480, codec="h264"),
        LerobotV21CameraSchema(name="wrist_camera", width=640, height=480, codec="h264"),
    ),
    extra_columns=(
        LerobotV21ColumnSchema.vector(
            "observation.velocity",
            ("joint_1", "joint_2", "joint_3", "gripper"),
        ),
        LerobotV21ColumnSchema(name="observation.ee_pose", dtype="float32", shape=(7,)),
    ),
)

Use cameras=() for robots without cameras. Declare only extra numeric columns that the writer should store.

from lerobot.recording.record import Record, RecordFrame


class YourRobotRecord(Record):
    config_class = YourRobotRecordConfig
    name = "your_robot"

    def dataset_schema(self) -> LerobotV21DatasetSchema:
        return DATASET_SCHEMA

    def setup_devices(self) -> None:
        self.robot = YourRobot(...)
        self.teleop = YourTeleop(...)

    def connect_devices(self) -> None:
        self.robot.connect()
        self.teleop.connect()

    def after_connect(self) -> None:
        pass

    def move_home(self, label: str) -> None:
        move_robot_and_teleop_to_safe_home(label)

    def release_for_recording(self) -> None:
        switch_teleop_to_live_control_mode()

    def record_step(self) -> RecordFrame | None:
        action = self.teleop.get_action()
        sent_action = self.robot.send_action(action)
        observation = self.robot.get_observation()

        if should_skip_this_frame(action, observation):
            return None

        return RecordFrame(
            qpos=vector_from_observation(observation),
            action=vector_from_action(sent_action),
            observation=observation,
            extra_columns=extra_columns_from_robot(self.robot),
        )

    def devices_connected(self) -> bool:
        return self.robot.is_connected or self.teleop.is_connected

    def disconnect_devices(self) -> None:
        self.teleop.disconnect()
        self.robot.disconnect()

    def after_disconnect(self) -> None:
        pass

record_step() runs in a background thread during recording. Keep it fast, deterministic, and safe. It should read the operator command, send the command, read state and cameras, optionally skip startup frames, and return a RecordFrame.

Implement Standardized Replay

Each robot also implements a Replay subclass so a saved episode can be sent back to hardware:

uv run lerobot-replay --replay.type your_robot --root /path/to/dataset --episode 0
src/lerobot/replay/your_robot_replay/
  __init__.py
  config_your_robot_replay.py
  your_robot_replay.py
from dataclasses import dataclass

from lerobot.replay.config import ReplayConfig


@ReplayConfig.register_subclass("your_robot")
@dataclass(kw_only=True)
class YourRobotReplayConfig(ReplayConfig):
    targets: str = "action"

Implement validate_replay(), load_episode(), print_status(), setup_devices(), connect_devices(), after_connect(), align_to_start(), replay_step(), move_home_after_replay(), devices_connected(), disconnect_devices(), and after_disconnect().

from lerobot.replay.replay import Replay, ReplayEpisode


class YourRobotReplay(Replay):
    config_class = YourRobotReplayConfig
    name = "your_robot"

    def validate_replay(self) -> None:
        validate_dataset_root_and_episode_index(self.config)

    def load_episode(self) -> ReplayEpisode:
        vectors, names, metadata = load_vectors_from_lerobot_v21_dataset(self.config)
        return ReplayEpisode(vectors=vectors, names=names, metadata=metadata)

    def print_status(self, episode: ReplayEpisode) -> None:
        print_replay_summary(episode)

    def setup_devices(self) -> None:
        self.robot = YourRobot(...)

    def connect_devices(self) -> None:
        self.robot.connect()

    def after_connect(self) -> None:
        pass

    def align_to_start(self, episode: ReplayEpisode) -> None:
        move_safely_from_current_pose_to(episode.vectors[0])

    def replay_step(self, local_idx: int, vector, episode: ReplayEpisode) -> None:
        self.robot.send_action(action_from_vector(vector, episode.names))

    def move_home_after_replay(self) -> None:
        move_robot_to_safe_home()

    def devices_connected(self) -> bool:
        return self.robot.is_connected

    def disconnect_devices(self) -> None:
        self.robot.disconnect()

    def after_disconnect(self) -> None:
        pass
Recording currently uses automatic discovery based on `--record.type`. In this checkout, replay support is still registered explicitly in `src/lerobot/replay/utils.py` and `src/lerobot/scripts/lerobot_replay.py`. Add your replay config and factory branch there, or first extend replay to use the same automatic discovery pattern as recording.

Use the Standard CLI

After the required interfaces are implemented and registered, record a dataset:

uv run lerobot-record --record.type your_robot --dataset-root /path/to/new_dataset --task "task text"

Replay an episode:

uv run lerobot-replay --replay.type your_robot --root /path/to/dataset --episode 0

Run a short hardware smoke test before long recording sessions: connect, home, record a few frames, save one episode, replay it slowly with --slow-down 2.0, and verify the final action values match the commands actually sent to the robot.