ODrive的ASCII协议
---------------------学习笔记-----------------------------------------
一、发送命令
(1)用Zadig把ODrive的驱动设置为“usbser”;(windows会把设备看作COM端口)
(2)用PuTTY或者你喜欢的编程语言发送命令;
二、命令格式
command *42 ; comment [new line character]
三、参考命令
(1)电机轨迹命令----------t motor destination (推荐一般绕轴运动)
Example: t 0 -20000
t是轨迹;
motor是电机(0 or 1);
destination是目标位置 (编码器计数)
(2)电机位置命令
①发送一个设定值------q motor position velocity_lim current_lim
Example: q 0 -20000 10000 10
velocity_lim:速度限制,单位是count /s(可选)。
current_lim:电流限制,单位是A(可选)。
②实时控制-------------p motor position velocity_ff current_ff
Example: p 0 -20000 0 0
velocity_ff:速度前馈项,单位是count /s(可选)。
current_ff:电流的前馈项,单位是A(可选)。
(不知道前馈值可以忽略)
(3)电机速度命令--------v motor velocity current_ff
evlocity:速度的期望值。
current_ff:电流的前馈值
(4)电机电流命令--------c motor current
current:电流的期望值
(5)请求反馈-------------f motor
response: pos vel
f: feedback缩写
pos:编码器的位置(浮点型)
vel:编码器的速度
(6)更新电机的watchdog---------u motor
此命令更新电机的watchdog timer,而不更改任何设定值
(7)参数的读/写(并不是所有的参数都可以通过ASCII协议访问,但是至少支持浮点和整数类型的所有参数。)
读:--------r [property]
Example: r vbus_voltage => response: 24.087744
property:属性的名称,如同odrivetool中所示。
响应:请求值的文本表示。
写:-------w [property] [value]
Example: w axis0.controller.pos_setpoint -123.456
(8)系统命令
------ss - Save config
------se - Erase config
------sr - Reboot
附:
Watchdog Timer
每一根轴需要配置一个watchdog timeout,当与Odrive控制连接中断后,停止电机。
-------------- axis.config.watchdog_timeout
当值为0时,暂停watchdog的功能;
如果watchdog在配置有时间间隔情况下,没有反馈,任何值>0时,都将暂停电机
watchdog 用 -----axis.watchdog_feed()-----函数反馈