LeRobot documentation

机器人

You are viewing main version, which requires installation from source. If you'd like regular pip install, checkout the latest stable version (v0.7.0).
Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

机器人

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

此页面为自动生成的参考文档。有关接线、校准和首次运行的说明,请从硬件指南开始——SO-101、LeKiwi、Hope Jr、Reachy 2、OpenArm——或参阅Imitation Learning for Robots了解端到端工作流。对于核心集之外的社区维护机器人,请参阅Third-Party Robots & Teleoperators。若要添加您自己的机器人,请参阅Bring Your Own Hardware。

机器人

抽象基类。子类实现了以下所有方法;此处描述的契约是策略或记录循环可以依赖的内容。

类 lerobot.robots.Robot

< >

( config: RobotConfig )

参数

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

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

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

连接

< >

( calibrate: bool = True )

参数

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

与机器人建立通信。

断开连接

< >

( )

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

配置

< >

( )

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

calibrate

< >

( )

如适用,请校准机器人。如果不适用,此操作应为空操作。

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

get_observation

< >

( ) → RobotObservation

返回值

RobotObservation

一个扁平字典,表示机器人当前的感知状态。其结构应与 :pymeth:observation_features 相匹配。

从机器人获取当前观测值。

send_action

< >

( action: dict ) → RobotAction

参数

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

返回值

RobotAction

实际发送到电机的动作,可能会经过裁剪或修改,例如通过速度安全限制。

向机器人发送操作指令。

observation_features

< >

( )

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

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

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

action_features

< >

( )

一个描述机器人预期动作的结构和类型的字典。其结构(键)应与传递给 :pymeth:send_action 的内容的结构相匹配。如果值是简单值,则字典的值应为该值的类型,例如,对于单个本体感觉值(关节的目标位置/速度),类型为 float

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

is_connected

< >

( )

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

is_calibrated

< >

( )

机器人当前是否已校准。如果不适用,则应始终为 True

RobotConfig

类 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 的跟随者

SO100Follower 和 SO101Follower 是同一个 SOFollower 类的别名;这两条机械臂的区别在于配置,而非控制代码。SO100FollowerConfig 和 SO101FollowerConfig 同样是 SOFollowerRobotConfig 的别名。

类 lerobot.robots.so_follower.SOFollower

< >

( config: SOFollowerRobotConfig )

通用 SO 跟随器基类,实现了 SO-100/101/10X 的通用功能。 设计为通过针对每个硬件型号的 config_class 和 name 进行子类化。

连接

< >

( calibrate: bool = True )

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

send_action

< >

( action: dict ) → RobotAction

返回值

RobotAction

发送至电机的动作,可能会被裁剪。

引发

RobotDeviceNotConnectedError

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

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

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

类 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 跟随器作为单个双臂机器人进行驱动。

类 lerobot.robots.bi_so_follower.BiSOFollower

< >

( config: BiSOFollowerConfig )

由 TheRobotStudio 设计的双手 SO 跟随臂

类 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

类 lerobot.robots.koch_follower.KochFollower

< >

( config: KochFollowerConfig )

连接

< >

( calibrate: bool = True )

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

send_action

< >

( action: dict ) → RobotAction

参数

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

返回值

RobotAction

发送至电机的动作,可能经过裁剪。

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

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

类 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 接口。

类 lerobot.robots.lekiwi.LeKiwi

< >

( config: LeKiwiConfig )

该机器人包含一个三轮全向轮移动底盘和一个远程从动臂。 主臂在本地(笔记本电脑上)连接,其关节位置被记录,然后 转发给远程从动臂(在应用安全钳制之后)。 同时,使用键盘遥操作来生成车轮的原始速度指令。

send_action

< >

( action: dict ) → RobotAction

返回值

RobotAction

发送至电机的动作,可能会被裁剪。

引发

RobotDeviceNotConnectedError

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

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

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

类 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 )

类 lerobot.robots.lekiwi.LeKiwiClient

< >

( config: LeKiwiClientConfig )

连接

< >

( )

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

断开连接

< >

( )

清理 ZMQ 通信

get_observation

< >

( )

从远程机器人捕获观测数据:当前从动臂位置、当前轮速(转换为机体坐标系下的速度:x、y、theta)以及一帧相机图像。通过 ZMQ 接收,并转换为机体坐标系下的速度

send_action

< >

( action: dict ) → np.ndarray

参数

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

返回值

np.ndarray

发送至电机的动作,可能会被裁剪。

引发

RobotDeviceNotConnectedError

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

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

类 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

类 lerobot.robots.openarm_follower.OpenArmFollower

< >

( config: OpenArmFollowerConfig )

OpenArms 跟随机器人使用 CAN 总线通信来控制带有夹爪的 7 自由度机械臂。 该机械臂使用处于 MIT 控制模式下的 Damiao 电机。

calibrate

< >

( )

运行 OpenArms 机器人的校准流程。

校准流程:

  1. 禁用扭矩
  2. 提示用户将手臂置于悬挂位置,并闭合夹爪
  3. 将此设置为零位置
  4. 记录每个关节的活动范围
  5. 保存校准

配置

< >

( )

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

连接

< >

( calibrate: bool = True )

连接到机器人,并可选地进行校准。

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

断开连接

< >

( )

与机器人断开连接。

get_observation

< >

( )

获取机器人的当前观测值,包括位置、速度和扭矩。

在单个 CAN 刷新周期内读取所有电机状态(pos/vel/torque),而不是进行 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})

向机器人发送操作命令。

动作幅度可能会根据安全限制进行裁剪。

类 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

类 lerobot.robots.bi_openarm_follower.BiOpenArmFollower

< >

( config: BiOpenArmFollowerConfig )

双臂 OpenArm 从臂

类 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

类 lerobot.robots.omx_follower.OmxFollower

< >

( config: OmxFollowerConfig )

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

连接

< >

( calibrate: bool = True )

对于出厂前已校准的 OMX 机器人:

  • 如果软件包中的默认校准与电机不匹配,则从电机读取并保存
  • 这使得无需手动校准即可使用预先校准的机器人
  • 如果不存在校准文件,请使用出厂默认值(homing_offset=0, range_min=0, range_max=4095)

send_action

< >

( action: dict ) → RobotAction

参数

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

返回值

RobotAction

发送至电机的动作,可能经过裁剪。

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

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

类 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

类 lerobot.robots.reachy2.Reachy2Robot

< >

( config: Reachy2RobotConfig )

Pollen Robotics 出品的 Reachy 2。

类 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

类 lerobot.robots.unitree_g1.UnitreeG1

< >

( config: UnitreeG1Config )

类 lerobot.robots.unitree_g1.UnitreeG1Config

< >

( kp: list[float] | None = Nonekd: list[float] | None = Nonedefault_positions: list = <factory>control_dt: float = 0.004is_simulation: bool = Trueend_effector: G1EndEffector = <G1EndEffector.DEX1: 'dex1'>sim_publish_images: bool = Truesim_camera_port: int = 5555sim_onscreen: bool | None = Nonerobot_ip: str = '192.168.123.164'cameras: dict = <factory>gravity_compensation: bool = Falsecontroller: str | None = Noneembodiment: str = 'g1_29'id: str | None = Nonecalibration_dir: pathlib.Path | None = None )

Hope Jr

Hope Jr 人形机器人被暴露为两个独立的机器人,即一条手臂和一只手。

类 lerobot.robots.hope_jr.HopeJrArm

< >

( config: HopeJrArmConfig )

连接

< >

( calibrate: bool = True )

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

类 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 )

类 lerobot.robots.hope_jr.HopeJrHand

< >

( config: HopeJrHandConfig )

类 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

类 lerobot.robots.rebot_b601_follower.RebotB601Follower

< >

( config: RebotB601FollowerRobotConfig )

Seeed Studio reBot B601 跟随臂(6 自由度 + 夹爪,CAN 电机)。

电机通信由 motorbridge 包通过 CAN 总线处理,可通过 Damiao 串口桥接器或 MotorBridge 的原生 CAN 传输方式访问。

配置

< >

( )

在启用扭矩之前,设置每个电机的控制模式。

disable_torque

< >

( )

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

断开连接

< >

( )

将电机和摄像头从机器人上断开。

send_action

< >

( action: dict )

将机械臂指令至目标关节配置。

位置以度为单位表示。相对动作幅度可能会根据 max_relative_target 进行裁剪,因此始终返回实际发送的动作。

类 lerobot.robots.rebot_b601_follower.RebotB601FollowerRobotConfig

< >

( port: strmotor_family: MotorFamily = <MotorFamily.DM: 'dm'>can_adapter: str | None = Nonedm_serial_baud: int = 921600disable_torque_on_disconnect: bool = Truemax_relative_target: float | dict[str, float] | None = Nonecameras: dict = <factory>motor_can_ids: dict[str, tuple[int, int]] | None = Nonecontrol_mode: ArmControlMode = <ArmControlMode.MIT: 'mit'>gripper_control_mode: lerobot.robots.rebot_b601_follower.motor_family.GripperControlMode | None = Nonemit_kp: float | dict[str, float] | None = Nonemit_kd: float | dict[str, float] | None = Nonepos_vel_velocity: float | dict[str, float] | None = Nonegripper_torque_ratio: float | None = Nonegripper_torque_limit: float | None = Nonegripper_hold_torque_limit: float | None = Nonejoint_limits: dict[str, tuple[float, float]] | None = Noneid: str | None = Nonecalibration_dir: pathlib.Path | None = None )

reBot B601 跟随机器人的注册配置。

BiRebotB601Follower

类 lerobot.robots.bi_rebot_b601_follower.BiRebotB601Follower

< >

( config: BiRebotB601FollowerConfig )

双手 Seeed Studio reBot B601 跟随者。

组合两个单臂 RebotB601Follower 实例。每个臂的观察和动作键都会加上 left_ / right_ 前缀进行命名空间隔离。

类 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 从动机器人的配置类。

EarthRoverMiniPlus

类 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 的机器人无需校准。

配置

< >

( )

配置机器人(基于 SDK 的机器人无需操作)。

连接

< >

( calibrate: bool = True )

参数

  • calibrate — 不适用于基于 SDK 的机器人(保留以兼容 API)

引发

DeviceAlreadyConnectedError 或 DeviceNotConnectedError

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

通过 Frodobots SDK 连接到机器人。

断开连接

< >

( )

引发

DeviceNotConnectedError

  • DeviceNotConnectedError — 如果机器人未连接

与机器人断开连接。

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

get_observation

< >

( ) → RobotObservation

返回值

RobotObservation

包含以下内容的观察:

  • 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 - 灯的状态(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 获取当前机器人观测值。

相机帧从 SDK 端点 /v2/front 和 /v2/rear 获取。 帧从 base64 解码,并从 BGR 格式转换为 RGB 格式。 机器人遥测数据从 /data 端点获取。 传感器数组(accels、gyros、mags、rpms)中的每个条目均为 [values…, timestamp];使用每个数组中的最新读数。

Note: 相机帧从 SDK 端点 /v2/front 和 /v2/rear 获取。 帧从 base64 解码,并从 BGR 格式转换为 RGB 格式。 机器人遥测数据从 /data 端点获取。 所有 SDK 值均被归一化到适合数据集记录的相应范围内。

send_action

< >

( action: dict ) → RobotAction

参数

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

返回值

RobotAction

发送的操作(与 action_features 的键匹配)

引发

DeviceNotConnectedError

  • DeviceNotConnectedError — 如果机器人未连接

通过 SDK 向机器人发送操作。

Note: 操作通过 POST /control 端点发送至 SDK。 SDK 期望命令值在 [-1, 1] 范围内。

类 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 端点直接访问。

Update on GitHub