One Motor 0.5.1
RoboMaster全平台一站式电机驱动库
载入中...
搜索中...
未找到
OneMotor::Motor::DJI::M3508Base< id > 模板类 参考abstract

M3508电机的抽象基类,提供通用接口和基础功能。 更多...

#include <M3508Base.hpp>

类 OneMotor::Motor::DJI::M3508Base< id > 继承关系图:
OneMotor::Motor::DJI::M3508< id, MotorMode::Angular > OneMotor::Motor::DJI::M3508< id, MotorMode::Position >

Public 成员函数

virtual ~M3508Base ()
 虚析构函数。
 
M3508Status getStatus () noexcept
 获取电机当前的状态。
 
Result disable () noexcept
 禁用电机。
 
Result enable () noexcept
 启用电机。
 
Result shutdown () noexcept
 关闭电机。
 

Protected 成员函数

 M3508Base (Can::CanDriver &driver)
 基类构造函数。
 
virtual void disabled_func_ (Can::CanFrame &&frame)=0
 纯虚函数,由派生类实现在“禁用”状态下的CAN帧处理逻辑。
 
virtual void enabled_func_ (Can::CanFrame &&frame)=0
 纯虚函数,由派生类实现在“启用”状态下的CAN帧处理逻辑。
 

静态 Protected 成员函数

static void shutdown_func_ (Can::CanFrame &&frame)
 “关闭”状态下的回调函数,不做任何事情。
 

Protected 属性

Can::CanDriverdriver_
 CAN总线驱动的引用
 
Util::SpinLock status_lock_
 用于保护状态访问的自旋锁
 
M3508Status status_
 电机的状态信息
 

静态 Protected 属性

static constexpr uint16_t canId_ = id + 0x200
 电机的CAN ID (标准ID范围 0x201-0x208)
 

详细描述

template<uint8_t id>
class OneMotor::Motor::DJI::M3508Base< id >

M3508电机的抽象基类,提供通用接口和基础功能。

模板参数
id电机的ID (1-8)。这决定了它在CAN总线上的地址以及在MotorManager中的位置。

此基类处理与 MotorManager 的交互(注册/注销), 并定义了启用(enable)、禁用(disable)、关闭(shutdown)电机和获取状态的公共接口。 具体的控制逻辑(例如,在启用状态下如何处理CAN反馈)由派生类通过重写纯虚函数 enabled_func_disabled_func_ 来实现。

构造及析构函数说明

◆ ~M3508Base()

template<uint8_t id>
OneMotor::Motor::DJI::M3508Base< id >::~M3508Base ( )
virtual

虚析构函数。

确保在对象销毁时,能正确地从MotorManager中注销电机。

◆ M3508Base()

template<uint8_t id>
OneMotor::Motor::DJI::M3508Base< id >::M3508Base ( Can::CanDriver & driver)
explicitprotected

基类构造函数。

参数
driver电机连接的CAN总线驱动实例。

在构造时会自动向MotorManager注册该电机。

成员函数说明

◆ disable()

template<uint8_t id>
Result OneMotor::Motor::DJI::M3508Base< id >::disable ( )
noexcept

禁用电机。

电机将停止主动控制,但仍会接收和更新状态。控制器输出将被忽略。

返回
Result 操作结果。

◆ disabled_func_()

template<uint8_t id>
virtual void OneMotor::Motor::DJI::M3508Base< id >::disabled_func_ ( Can::CanFrame && frame)
protectedpure virtual

纯虚函数,由派生类实现在“禁用”状态下的CAN帧处理逻辑。

参数
frame接收到的CAN帧。

◆ enable()

template<uint8_t id>
Result OneMotor::Motor::DJI::M3508Base< id >::enable ( )
noexcept

启用电机。

电机将根据设定的模式和目标值开始主动控制。

返回
Result 操作结果。

◆ enabled_func_()

template<uint8_t id>
virtual void OneMotor::Motor::DJI::M3508Base< id >::enabled_func_ ( Can::CanFrame && frame)
protectedpure virtual

纯虚函数,由派生类实现在“启用”状态下的CAN帧处理逻辑。

参数
frame接收到的CAN帧。

◆ getStatus()

template<uint8_t id>
M3508Status OneMotor::Motor::DJI::M3508Base< id >::getStatus ( )
noexcept

获取电机当前的状态。

返回
M3508Status 结构体的一个拷贝,包含了角度、速度、电流等信息。
注解
此操作是线程安全的。

◆ shutdown()

template<uint8_t id>
Result OneMotor::Motor::DJI::M3508Base< id >::shutdown ( )
noexcept

关闭电机。

电机将完全停止响应,不进行任何处理。

返回
Result 操作结果。

◆ shutdown_func_()

template<uint8_t id>
static void OneMotor::Motor::DJI::M3508Base< id >::shutdown_func_ ( Can::CanFrame && frame)
inlinestaticprotected

“关闭”状态下的回调函数,不做任何事情。

参数
frame接收到的CAN帧 (未使用)。

该类的文档由以下文件生成: