One Motor 0.6.0
RoboMaster全平台一站式电机驱动库
载入中...
搜索中...
未找到
J4310Frame.hpp
浏览该文件的文档.
1
9#ifndef J4310FRAME_HPP
10#define J4310FRAME_HPP
12#include <string>
13
14namespace OneMotor::Motor::DM
15{
18 constexpr float DM_V_MIN = -45.0f;
19 constexpr float DM_V_MAX = 45.0f;
20 constexpr float DM_P_MIN = -12.5f;
21 constexpr float DM_P_MAX = 12.5f;
22 constexpr float DM_T_MIN = -18.0f;
23 constexpr float DM_T_MAX = 18.0f;
24 constexpr float DM_KP_MIN = 0.0f;
25 constexpr float DM_KP_MAX = 500.0f;
26 constexpr float DM_KD_MIN = 0.0f;
27 constexpr float DM_KD_MAX = 5.0f;
29
38 constexpr float uint_to_float(const int x_int, const float x_min, const float x_max, const int bits)
39 {
40 const float span = x_max - x_min;
41 const float offset = x_min;
42 return static_cast<float>(x_int) * span / static_cast<float>((1 << bits) - 1) + offset;
43 }
44
53 constexpr int float_to_uint(const float x, const float x_min, const float x_max, const int bits)
54 {
55 const float span = x_max - x_min;
56 const float offset = x_min;
57 return static_cast<int>((x - offset) * static_cast<float>((1 << bits) - 1) / span);
58 }
59
75
79 struct J4310Status
80 {
81 J4310Status() = default;
82
87 explicit J4310Status(const Can::CanFrame& frame);
88
93 std::string format() const;
94
95 uint8_t ID;
97 float position;
98 float velocity;
99 float torque;
102 };
103}
104#endif //J4310FRAME_HPP
定义了与平台无关的CAN帧结构体。
constexpr int float_to_uint(const float x, const float x_min, const float x_max, const int bits)
将浮点数转换为无符号整数
定义 J4310Frame.hpp:53
constexpr float uint_to_float(const int x_int, const float x_min, const float x_max, const int bits)
将无符号整数转换为浮点数
定义 J4310Frame.hpp:38
constexpr float DM_P_MIN
rad
定义 J4310Frame.hpp:20
DMStatus
DM 系列电机状态枚举
定义 J4310Frame.hpp:64
@ Enabled
电机已启用
定义 J4310Frame.hpp:66
@ OverVoltage
过压错误
定义 J4310Frame.hpp:67
@ RotorOverheat
转子过热错误
定义 J4310Frame.hpp:71
@ UnderVoltage
欠压错误
定义 J4310Frame.hpp:68
@ Overloaded
电机过载
定义 J4310Frame.hpp:73
@ MosOverheat
MOS 过热错误
定义 J4310Frame.hpp:70
@ OverCurrent
过流错误
定义 J4310Frame.hpp:69
@ Disabled
电机已禁用
定义 J4310Frame.hpp:65
@ Disconnected
电机断开连接
定义 J4310Frame.hpp:72
constexpr float DM_V_MAX
rad/s
定义 J4310Frame.hpp:19
constexpr float DM_V_MIN
电机参数限制
定义 J4310Frame.hpp:18
constexpr float DM_T_MIN
N*m
定义 J4310Frame.hpp:22
constexpr float DM_P_MAX
rad
定义 J4310Frame.hpp:21
constexpr float DM_T_MAX
N*m
定义 J4310Frame.hpp:23
一个与平台无关的CAN帧结构体。
定义 CanFrame.hpp:36
float position
电机位置 (rad)
定义 J4310Frame.hpp:97
uint8_t ID
电机 ID
定义 J4310Frame.hpp:95
DMStatus status
电机状态
定义 J4310Frame.hpp:96
float velocity
电机速度 (rad/s)
定义 J4310Frame.hpp:98
float torque
电机扭矩 (N*m)
定义 J4310Frame.hpp:99
std::string format() const
将状态格式化为用于打印的字符串
定义 N_J4310Frame.cpp:26
uint8_t temperature_Rotor
转子温度 (摄氏度)
定义 J4310Frame.hpp:101
uint8_t temperature_MOS
MOS 温度 (摄氏度)
定义 J4310Frame.hpp:100