Skip to main content
The Robot class provides a standardized interface for interacting with physical robots in LeRobot. All robot implementations inherit from this abstract base class.

Class Definition

Location: src/lerobot/robots/robot.py:30

Overview

The Robot class is an abstract base that defines the core interface for robot control in LeRobot. It handles:
  • Connection management (connect/disconnect)
  • Motor calibration
  • Observation retrieval
  • Action execution
  • Configuration management

Class Attributes

type[RobotConfig]
required
The configuration class expected for this robot type. Must be set in all subclasses.
str
required
The unique robot name used to identify this robot type. Must be set in all subclasses.

Constructor

RobotConfig
required
Configuration object containing robot-specific settings including ID, calibration directory, and hardware parameters.

Abstract Properties

Subclasses must implement these properties:

observation_features

dict
A dictionary describing the structure and types of observations produced by the robot.Keys should match the structure returned by get_observation(). Values should be either:
  • The type of the value for simple values (e.g., float for joint position)
  • A tuple representing shape for array-type values (e.g., (height, width, channel) for images)
This property must be callable regardless of connection state.

action_features

dict
A dictionary describing the structure and types of actions expected by the robot.Keys should match the structure passed to send_action(). Values should be the type of the value (e.g., float for joint goal position).This property must be callable regardless of connection state.

is_connected

bool
Whether the robot is currently connected. If False, calling get_observation() or send_action() should raise an error.

is_calibrated

bool
Whether the robot is currently calibrated. Should always be True if calibration is not applicable.

Abstract Methods

Subclasses must implement these methods:

connect

Establish communication with the robot.
bool
default:"True"
If True, automatically calibrate the robot after connecting if it’s not calibrated or needs calibration.

calibrate

Calibrate the robot if applicable. Should be a no-op if calibration is not needed. This method should collect necessary data (e.g., motor offsets) and update the calibration dictionary.

configure

Apply any one-time or runtime configuration to the robot. May include setting motor parameters, control modes, or initial state.

get_observation

Retrieve the current observation from the robot.
dict
A flat dictionary representing the robot’s current sensory state. Structure should match observation_features.

send_action

Send an action command to the robot.
RobotAction
required
Dictionary representing the desired action. Structure should match action_features.
dict
The action actually sent to the motors, potentially clipped or modified by safety limits.

disconnect

Disconnect from the robot and perform any necessary cleanup.

Helper Methods

_load_calibration

Load calibration data from a file.
Path | None
Optional path to calibration file. Defaults to self.calibration_fpath.

_save_calibration

Save calibration data to a file.
Path | None
Optional path to save calibration file. Defaults to self.calibration_fpath.

Context Manager

The Robot class supports context manager protocol for automatic resource management:

Example Implementation

Factory Function

Use the factory function to create robots from configuration:
Location: src/lerobot/robots/utils.py:25

See Also