机器人

LeRobot 中的每个机器人都实现了 Robot 接口:连接、读取 observation、发送 action、 断开连接。针对该接口编写 policy 或录制脚本,意味着它无需修改即可适用于任何受支持的 机械臂。

本页是生成的参考文档。关于接线、calibration 和首次运行的说明,请从 硬件指南开始——SO-101LeKiwiHope JrReachy 2OpenArm——或查看机器人模仿学习了解端到端工作流程。要添加 你自己的机器人,请参阅接入你自己的硬件

Robot

抽象基类。子类实现下面的每个方法;这里描述的契约是 policy 或录制循环可以依赖的。

class lerobot.robots.Robot

< >

( config: RobotConfig )

参数

  • config_class (RobotConfig) — 此机器人预期的配置类。
  • name (str) — 用于标识此机器人类型的唯一机器人名称。

所有与 LeRobot 兼容的机器人的基础抽象类。

此类提供了用于与物理机器人交互的标准化接口。 子类必须实现所有抽象方法和属性才能使用。

connect

< >

( calibrate: bool = True )

参数

  • calibrate (bool) — 如果为 True,则在连接后,如果机器人未 calibration 或需要 calibrate,则自动对其进行 calibration(这取决于硬件)。

与机器人建立通信。

disconnect

< >

( )

与机器人断开连接并执行任何必要的清理。

configure

< >

( )

对机器人应用任何一次性或运行时配置。 这可能包括设置电机参数、控制模式或初始 state。

calibrate

< >

( )

如适用则 calibrate 机器人。否则,这应为空操作。

此方法应收集任何必要的数据(例如电机偏移量),并相应更新 :pyattr:calibration 字典。

get_observation

< >

( ) RobotObservation

返回

RobotObservation

表示机器人当前感官 state 的扁平字典。其结构 应与 :pymeth:observation_features 匹配。

从机器人检索当前 observation。

send_action

< >

( action: dict ) RobotAction

参数

  • action (RobotAction) — 表示期望 action 的字典。其结构应与 :pymeth:action_features 匹配。

返回

RobotAction

实际发送给电机、可能被裁剪或修改的 action,例如受 速度安全限制。

向机器人发送 action 命令。

observation_features

< >

( )

描述机器人所产生 observation 的结构和类型的字典。 其结构(键)应与 :pymeth:get_observation 返回的结构匹配。 该字典的值应为以下之一:

  • 如果值是简单值,则为该值的类型,例如单一本体感受值(关节的位置/速度)用 float
  • 如果值是数组类型,则表示形状的元组,例如图像用 (height, width, channel)

注意:无论机器人是否已连接,都应能调用此属性。

action_features

< >

( )

描述机器人所期望 action 的结构和类型的字典。其结构 (键)应与传递给 :pymeth:send_action 的结构匹配。该字典的值 应为:如果值是简单值,则为该值的类型,例如单一本体感受值 (关节的目标位置/速度)用 float

注意:无论机器人是否已连接,都应能调用此属性。

is_connected

< >

( )

机器人当前是否已连接。如果为 False,调用 :pymeth:get_observation 或 :pymeth:send_action 应抛出错误。

is_calibrated

< >

( )

机器人当前是否已 calibration。如不适用,应始终为 True

RobotConfig

class lerobot.robots.RobotConfig

< >

( id: str | None = Nonecalibration_dir: pathlib.Path | None = None )

make_robot_from_config

lerobot.robots.make_robot_from_config

< >

( config: RobotConfig )

SO-100 和 SO-101 follower arm

SO100FollowerSO101Follower 是同一个 SOFollower 类的别名;这两款机械臂的区别在于它们的 配置,而非控制代码。SO100FollowerConfigSO101FollowerConfig 同样是 SOFollowerRobotConfig 的 别名。

class lerobot.robots.so_follower.SOFollower

< >

( config: SOFollowerRobotConfig )

通用 SO follower arm 基类,实现了 SO-100/101/10X 的通用功能。 设计为通过每种硬件型号的 config_classname 进行子类化。

connect

< >

( calibrate: bool = True )

我们假设在连接时,机械臂处于静止位置, 并且可以安全地禁用力矩以运行 calibration。

send_action

< >

( action: dict ) RobotAction

返回

RobotAction

发送给电机、可能被裁剪的 action。

抛出异常

RobotDeviceNotConnectedError

  • RobotDeviceNotConnectedError — 如果机器人未连接。

命令机械臂移动到目标关节配置。

relative action 幅度可能会根据配置参数 max_relative_target 进行裁剪。在这种情况下,发送的 action 与原始 action 不同。 因此,此函数始终返回实际发送的 action。

class lerobot.robots.so_follower.SOFollowerRobotConfig

< >

( port: strdisable_torque_on_disconnect: bool = Truemax_relative_target: float | dict[str, float] | None = Nonecameras: dict = <factory>use_degrees: bool = Trueposition_p_coefficient: int = 16position_i_coefficient: int = 0position_d_coefficient: int = 32num_read_retries: int = 2id: str | None = Nonecalibration_dir: pathlib.Path | None = None )

BiSOFollower

两个 SO follower arm 作为一个双臂机器人驱动。

class lerobot.robots.bi_so_follower.BiSOFollower

< >

( config: BiSOFollowerConfig )

由 TheRobotStudio 设计的双臂 SO follower arm

class lerobot.robots.bi_so_follower.BiSOFollowerConfig

< >

( left_arm_config: SOFollowerConfigright_arm_config: SOFollowerConfigcameras: dict = <factory>id: str | None = Nonecalibration_dir: pathlib.Path | None = None )

Bi SO Follower 机器人的配置类。

KochFollower

class lerobot.robots.koch_follower.KochFollower

< >

( config: KochFollowerConfig )

connect

< >

( calibrate: bool = True )

我们假设在连接时,机械臂处于静止位置, 并且可以安全地禁用力矩以运行 calibration。

send_action

< >

( action: dict ) RobotAction

参数

  • action (RobotAction) — 电机的目标位置。

返回

RobotAction

发送给电机、可能被裁剪的 action。

命令机械臂移动到目标关节配置。

relative action 幅度可能会根据配置参数 max_relative_target 进行裁剪。在这种情况下,发送的 action 与原始 action 不同。 因此,此函数始终返回实际发送的 action。

class lerobot.robots.koch_follower.KochFollowerConfig

< >

( port: strdisable_torque_on_disconnect: bool = Truemax_relative_target: float | dict[str, float] | None = Nonecameras: dict = <factory>use_degrees: bool = Falseid: str | None = Nonecalibration_dir: pathlib.Path | None = None )

LeKiwi

LeKiwi 在机器人本身上运行。LeKiwiClient 是主机端代理,它通过网络与其通信 并呈现相同的 Robot 接口。

class lerobot.robots.lekiwi.LeKiwi

< >

( config: LeKiwiConfig )

该机器人包含一个三轮全向移动底座和一个远程 follower arm。 leader arm 本地连接(在笔记本电脑上),其关节位置被记录,然后 (在应用安全钳制后)转发给远程 follower arm。 同时,使用键盘 teleoperation 为轮子生成原始速度命令。

send_action

< >

( action: dict ) RobotAction

返回

RobotAction

发送给电机、可能被裁剪的 action。

抛出异常

RobotDeviceNotConnectedError

  • RobotDeviceNotConnectedError — 如果机器人未连接。

命令 LeKiwi 移动到目标关节配置。

relative action 幅度可能会根据配置参数 max_relative_target 进行裁剪。在这种情况下,发送的 action 与原始 action 不同。 因此,此函数始终返回实际发送的 action。

class lerobot.robots.lekiwi.LeKiwiConfig

< >

( port: str = '/dev/ttyACM0'disable_torque_on_disconnect: bool = Truemax_relative_target: float | dict[str, float] | None = Nonecameras: dict = <factory>use_degrees: bool = Truenum_read_retries: int = 2id: str | None = Nonecalibration_dir: pathlib.Path | None = None )

class lerobot.robots.lekiwi.LeKiwiClient

< >

( config: LeKiwiClientConfig )

connect

< >

( )

与远程移动机器人建立 ZMQ 套接字

disconnect

< >

( )

清理 ZMQ 通信

get_observation

< >

( )

从远程机器人捕获 observation:当前 follower arm 位置、 当前轮速(转换为机体坐标系速度:x、y、theta), 以及一帧相机画面。通过 ZMQ 接收,并转换为机体坐标系速度

send_action

< >

( action: dict ) np.ndarray

参数

  • action (RobotAction) — 包含电机目标位置的数组。

返回

np.ndarray

发送给电机、可能被裁剪的 action。

抛出异常

RobotDeviceNotConnectedError

  • RobotDeviceNotConnectedError — 如果机器人未连接。

命令 LeKiwi 移动到目标关节配置。转换为电机空间并通过 ZMQ 发送

class lerobot.robots.lekiwi.LeKiwiClientConfig

< >

( remote_ip: strport_zmq_cmd: int = 5555port_zmq_observations: int = 5556teleop_keys: dict = <factory>cameras: dict = <factory>polling_timeout_ms: int = 15connect_timeout_s: int = 5id: str | None = Nonecalibration_dir: pathlib.Path | None = None )

OpenArmFollower

class lerobot.robots.openarm_follower.OpenArmFollower

< >

( config: OpenArmFollowerConfig )

OpenArms follower arm 机器人,使用 CAN 总线通信控制带 gripper 的 7 自由度机械臂。 该机械臂使用 MIT 控制模式下的 Damiao 电机。

calibrate

< >

( )

为 OpenArms 机器人运行 calibration 程序。

calibration 程序:

  1. 禁用力矩
  2. 要求用户将机械臂置于下垂位置并闭合 gripper
  3. 将此设置为零位
  4. 记录每个关节的运动范围
  5. 保存 calibration

configure

< >

( )

使用适当的设置配置电机。

connect

< >

( calibrate: bool = True )

连接到机器人并可选择进行 calibration。

我们假设在连接时,机械臂处于安全的静止位置, 并且如果需要,可以安全地禁用力矩以运行 calibration。

disconnect

< >

( )

与机器人断开连接。

get_observation

< >

( )

从机器人获取当前 observation,包括位置、速度和力矩。

在一次 CAN 刷新周期内读取所有电机 state(位置/速度/力矩), 而不是进行 3 次单独的读取。

send_action

< >

( action: dictcustom_kp: dict[str, float] | None = Nonecustom_kd: dict[str, float] | None = None )

参数

  • action — 包含电机位置的字典(例如 “joint_1.pos”、“joint_2.pos”)
  • custom_kp — 可选的每个电机自定义 kp 增益(例如 {“joint_1”: 120.0, “joint_2”: 150.0})
  • custom_kd — 可选的每个电机自定义 kd 增益(例如 {“joint_1”: 1.5, “joint_2”: 2.0})

向机器人发送 action 命令。

action 幅度可能会根据安全限制被裁剪。

class lerobot.robots.openarm_follower.OpenArmFollowerConfig

< >

( port: strside: str | None = Nonecan_interface: str = 'socketcan'use_can_fd: bool = Truecan_bitrate: int = 1000000can_data_bitrate: int = 5000000disable_torque_on_disconnect: bool = Trueuse_velocity_and_torque: bool = Falsemax_relative_target: float | dict[str, float] | None = Nonecameras: dict = <factory>motor_config: dict = <factory>position_kp: list = <factory>position_kd: list = <factory>joint_limits: dict = <factory>id: str | None = Nonecalibration_dir: pathlib.Path | None = None )

BiOpenArmFollower

class lerobot.robots.bi_openarm_follower.BiOpenArmFollower

< >

( config: BiOpenArmFollowerConfig )

双臂 OpenArm follower arm

class lerobot.robots.bi_openarm_follower.BiOpenArmFollowerConfig

< >

( id: str | None = 'bi_openarm_follower'calibration_dir: pathlib.Path | None = Noneleft_arm_config: OpenArmFollowerConfigBaseright_arm_config: OpenArmFollowerConfigBasecameras: dict = <factory> )

Bi OpenArm Follower 机器人的配置类。

OmxFollower

class lerobot.robots.omx_follower.OmxFollower

< >

( config: OmxFollowerConfig )

  • OMX, 扩展件,由 ROBOTIS 的 Woojin Wie 和 Junha Cha 开发

connect

< >

( calibrate: bool = True )

对于出厂已 calibration 的 OMX 机器人:

  • 如果软件包中的默认 calibration 与电机不匹配,则从电机读取并保存
  • 这样就能使用预 calibration 的机器人,无需手动 calibrate
  • 如果不存在 calibration 文件,则使用出厂默认值(homing_offset=0、range_min=0、range_max=4095)

send_action

< >

( action: dict ) RobotAction

参数

  • action (RobotAction) — 电机的目标位置。

返回

RobotAction

发送给电机、可能被裁剪的 action。

命令机械臂移动到目标关节配置。

relative action 幅度可能会根据配置参数 max_relative_target 进行裁剪。在这种情况下,发送的 action 与原始 action 不同。 因此,此函数始终返回实际发送的 action。

class lerobot.robots.omx_follower.OmxFollowerConfig

< >

( port: strdisable_torque_on_disconnect: bool = Truemax_relative_target: float | dict[str, float] | None = Nonecameras: dict = <factory>use_degrees: bool = Falseid: str | None = Nonecalibration_dir: pathlib.Path | None = None )

Reachy2Robot

class lerobot.robots.reachy2.Reachy2Robot

< >

( config: Reachy2RobotConfig )

Reachy 2,由 Pollen Robotics 开发。

class lerobot.robots.reachy2.Reachy2RobotConfig

< >

( max_relative_target: float | None = Noneip_address: str | None = 'localhost'port: int = 50065disable_torque_on_disconnect: bool = Falseuse_external_commands: bool = Falsewith_mobile_base: bool = Truewith_l_arm: bool = Truewith_r_arm: bool = Truewith_neck: bool = Truewith_antennas: bool = Truewith_left_teleop_camera: bool = Falsewith_right_teleop_camera: bool = Falsewith_torso_camera: bool = Falsecamera_width: int = 640camera_height: int = 480cameras: dict = <factory>id: str | None = Nonecalibration_dir: pathlib.Path | None = None )

UnitreeG1

class lerobot.robots.unitree_g1.UnitreeG1

< >

( config: UnitreeG1Config )

class lerobot.robots.unitree_g1.UnitreeG1Config

< >

( kp: list = <factory>kd: list = <factory>default_positions: list = <factory>control_dt: float = 0.004is_simulation: bool = Truerobot_ip: str = '192.168.123.164'cameras: dict = <factory>gravity_compensation: bool = Falsecontroller: str | None = Noneid: str | None = Nonecalibration_dir: pathlib.Path | None = None )

Hope Jr

Hope Jr 人形机器人以两个独立的机器人形式呈现:一个臂和一个手。

class lerobot.robots.hope_jr.HopeJrArm

< >

( config: HopeJrArmConfig )

connect

< >

( calibrate: bool = True )

我们假设在连接时,机械臂处于静止位置, 并且可以安全地禁用力矩以运行 calibration。

class lerobot.robots.hope_jr.HopeJrArmConfig

< >

( port: strdisable_torque_on_disconnect: bool = Truemax_relative_target: float | dict[str, float] | None = Nonecameras: dict = <factory>id: str | None = Nonecalibration_dir: pathlib.Path | None = None )

class lerobot.robots.hope_jr.HopeJrHand

< >

( config: HopeJrHandConfig )

class lerobot.robots.hope_jr.HopeJrHandConfig

< >

( port: strside: strdisable_torque_on_disconnect: bool = Truecameras: dict = <factory>id: str | None = Nonecalibration_dir: pathlib.Path | None = None )

RebotB601Follower

class lerobot.robots.rebot_b601_follower.RebotB601Follower

< >

( config: RebotB601FollowerRobotConfig )

Seeed Studio reBot B601-DM follower arm(6 自由度 + gripper,Damiao CAN 电机)。

电机通信由 motorbridge 软件包通过 CAN 总线处理, 可通过 Damiao 串行桥接器或 SocketCAN 适配器接入。

disable_torque

< >

( )

禁用电机的力矩,以便可以用手移动机械臂(只读调试)。

send_action

< >

( action: dict )

命令机械臂移动到目标关节配置。

位置以度为单位表示。relative action 幅度可能会 根据 max_relative_target 被裁剪,因此始终返回实际发送的 action。

class lerobot.robots.rebot_b601_follower.RebotB601FollowerRobotConfig

< >

( port: strcan_adapter: str = 'damiao'dm_serial_baud: int = 921600disable_torque_on_disconnect: bool = Truemax_relative_target: float | dict[str, float] | None = Nonecameras: dict = <factory>motor_can_ids: dict = <factory>pos_vel_velocity: float | list[float] = <factory>control_mode: str = 'mit'mit_kp: float | list[float] = <factory>mit_kd: float | list[float] = <factory>gripper_control_mode: str = 'force_pos'gripper_torque_ratio: float = 0.07gripper_mit_kp: float = 8.0gripper_mit_kd: float = 0.3joint_limits: dict = <factory>id: str | None = Nonecalibration_dir: pathlib.Path | None = None )

reBot B601-DM follower arm 机器人注册的配置。

BiRebotB601Follower

class lerobot.robots.bi_rebot_b601_follower.BiRebotB601Follower

< >

( config: BiRebotB601FollowerConfig )

双臂 Seeed Studio reBot B601-DM follower arm。

组合两个单臂 RebotB601Follower 实例。每个臂的 observation 和 action 键都带有 left_ / right_ 前缀命名空间。

class lerobot.robots.bi_rebot_b601_follower.BiRebotB601FollowerConfig

< >

( left_arm_config: RebotB601FollowerConfigright_arm_config: RebotB601FollowerConfigcameras: dict = <factory>id: str | None = Nonecalibration_dir: pathlib.Path | None = None )

双臂 reBot B601-DM follower arm 机器人的配置类。

EarthRoverMiniPlus

class lerobot.robots.earthrover_mini_plus.EarthRoverMiniPlus

< >

( config: EarthRoverMiniPlusConfig )

参数

  • config — 机器人配置
  • sdk_base_url — Frodobots SDK 服务器的基础 URL,取自 config.sdk_url(默认:http://localhost:8000)

通过 Frodobots SDK HTTP API 控制的 EarthRover Mini Plus 机器人。

该机器人通过 Frodobots SDK 使用基于云的控制,而非直接的 硬件连接。相机通过 Agora 云经 WebRTC 传输,控制 命令通过 HTTP POST 请求发送。

该机器人支持:

  • 通过 SDK HTTP 端点访问的双相机(前和后)
  • 线速度和角速度控制
  • 电池和方向遥测

calibrate

< >

( )

基于 SDK 的机器人无需 calibration。

configure

< >

( )

配置机器人(对基于 SDK 的机器人为空操作)。

connect

< >

( calibrate: bool = True )

参数

  • calibrate — 不用于基于 SDK 的机器人(为 API 兼容性而保留)

抛出异常

DeviceAlreadyConnectedError or DeviceNotConnectedError

  • DeviceAlreadyConnectedError — 如果机器人已连接
  • DeviceNotConnectedError — 如果无法连接到 SDK 服务器

通过 Frodobots SDK 连接到机器人。

disconnect

< >

( )

抛出异常

DeviceNotConnectedError

  • DeviceNotConnectedError — 如果机器人未连接

与机器人断开连接。

停止机器人并关闭与 SDK 的连接。

get_observation

< >

( ) RobotObservation

返回

RobotObservation

包含以下内容的 observation:

  • front:RGB 格式的前相机图像 (480, 640, 3)
  • rear:RGB 格式的后相机图像 (480, 640, 3)
  • speed: float - 当前速度(原始 SDK 值)
  • battery_level: float - 电池电量 (0-100)
  • orientation: float - 机器人方向(以度为单位)
  • gps_latitude: float - GPS 纬度坐标
  • gps_longitude: float - GPS 经度坐标
  • gps_signal: float - GPS 信号强度(百分比)
  • signal_level: float - 网络信号级别 (0-5)
  • vibration: float - 振动传感器读数
  • lamp: float - 灯的 state(0=关,1=开)
  • accelerometer_x/y/z: float - 加速度计各轴(原始 SDK 值)
  • gyroscope_x/y/z: float - 陀螺仪各轴(原始 SDK 值)
  • magnetometer_filtered_x/y/z: float - 磁力计各轴(原始 SDK 值)
  • wheel_rpm_0/1/2/3: float - 轮子转速

抛出异常

DeviceNotConnectedError

  • DeviceNotConnectedError — 如果机器人未连接

从 SDK 获取当前机器人 observation。

相机帧从 SDK 端点 /v2/front 和 /v2/rear 检索。 帧从 base64 解码,并从 BGR 格式转换为 RGB 格式。 机器人遥测从 /data 端点检索。 传感器数组(加速度计、陀螺仪、磁力计、转速)各自包含形式为 [values…, timestamp] 的条目;使用每个数组中最新的读数。

注意: 相机帧从 SDK 端点 /v2/front 和 /v2/rear 检索。 帧从 base64 解码,并从 BGR 格式转换为 RGB 格式。 机器人遥测从 /data 端点检索。 所有 SDK 值都被归一化到适合 dataset 记录的范围内。

send_action

< >

( action: dict ) RobotAction

参数

  • action — 包含以下键的 action 字典:
    • linear_velocity:目标线速度 (-1 至 1)
    • angular_velocity:目标角速度 (-1 至 1)

返回

RobotAction

已发送的 action(与 action_features 键匹配)

抛出异常

DeviceNotConnectedError

  • DeviceNotConnectedError — 如果机器人未连接

通过 SDK 向机器人发送 action。

注意: action 通过 POST /control 端点发送到 SDK。 SDK 期望命令在 [-1, 1] 范围内。

class lerobot.robots.earthrover_mini_plus.EarthRoverMiniPlusConfig

< >

( sdk_url: str = 'http://localhost:8000'id: str | None = Nonecalibration_dir: pathlib.Path | None = None )

参数

  • sdk_url — Frodobots SDK 服务器的 URL(默认:http://localhost:8000)

使用 Frodobots SDK 的 EarthRover Mini Plus 机器人配置。

该机器人通过 Frodobots SDK HTTP API 使用基于云的控制。 相机帧通过 SDK HTTP 端点直接访问。

在 GitHub 上更新