智能佳(ZNJ)low cost robot 具身智能机械臂-xx.使用DynamixelMotorsBus控制您的电机
实例化DynamixelMotorsBus
首先,使用相应的USB端口(例如)创建两个实例DynamixelMotorsBus,每个臂一个DynamixelMotorsBus(port="/dev/tty.usbmodem575E0031751"。
要找到每个臂的正确端口,请运行实用程序脚本两次:
python lerobot/common/robot_devices/motors/dynamixel.py
识别引导臂端口时的示例输出
在Mac上识别为/dev/tty.usbmodem575E0031751,
在Linux上识别为/dev/ttyACM0:
Finding all available ports for the DynamixelMotorsBus.
['/dev/tty.usbmodem575E0032081', '/dev/tty.usbmodem575E0031751']
Remove the usb cable from your DynamixelMotorsBus and press Enter when done.
[...Disconnect leader arm and press Enter...]
The port of this DynamixelMotorsBus is /dev/tty.usbmodem575E0031751
Reconnect the usb cable.
识别从动臂端口时的输出示例(例如,/dev/tty.usbmodem575E0032081或者可能在Linux上识别为/dev/ttyACM1):
Finding all available ports for the DynamixelMotorsBus.
['/dev/tty.usbmodem575E0032081', '/dev/tty.usbmodem575E0031751']
Remove the usb cable from your DynamixelMotorsBus and press Enter when done.
[...Disconnect follower arm and press Enter...]
The port of this DynamixelMotorsBus is /dev/tty.usbmodem575E0032081
Reconnect the usb cable.
故障排除:在Linux上,您可能需要通过运行以下命令来授予对USB端口的访问权限:
sudo chmod 666 /dev/ttyACM0
sudo chmod 666 /dev/ttyACM1
列出和配置电机
接下来,您需要列出每个臂的电机,包括它们的名称、索引和型号。最初,每个电机都分配有工厂默认索引1。由于每个电机在连接到公共总线上的链中时都需要唯一的索引才能正常运行,因此您需要分配不同的索引。建议使用从1(例如1, 2, 3, 4, 5, 6) 开始的升序索引顺序。这些索引将在第一次连接期间保存在每个电机的持久存储器中。
要为电机分配索引,请在交互式Python会话中运行此代码。
将这些值替换port为您之前确定的值:
from lerobot.common.robot_devices.motors.dynamixel import DynamixelMotorsBus
leader_port = "/dev/tty.usbmodem575E0031751"
follower_port = "/dev/tty.usbmodem575E0032081"
leader_arm = DynamixelMotorsBus(
port=leader_port,
motors={
# name: (index, model)
"shoulder_pan": (1, "xl330-m077"),
"shoulder_lift": (2, "xl330-m077"),
"elbow_flex": (3, "xl330-m077"),
"wrist_flex": (4, "xl330-m077"),
"wrist_roll": (5, "xl330-m077"),
"gripper": (6, "xl330-m077"),
},
)
follower_arm = DynamixelMotorsBus(
port=follower_port,
motors={
# name: (index, model)
"shoulder_pan": (1, "xl430-w250"),
"shoulder_lift": (2, "xl430-w250"),
"elbow_flex": (3, "xl330-m288"),
"wrist_flex": (4, "xl330-m288"),
"wrist_roll": (5, "xl330-m288"),
"gripper": (6, "xl330-m288"),
},
)
更新YAML配置文件
lerobot/configs/robot/koch.yaml接下来,使用您确定的端口更新Koch机器人的 YAML配置文件中的端口值: