Robot class provides a standardized interface for interacting with physical robots in LeRobot. All robot implementations inherit from this abstract base class.
Class Definition
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
The configuration class expected for this robot type. Must be set in all subclasses.
The unique robot name used to identify this robot type. Must be set in all subclasses.
Constructor
Configuration object containing robot-specific settings including ID, calibration directory, and hardware parameters.
Abstract Properties
Subclasses must implement these properties:observation_features
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.,
floatfor joint position) - A tuple representing shape for array-type values (e.g.,
(height, width, channel)for images)
action_features
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
Whether the robot is currently connected. If False, calling
get_observation() or send_action() should raise an error.is_calibrated
Whether the robot is currently calibrated. Should always be True if calibration is not applicable.
Abstract Methods
Subclasses must implement these methods:connect
If True, automatically calibrate the robot after connecting if it’s not calibrated or needs calibration.
calibrate
calibration dictionary.
configure
get_observation
A flat dictionary representing the robot’s current sensory state. Structure should match
observation_features.send_action
Dictionary representing the desired action. Structure should match
action_features.The action actually sent to the motors, potentially clipped or modified by safety limits.
disconnect
Helper Methods
_load_calibration
Optional path to calibration file. Defaults to
self.calibration_fpath._save_calibration
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:src/lerobot/robots/utils.py:25
See Also
- LeRobotDataset - For recording robot data
- Processor API - For processing robot observations and actions