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