ODrive Module
ODrive 是 M5Stack 推出的高性能伺服电机驱动模块,基于开源运动控制方案 ODrive。
支持以下产品:
MicroPython 应用示例:
import os, sys, io
import M5
from M5 import *
from module import ODriveModule
drive = ODriveModule(port=(13,5))
drive.get_vbus_voltage()
drive.set_velocity(10)
drive.set_current(5)
drive.set_control_mode(ODriveModule.CONTROL_MODE_POSITION_CONTROL)
drive.set_position(1000)
UiFlow2 应用示例
class ODriveModule
Constructors
Methods
- ODriveModule.set_position(position, velocity_feedforward, current_feedforward)
设置目标位置,并可选设置前馈值。
- 参数:
UiFlow2:

- ODriveModule.set_velocity(velocity, current_feedforward)
设置目标速度,并可选设置电流前馈。
- 参数:
velocity – 目标速度,单位为 counts/s 或 radians/s。
current_feedforward (float) – 用于辅助控制器的前馈电流(单位:A)。
UiFlow2:

- ODriveModule.set_current(current)
设置目标电流。
- 参数:
current – 用于扭矩控制的目标电流值,单位为安培。
UiFlow2:

- ODriveModule.set_gain(pos_gain, vel_gain, vel_integrator_gain)
- 参数:
pos_gain
vel_gain
vel_integrator_gain
UiFlow2:

- ODriveModule.set_control_mode(mode)
设置控制器的控制模式。
- 参数:
mode – 控制模式。
UiFlow2:

- ODriveModule.set_control_input_pos(pos)
设置控制器的控制输入位置。
- 参数:
pos – 位置控制所需的目标输入位置,单位为计数或弧度。
UiFlow2:

- ODriveModule.trapezoidal_move(position)
执行梯形运动到给定位置。
- 参数:
position – 使用梯形速度曲线移动到的目标位置(以计数或弧度为单位)。
UiFlow2:

- ODriveModule.run_state(requested_state, timeout)
在超时期限内将轴运行到请求的状态。
- 参数:
requested_state – 要切换到的目标轴状态,使用 AXIS_STATE_* 常量。
timeout – 等待轴达到请求状态的超时时间,单位为毫秒。
UiFlow2:

- ODriveModule.get_velocity()
获取电机的估算速度。
- Return (float):
估计速度,单位为 counts/s 或 radians/s。
UiFlow2:

- ODriveModule.get_vbus_voltage()
获取测得的总线电压。
- Return (float):
总线电压(单位:V)。
UiFlow2:

- ODriveModule.get_phase_current()
获取电机测得的相电流。
- Return (float):
相电流,单位为安培。
UiFlow2:

- ODriveModule.get_bus_current()
获取电机的总线电流消耗。
- Return (float):
总线电流,单位为安培。
UiFlow2:

- ODriveModule.get_encoder_shadow_count()
获取编码器的影子计数,该计数是一个内部计数器。
- Return (int):
阴影计数为整数值。
UiFlow2:

- ODriveModule.get_encoder_pos_estimate()
从编码器获取估算位置。
- Return (float):
以计数或弧度表示的估计位置。
UiFlow2:

- ODriveModule.get_motor_temp()
获取电机热敏电阻的温度。
- Return (float):
电机温度,单位为摄氏度。
UiFlow2:

- ODriveModule.erase_config()
擦除当前配置设置。
UiFlow2:

- ODriveModule.save_config()
将当前配置保存到非易失性存储器中。
UiFlow2:

- ODriveModule.reboot()
重启 ODrive 设备。
UiFlow2:

- ODriveModule.set_default_config()
设置默认配置参数。
UiFlow2:

- ODriveModule.check_error()
检查系统组件是否存在任何错误。
UiFlow2:

- ODriveModule.read_flush()
刷新 UART 读取缓冲区,以清除任何残留数据。
UiFlow2:

- ODriveModule.read_string()
从设备读取以换行符结尾的字符串。
- Return (str):
从设备读取的字符串,不包括换行符。
UiFlow2:

- ODriveModule.read_float()
从设备读取一个浮点数值。
- Return (float):
从设备读取的浮点值;如果解析失败,则返回 0.0。
UiFlow2:

- ODriveModule.read_int()
从设备读取一个整数值。
- Return (int):
从设备读取的整数值;如果解析失败,则返回 0。
UiFlow2:

- ODriveModule.write_to_device(data)
通过 UART 向设备写入命令字符串。
- 参数:
data – 发送到设备的命令字符串,以换行符结尾。
UiFlow2:

- ODriveModule.write_config(config, value)
将配置参数写入设备。
- 参数:
config – 配置键(字符串形式),例如 'axis0.controller.config.pos_gain'。
value – 要为配置参数设置的值;可以是浮点数或整数。
UiFlow2:

- ODriveModule.read_config_int(config)
从设备读取一个整数配置参数。
- Return (int):
指定配置参数的整数值;如果解析失败,则返回 0。
- 参数:
config – 配置键的字符串形式,例如 'axis0.encoder.error'。
UiFlow2:

- ODriveModule.read_config_float(config)
从设备中读取浮点配置参数。
- Return (float):
指定配置参数的浮点值;如果解析失败则返回 0.0。
- 参数:
config – 配置键,以字符串形式表示,例如 'axis0.motor_thermistor.temperature'。
UiFlow2:

Constants
- ODriveModule.AXIS_STATE_UNDEFINED
- ODriveModule.AXIS_STATE_IDLE
- ODriveModule.AXIS_STATE_STARTUP_SEQUENCE
- ODriveModule.AXIS_STATE_FULL_CALIBRATION_SEQUENCE
- ODriveModule.AXIS_STATE_MOTOR_CALIBRATION
- ODriveModule.AXIS_STATE_SENSORLESS_CONTROL
- ODriveModule.AXIS_STATE_ENCODER_INDEX_SEARCH
- ODriveModule.AXIS_STATE_ENCODER_OFFSET_CALIBRATION
- ODriveModule.AXIS_STATE_CLOSED_LOOP_CONTROL
轴状态
- ODriveModule.CONTROL_MODE_VOLTAGE_CONTROL
- ODriveModule.CONTROL_MODE_TORQUE_CONTROL
- ODriveModule.CONTROL_MODE_VELOCITY_CONTROL
- ODriveModule.CONTROL_MODE_POSITION_CONTROL
控制模式


