
# LeRobot (SO101)
本章介绍如何通过LeRobot适配器（hardware.type: "lerobot"）接入SO101双臂机器人。
#### 硬件说明
表1硬件信息 
| 组件 | 数量      | 协议           | 说明                                                                                                                                                                                                                    |
|:---|:---|:---|:---|
| 双臂 | 2×6 DOF | LeRobot 标准协议 | 通过 robot.send_action() 驱动。                                                                                                                                                                                            |
| 夹爪 | 2       | LeRobot 协议   | 步进电机夹爪。                                                                                                                                                                                                               |
| 相机 | 2       | OpenCV USB   | - 分辨率：640×480  - 频率：30fps   |
   
#### 依赖与环境
参考[配置软件环境](https://support.huaweicloud.com/sdkreference-cloudrobo/cloudrobo_03_0002.html)安装LeRobot环境。
```
# 安装SDK
cd /home/robot/project/r2c_sdk_python 
conda activate lerobot
pip install -e .
```
#### 配置文件
使用config/robot_so101_lerobot_config.yaml。
**关键配置项**如下表所示。
表2关键配置项 
| 参数                                   | 说明                               |
|:---|:---|
| robot.type                           | LeRobot 机器人类型（so101_follower 等）。 |
| robot.port                           | 串口设备路径（默认 /dev/ttyACM0）。         |
| robot.cameras.\<name\>.type          | 相机驱动类型（opencv）。                  |
| robot.cameras.\<name\>.index_or_path | 相机设备索引或路径。                       |
| robot.cameras.\<name\>.fps           | 相机帧率。                            |
   
#### 启动命令
```
cd /home/robot/project/r2c_sdk_python 
conda activate lerobot
python -m r2c_sdk.cloudroboclient --bundle config/配置文件名.zip --robot-config config/robot_so101_lerobot_config.yaml
```
#### go_home
LeRobot go_home通过LeRobotGoHomeCommand实现，支持两种joint格式：
- Dict 模式：joints: {"joint_1": 0.0, "joint_2": 0.1, ...} --- 直接传给 robot.send_action()
- List 模式：joints: \[0.0, 0.1, ...\] + joint_names: \["joint_1", "joint_2", ...\] --- 按序映射
```
# 命令配置
commands:
  go_home:
    type: go_home
    joint_names:
      - shoulder_pan.pos
      - shoulder_lift.pos
      - elbow_flex.pos
      - wrist_flex.pos
      - wrist_roll.pos
      - gripper.pos
    joints: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
```
#### 键盘控制
表3按键功能 
| 按键     | 功能                               |
|:---|:---|
| Space键 | 暂停/恢复。                           |
| h键     | go_home（左臂 6 关节 → 0 rad，夹爪 → 0）。 |
| q键     | 退出。                              |
   
