OpenDuckMini快速入门教程-舵机配置
文章说明
- 本教程主要介绍如何进行舵机配置
- 注意:进行硬件组装前需要进行舵机配置
- 本次教程配置可以在PC或者树莓派上运行
欢迎加入我们的openduckmini交流群,微信扫描右侧二维码立即进群交流
相关设备
OpenDuckMini
套件: 采购地址

前提准备
- 准备电源,选择合适的电源进行供电,比如12v舵机就用12v电源,7.4v舵机就用7.4v电源
- 电源供电给舵机驱动板,舵机驱动板连接PC或者树莓派,还有接上舵机
舵机配置有两种方式:
终端下使用脚本配置
- 终端下配置需要提前部署好
Open_Duck_Mini_Runtime
代码到虚拟机或者PC或者树莓派上- 代码安装教程 | 教程地址
win下使用飞特舵机配套软件配置
- 飞特舵机配套软件下载链接:FD1.9.8.5(250706).7z
操作步骤
终端配置
- 监测端口是否存在
$ lsusb
Bus 001 Device 003: ID 1a86:55d3 QinHeng Electronics USB Single Serial
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
- 各个舵机的ID和对应的名称
{
"left_hip_yaw": 20,
"left_hip_roll": 21,
"left_hip_pitch": 22,
"left_knee": 23,
"left_ankle": 24,
"neck_pitch": 30,
"head_pitch": 31,
"head_yaw": 32,
"head_roll": 33,
"right_hip_yaw": 10,
"right_hip_roll": 11,
"right_hip_pitch": 12,
"right_knee": 13,
"right_ankle": 14,
}
- 设置舵机ID
$ sudo chmod 777 /dev/ttyACM0
$ cd ~/open_duck_mini_ws/Open_Duck_Mini_Runtime/mini_bdx_runtime/mini_bdx_runtime
$ python configure_motor.py --id 20
===
Done configuring motor.
Motor id: 20
P coefficient : (32,)
I coefficient : (0,)
D coefficient : (0,)
acceleration: (0,)
max_acceleration: (0,)
mode: (0,)
===
- 安装舵盘需要对准中线,只有一个孔位是能刚好对正中线安装的
- 舵机设置完成之后,最好贴一下标签或者标识一下,以免遗忘
- 比如像下图一样设置
使用飞特舵机配套软件配置
- 接上驱动板和舵机后,选择对应的端口号和
波特率
设置为1000000
- 进入编程栏,编辑5号地址的值,设置对应的舵机ID
- 点击上方
中位校准
按钮进行一键校准
- 或者40号地址写入128,当前位置自动校准为2048;2048是180度,即是中位
舵机配置完后,进行舵盘安装,具体细节请看
终端下使用脚本配置
内容的后半部分至于舵机的PID值、加速度、最大加速度、模式等参数值,可以在终端下一键批量配置
添加以下脚本
$ cd ~/open_duck_mini_ws/Open_Duck_Mini_Runtime/scripts
$ touch batch_configure_motor.py
$ vim batch_configure_motor.py
#!/usr/bin/env python3
import argparse
from pypot.feetech import FeetechSTS3215IO
def discover_servos(io):
"""Return a list of IDs for which get_present_position succeeds."""
found = []
for sid in range(1, 34):
try:
io.get_present_position([sid])
found.append(sid)
except Exception:
pass
return found
def program_servo(io, sid, params):
"""Write the desired parameters to one servo."""
io.set_lock({sid: 0})
io.set_P_coefficient({sid: params['P']})
io.set_I_coefficient({sid: params['I']})
io.set_D_coefficient({sid: params['D']})
io.set_acceleration({sid: params['accel']})
io.set_maximum_acceleration({sid: params['max_accel']})
io.set_mode({sid: params['mode']})
#io.set_lock({sid: 1})
def main():
parser = argparse.ArgumentParser(
description="Program STS3215 servos with preset PID and motion parameters"
)
parser.add_argument(
"--port",
default="/dev/ttyACM0",
help="Serial port (e.g. /dev/ttyACM0)",
)
args = parser.parse_args()
io = FeetechSTS3215IO(args.port)
print(f"Scanning for servos on port {args.port}…")
servos = discover_servos(io)
if not servos:
print("No servos found.")
return
print("Found servos:", servos)
params = {
'P': 32,
'I': 0,
'D': 0,
'accel': 0,
'max_accel': 0,
'mode': 0
}
for sid in servos:
print(f"Programming servo {sid}…")
program_servo(io, sid, params)
print("All servos programmed.")
if __name__ == "__main__":
main()
- 运行批量设置舵机参数的脚本
$ pyhton batch_configure_motor.py
Scanning for servos on port /dev/ttyACM0…
Found servos: [10, 11, 12, 13, 14, 20, 21, 22, 23, 24, 30, 31, 32, 33]
Programming servo 10…
Programming servo 11…
Programming servo 12…
Programming servo 13…
Programming servo 14…
Programming servo 20…
Programming servo 21…
Programming servo 22…
Programming servo 23…
Programming servo 24…
Programming servo 30…
Programming servo 31…
Programming servo 32…
Programming servo 33…
All servos programmed.
14个舵机联测
- 所有舵机都配置完成之后,就进行检测一次,确定没有遗漏
- 将14个舵机都串联起来接到驱动板上
$ cd ~/open_duck_mini_ws/Open_Duck_Mini_Runtime/scripts
$ python check_motors.py
Initializing hardware interface...
Attempting to connect to motor controller...
Attempting to connect to motor controller...
Successfully connected to hardware!
Turning on motors with low torque (one by one)...
Setting low torque for motor 'left_hip_yaw' (ID: 20)...
d_coefficient: [0]
✓ Low torque set successfully for motor 'left_hip_yaw' (ID: 20).
Setting low torque for motor 'left_hip_roll' (ID: 21)...
d_coefficient: [0]
✓ Low torque set successfully for motor 'left_hip_roll' (ID: 21).
Setting low torque for motor 'left_hip_pitch' (ID: 22)...
d_coefficient: [0]
✓ Low torque set successfully for motor 'left_hip_pitch' (ID: 22).
Setting low torque for motor 'left_knee' (ID: 23)...
d_coefficient: [0]
✓ Low torque set successfully for motor 'left_knee' (ID: 23).
Setting low torque for motor 'left_ankle' (ID: 24)...
d_coefficient: [0]
✓ Low torque set successfully for motor 'left_ankle' (ID: 24).
Setting low torque for motor 'neck_pitch' (ID: 30)...
d_coefficient: [0]
✓ Low torque set successfully for motor 'neck_pitch' (ID: 30).
Setting low torque for motor 'head_pitch' (ID: 31)...
d_coefficient: [0]
✓ Low torque set successfully for motor 'head_pitch' (ID: 31).
Setting low torque for motor 'head_yaw' (ID: 32)...
d_coefficient: [0]
✓ Low torque set successfully for motor 'head_yaw' (ID: 32).
Setting low torque for motor 'head_roll' (ID: 33)...
d_coefficient: [0]
✓ Low torque set successfully for motor 'head_roll' (ID: 33).
Setting low torque for motor 'right_hip_yaw' (ID: 10)...
d_coefficient: [0]
✓ Low torque set successfully for motor 'right_hip_yaw' (ID: 10).
Setting low torque for motor 'right_hip_roll' (ID: 11)...
d_coefficient: [0]
✓ Low torque set successfully for motor 'right_hip_roll' (ID: 11).
Setting low torque for motor 'right_hip_pitch' (ID: 12)...
d_coefficient: [0]
✓ Low torque set successfully for motor 'right_hip_pitch' (ID: 12).
Setting low torque for motor 'right_knee' (ID: 13)...
d_coefficient: [0]
✓ Low torque set successfully for motor 'right_knee' (ID: 13).
Setting low torque for motor 'right_ankle' (ID: 14)...
d_coefficient: [0]
✓ Low torque set successfully for motor 'right_ankle' (ID: 14).
Checking if all motors are responsive...
Attempting to read position from motor 'left_hip_yaw' (ID: 20)...
✓ Motor 'left_hip_yaw' (ID: 20) is responsive. Position: -0.002
Attempting to read position from motor 'left_hip_roll' (ID: 21)...
✓ Motor 'left_hip_roll' (ID: 21) is responsive. Position: 0.000
Attempting to read position from motor 'left_hip_pitch' (ID: 22)...
✓ Motor 'left_hip_pitch' (ID: 22) is responsive. Position: -0.001
Attempting to read position from motor 'left_knee' (ID: 23)...
✓ Motor 'left_knee' (ID: 23) is responsive. Position: -0.001
Attempting to read position from motor 'left_ankle' (ID: 24)...
✓ Motor 'left_ankle' (ID: 24) is responsive. Position: -0.001
Attempting to read position from motor 'neck_pitch' (ID: 30)...
✓ Motor 'neck_pitch' (ID: 30) is responsive. Position: 0.000
Attempting to read position from motor 'head_pitch' (ID: 31)...
✓ Motor 'head_pitch' (ID: 31) is responsive. Position: 0.04
Attempting to read position from motor 'head_yaw' (ID: 32)...
✓ Motor 'head_yaw' (ID: 32) is responsive. Position: -0.002
Attempting to read position from motor 'head_roll' (ID: 33)...
✓ Motor 'head_roll' (ID: 33) is responsive. Position: -0.003
Attempting to read position from motor 'right_hip_yaw' (ID: 10)...
✓ Motor 'right_hip_yaw' (ID: 10) is responsive. Position: 0.001
Attempting to read position from motor 'right_hip_roll' (ID: 11)...
✓ Motor 'right_hip_roll' (ID: 11) is responsive. Position: -0.001
Attempting to read position from motor 'right_hip_pitch' (ID: 12)...
✓ Motor 'right_hip_pitch' (ID: 12) is responsive. Position: 0.001
Attempting to read position from motor 'right_knee' (ID: 13)...
✓ Motor 'right_knee' (ID: 13) is responsive. Position: 0.00
Attempting to read position from motor 'right_ankle' (ID: 14)...
✓ Motor 'right_ankle' (ID: 14) is responsive. Position: -0.000
--- Motor Movement Test ---
This will move each motor by a small amount to check if it's working correctly.
Press Enter to begin the movement test...
Testing motor: 'left_hip_yaw' (ID: 20)
Test this motor? (Enter/y for yes, n to skip, q to quit): q
Exiting movement test...
Turning off motors one by one...
Disabling torque for motor 'left_hip_yaw' (ID: 20)...
✓ Motor 'left_hip_yaw' (ID: 20) turned off successfully.
Disabling torque for motor 'left_hip_roll' (ID: 21)...
✓ Motor 'left_hip_roll' (ID: 21) turned off successfully.
Disabling torque for motor 'left_hip_pitch' (ID: 22)...
✓ Motor 'left_hip_pitch' (ID: 22) turned off successfully.
Disabling torque for motor 'left_knee' (ID: 23)...
✓ Motor 'left_knee' (ID: 23) turned off successfully.
Disabling torque for motor 'left_ankle' (ID: 24)...
✓ Motor 'left_ankle' (ID: 24) turned off successfully.
Disabling torque for motor 'neck_pitch' (ID: 30)...
✓ Motor 'neck_pitch' (ID: 30) turned off successfully.
Disabling torque for motor 'head_pitch' (ID: 31)...
✓ Motor 'head_pitch' (ID: 31) turned off successfully.
Disabling torque for motor 'head_yaw' (ID: 32)...
✓ Motor 'head_yaw' (ID: 32) turned off successfully.
Disabling torque for motor 'head_roll' (ID: 33)...
✓ Motor 'head_roll' (ID: 33) turned off successfully.
Disabling torque for motor 'right_hip_yaw' (ID: 10)...
✓ Motor 'right_hip_yaw' (ID: 10) turned off successfully.
Disabling torque for motor 'right_hip_roll' (ID: 11)...
✓ Motor 'right_hip_roll' (ID: 11) turned off successfully.
Disabling torque for motor 'right_hip_pitch' (ID: 12)...
✓ Motor 'right_hip_pitch' (ID: 12) turned off successfully.
Disabling torque for motor 'right_knee' (ID: 13)...
✓ Motor 'right_knee' (ID: 13) turned off successfully.
Disabling torque for motor 'right_ankle' (ID: 14)...
✓ Motor 'right_ankle' (ID: 14) turned off successfully.
Motor test completed.
正常状态下应该全部检测到14个舵机,且舵机的position值应都约等于0
测试舵机电压
本次测试使用的是12v舵机,使用的电源也是12v
$ cd ~/open_duck_mini_ws/Open_Duck_Mini_Runtime/scripts
$ python3 check_voltage.py
left_hip_yaw 12.2 V
left_hip_roll 12.1 V
left_hip_pitch 12.2 V
left_knee 12.2 V
left_ankle 12.1 V
neck_pitch 12.2 V
head_pitch 12.0 V
head_yaw 12.0 V
head_roll 12.1 V
right_hip_yaw 12.0 V
right_hip_roll 12.1 V
right_hip_pitch 12.0 V
right_knee 12.1 V
right_ankle 12.1 V
演示视频
终端下使用脚本配置
win下使用飞特舵机配套软件配置
获取最新文章: 扫一扫右上角的二维码加入“创客智造”公众号