LeRobot documentation
Damiao Motors 与 CAN 总线
快速入门
教程
用于机器人的模仿学习LeLab - Lerobot GUI添加策略自带硬件使用 RL 训练机器人在模拟环境中训练 RL多 GPU 训练人工参与的数据收集使用 PEFT(例如 LoRA)进行训练使用重命名映射和空相机
计算与硬件
数据集
策略
ACTSmolVLAπ₀ (Pi0)π₀-FAST (Pi0Fast)π₀.₅ (Pi05)FineART-VLAMolmoAct2VLA-JEPALaWAMEO-1LingBot-VALingBot-VLA 2.0OpenGalaxea G0.5FastWAMLong-WAMFLUX 3 Action (flux3)EVO1NVIDIA GR00TX-VLA多任务 DiT 策略WALL-OSSWall-OSS-0.5DM05Cosmos3
奖励模型
推理
模拟
基准测试
添加基准测试LIBEROLIBERO-plusMeta-WorldRoboTwin 2.0RoboCasa365RoboCerebraNVIDIA RoboLabRoboMMENVIDIA IsaacLab Arena 环境VLABench
机器人处理器
机器人
SO-101SO-100Koch v1.1LeKiwiHope JrReachy 2Unitree G1Earth Rover MiniOMXOpenArmreBot B601YAM第三方机器人 & 遥操作器
远程操作员
传感器
资源
关于
API 参考
Damiao Motors 与 CAN 总线
本指南介绍了如何通过 CAN 总线通信在 LeRobot 中设置和使用 Damiao 电机。
目前仅支持 Linux,因为 OpenArms CAN 适配器仅提供 Linux 驱动程序。
Linux CAN 设置
在使用 Damiao 电机之前,您需要在 Linux 系统上配置 CAN 接口。
安装 CAN 实用工具
sudo apt-get install can-utils配置 CAN 接口(手动)
对于标准 CAN FD(推荐用于 OpenArms):
sudo ip link set can0 down
sudo ip link set can0 type can bitrate 1000000 dbitrate 5000000 fd on
sudo ip link set can0 up对于标准 CAN(不带 FD):
sudo ip link set can0 down
sudo ip link set can0 type can bitrate 1000000
sudo ip link set can0 up配置 CAN 接口(使用 LeRobot)
LeRobot 提供了一个实用脚本,用于设置和测试 CAN 接口:
# Setup multiple interfaces (e.g., OpenArms Followers with 2 CAN buses)
lerobot-setup-can --mode=setup --interfaces=can0,can1调试 CAN 通信
使用内置的调试工具来测试电机通信:
# Test motors on all interfaces
lerobot-setup-can --mode=test --interfaces=can0,can1
# Run speed/latency test
lerobot-setup-can --mode=speed --interfaces=can0测试模式将扫描电机(ID 0x01-0x08)并报告哪些电机有响应。输出示例:
can0: UP (CAN FD)
Motor 0x01 (joint_1): ✓ FOUND
→ Response 0x11 [FD]: 00112233...
Motor 0x02 (joint_2): ✓ FOUND
Motor 0x03 (joint_3): ✗ No response
...
Summary: 2/8 motors found用法
基础设置
from lerobot.motors import Motor
from lerobot.motors.damiao import DamiaoMotorsBus
# Define your motors with send/receive CAN IDs
motors = {
"joint_1": Motor(id=0x01, motor_type_str="dm8009", recv_id=0x11),
"joint_2": Motor(id=0x02, motor_type_str="dm4340", recv_id=0x12),
"joint_3": Motor(id=0x03, motor_type_str="dm4310", recv_id=0x13),
}
# Create the bus
bus = DamiaoMotorsBus(
port="can0", # Linux socketcan interface
motors=motors,
)
# Connect
bus.connect()读取电机状态
# Read single motor position (degrees)
position = bus.read("Present_Position", "joint_1")
# Read from multiple motors
positions = bus.sync_read("Present_Position") # All motors
positions = bus.sync_read("Present_Position", ["joint_1", "joint_2"])
# Read all states at once (position, velocity, torque)
states = bus.sync_read_all_states()
# Returns: {'joint_1': {'position': 45.2, 'velocity': 1.3, 'torque': 0.5}, ...}编写电机指令
# Enable torque
bus.enable_torque()
# Set goal position (degrees)
bus.write("Goal_Position", "joint_1", 45.0)
# Set positions for multiple motors
bus.sync_write("Goal_Position", {
"joint_1": 45.0,
"joint_2": -30.0,
"joint_3": 90.0,
})
# Disable torque
bus.disable_torque()配置选项
| 参数 | 默认 | 描述 |
|---|---|---|
port | - | CAN 接口(can0)或串行端口(/dev/cu.usbmodem*) |
use_can_fd | True | 启用 CAN FD 以实现更高的数据速率 |
bitrate | 1000000 | 标称比特率 (1 Mbps) |
data_bitrate | 5000000 | CAN FD 数据比特率 (5 Mbps) |
电机配置
每个电机需要:
id:用于发送命令的 CAN IDmotor_type:受支持的电机类型之一(例如"dm8009"、"dm4340")recv_id:用于接收响应的 CAN ID
OpenArms 默认 ID 遵循以下模式:发送 ID 为 0x0N,接收 ID 为 0x1N,其中 N 为关节编号。
故障排除
电机无响应
- 检查电源
- Verify CAN wiring: Check CAN-H, CAN-L, and GND connections
- 检查电机 ID:使用 Damiao 调试工具来验证/配置 ID
- 测试 CAN 接口:运行
candump can0以查看是否正在接收消息 - 运行诊断:
lerobot-setup-can --mode=test --interfaces=can0
Motor 超时参数
如果电机配置为 timeout=0,它们将不会响应命令。请使用 Damiao 调试工具设置一个非零的超时值。
验证 CAN FD 状态
ip -d link show can0 | grep fd