Documentation Index
Fetch the complete documentation index at: https://mintlify.com/huggingface/lerobot/llms.txt
Use this file to discover all available pages before exploring further.
Overview
LeRobot provides a standardizedRobot abstract base class that defines a unified interface for interacting with physical robots. This abstraction allows you to work with different robot hardware using the same API, making your code portable across platforms.
The Robot Class
All LeRobot-compatible robots inherit from theRobot base class, which provides a consistent interface for:
- Connection management: Connect/disconnect from hardware
- Calibration: Store and load motor calibration data
- Observations: Read sensor data and camera images
- Actions: Send motor commands to the robot
Class Structure
Every robot implementation must define:src/lerobot/robots/robot.py:30
Core Methods
Connection Lifecycle
connect()
Establishes communication with the robot hardware:calibrate(bool): If True, automatically calibrate the robot after connecting if needed
src/lerobot/robots/robot.py:125
disconnect()
Cleanly disconnects from the robot and releases resources:src/lerobot/robots/robot.py:209
Context Manager Support
TheRobot class supports Python’s context manager protocol for automatic cleanup:
src/lerobot/robots/robot.py:61
Observations and Actions
get_observation()
Retrieves the current state from the robot’s sensors:RobotObservation: A flat dictionary containing:- Motor positions (e.g.,
"shoulder_pan.pos": 0.5) - Camera images (e.g.,
"camera_top": numpy.ndarray) - Other sensor readings
- Motor positions (e.g.,
observation_features.
Source: src/lerobot/robots/robot.py:182
send_action()
Sends action commands to the robot:action(RobotAction): Dictionary of motor commands matchingaction_features
RobotAction: The action actually sent (may be clipped by safety limits)
src/lerobot/robots/robot.py:194
Feature Definitions
observation_features
Describes the structure of observations produced by the robot:get_observation() returns. Values are either:
- A type (e.g.,
float) for scalar values - A tuple (e.g.,
(480, 640, 3)) for array shapes
src/lerobot/robots/robot.py:88
action_features
Describes the structure of actions expected by the robot:src/lerobot/robots/robot.py:102
Calibration
Robots with motors typically need calibration to map between raw motor positions and normalized values.calibrate()
Runs the calibration procedure:- Collects calibration data (e.g., motor offsets, range limits)
- Updates the
calibrationdictionary - Typically saves to disk
src/lerobot/robots/robot.py:142
Calibration Storage
Calibration data is stored in JSON format at:src/lerobot/robots/robot.py:54
Example: SO-100 Follower Robot
Here’s a real-world example of the Robot interface in action:src/lerobot/robots/so_follower/so_follower.py:37
Key Properties
is_connected
Check if the robot is currently connected:src/lerobot/robots/robot.py:116
is_calibrated
Check if the robot has valid calibration:src/lerobot/robots/robot.py:136
Best Practices
Next Steps
- Learn about Processors for transforming observations and actions
- Explore Policies for generating actions from observations
- See LeRobotDataset for recording and replaying robot data