修复HT电机解算bug,待添加零位校准。修复bsp_can module id未初始化问题
This commit is contained in:
parent
4637cb8297
commit
3dbc0a7b0a
|
@ -42,7 +42,13 @@
|
||||||
"quaternionekf.h": "c",
|
"quaternionekf.h": "c",
|
||||||
"shoot.h": "c",
|
"shoot.h": "c",
|
||||||
"lk9025.h": "c",
|
"lk9025.h": "c",
|
||||||
"ht04.h": "c"
|
"ht04.h": "c",
|
||||||
|
"rtc.h": "c",
|
||||||
|
"tim.h": "c",
|
||||||
|
"usb_device.h": "c",
|
||||||
|
"gpio.h": "c",
|
||||||
|
"rng.h": "c",
|
||||||
|
"cmsis_os.h": "c"
|
||||||
},
|
},
|
||||||
"C_Cpp.default.configurationProvider": "ms-vscode.makefile-tools",
|
"C_Cpp.default.configurationProvider": "ms-vscode.makefile-tools",
|
||||||
"C_Cpp.intelliSenseEngineFallback": "enabled",
|
"C_Cpp.intelliSenseEngineFallback": "enabled",
|
||||||
|
|
|
@ -55,14 +55,14 @@
|
||||||
// 机器人状态
|
// 机器人状态
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
ROBOT_STOP,
|
ROBOT_STOP=0,
|
||||||
ROBOT_READY,
|
ROBOT_READY,
|
||||||
} Robot_Status_e;
|
} Robot_Status_e;
|
||||||
|
|
||||||
// 应用状态
|
// 应用状态
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
APP_OFFLINE,
|
APP_OFFLINE=0,
|
||||||
APP_ONLINE,
|
APP_ONLINE,
|
||||||
APP_ERROR,
|
APP_ERROR,
|
||||||
} App_Status_e;
|
} App_Status_e;
|
||||||
|
@ -74,7 +74,7 @@ typedef enum
|
||||||
*/
|
*/
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
CHASSIS_ZERO_FORCE, // 电流零输入
|
CHASSIS_ZERO_FORCE=0, // 电流零输入
|
||||||
CHASSIS_ROTATE, // 小陀螺模式
|
CHASSIS_ROTATE, // 小陀螺模式
|
||||||
CHASSIS_NO_FOLLOW, // 不跟随,允许全向平移
|
CHASSIS_NO_FOLLOW, // 不跟随,允许全向平移
|
||||||
CHASSIS_FOLLOW_GIMBAL_YAW, // 跟随模式,底盘叠加角度环控制
|
CHASSIS_FOLLOW_GIMBAL_YAW, // 跟随模式,底盘叠加角度环控制
|
||||||
|
@ -83,7 +83,7 @@ typedef enum
|
||||||
// 云台模式设置
|
// 云台模式设置
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
GIMBAL_ZERO_FORCE, // 电流零输入
|
GIMBAL_ZERO_FORCE=0, // 电流零输入
|
||||||
GIMBAL_FREE_MODE, // 云台自由运动模式,即与底盘分离(底盘此时应为NO_FOLLOW)反馈值为电机total_angle;似乎可以改为全部用IMU数据?
|
GIMBAL_FREE_MODE, // 云台自由运动模式,即与底盘分离(底盘此时应为NO_FOLLOW)反馈值为电机total_angle;似乎可以改为全部用IMU数据?
|
||||||
GIMBAL_GYRO_MODE, // 云台陀螺仪反馈模式,反馈值为陀螺仪pitch,total_yaw_angle,底盘可以为小陀螺和跟随模式
|
GIMBAL_GYRO_MODE, // 云台陀螺仪反馈模式,反馈值为陀螺仪pitch,total_yaw_angle,底盘可以为小陀螺和跟随模式
|
||||||
} gimbal_mode_e;
|
} gimbal_mode_e;
|
||||||
|
@ -91,24 +91,24 @@ typedef enum
|
||||||
// 发射模式设置
|
// 发射模式设置
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
SHOOT_ON = 0,
|
SHOOT_OFF = 0,
|
||||||
SHOOT_OFF,
|
SHOOT_ON,
|
||||||
} shoot_mode_e;
|
} shoot_mode_e;
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
FRICTION_OFF, // 摩擦轮关闭
|
FRICTION_OFF=0, // 摩擦轮关闭
|
||||||
FRICTION_ON, // 摩擦轮开启
|
FRICTION_ON, // 摩擦轮开启
|
||||||
} friction_mode_e;
|
} friction_mode_e;
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
LID_CLOSE, // 弹舱盖打开
|
LID_OPEN=0, // 弹舱盖打开
|
||||||
LID_OPEN, // 弹舱盖关闭
|
LID_CLOSE, // 弹舱盖关闭
|
||||||
} lid_mode_e;
|
} lid_mode_e;
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
LOAD_STOP, // 停止发射
|
LOAD_STOP=0, // 停止发射
|
||||||
LOAD_REVERSE, // 反转
|
LOAD_REVERSE, // 反转
|
||||||
LOAD_1_BULLET, // 单发
|
LOAD_1_BULLET, // 单发
|
||||||
LOAD_3_BULLET, // 三发
|
LOAD_3_BULLET, // 三发
|
||||||
|
|
|
@ -79,6 +79,7 @@ CANInstance *CANRegister(CAN_Init_Config_s *config)
|
||||||
instance[idx]->tx_id = config->tx_id; // 好像没用,可以删掉
|
instance[idx]->tx_id = config->tx_id; // 好像没用,可以删掉
|
||||||
instance[idx]->rx_id = config->rx_id;
|
instance[idx]->rx_id = config->rx_id;
|
||||||
instance[idx]->can_module_callback = config->can_module_callback;
|
instance[idx]->can_module_callback = config->can_module_callback;
|
||||||
|
instance[idx]->id=config->id;
|
||||||
|
|
||||||
CANAddFilter(instance[idx]); // 添加CAN过滤器规则
|
CANAddFilter(instance[idx]); // 添加CAN过滤器规则
|
||||||
return instance[idx++]; // 返回指针
|
return instance[idx++]; // 返回指针
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
// PID 优化环节使能标志位
|
// PID 优化环节使能标志位
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
NONE = 0b00000000, // 0000 0000
|
PID_IMPROVE_NONE = 0b00000000, // 0000 0000
|
||||||
Integral_Limit = 0b00000001, // 0000 0001
|
Integral_Limit = 0b00000001, // 0000 0001
|
||||||
Derivative_On_Measurement = 0b00000010, // 0000 0010
|
Derivative_On_Measurement = 0b00000010, // 0000 0010
|
||||||
Trapezoid_Intergral = 0b00000100, // 0000 0100
|
Trapezoid_Intergral = 0b00000100, // 0000 0100
|
||||||
|
|
|
@ -52,13 +52,14 @@ typedef enum
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
MODE_AIM = 0,
|
VISION_MODE_AIM = 0,
|
||||||
MODE_SMALL_BUFF = 1,
|
VISION_MODE_SMALL_BUFF = 1,
|
||||||
MODE_BIG_BUFF = 2
|
VISION_MODE_BIG_BUFF = 2
|
||||||
} Work_Mode_e;
|
} Work_Mode_e;
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
|
BULLET_SPEED_NONE = 0,
|
||||||
BIG_AMU_10 = 10,
|
BIG_AMU_10 = 10,
|
||||||
SMALL_AMU_15 = 15,
|
SMALL_AMU_15 = 15,
|
||||||
BIG_AMU_16 = 16,
|
BIG_AMU_16 = 16,
|
||||||
|
|
|
@ -50,14 +50,14 @@ static void HTMotorDecode(CANInstance *motor_can)
|
||||||
measure->last_angle = measure->total_angle;
|
measure->last_angle = measure->total_angle;
|
||||||
|
|
||||||
tmp = (uint16_t)((rxbuff[1] << 8) | rxbuff[2]);
|
tmp = (uint16_t)((rxbuff[1] << 8) | rxbuff[2]);
|
||||||
measure->total_angle = RAD_2_ANGLE * uint_to_float(tmp, P_MAX, P_MIN, 16);
|
measure->total_angle = RAD_2_ANGLE * uint_to_float(tmp, P_MIN, P_MAX, 16);
|
||||||
|
|
||||||
tmp = (uint16_t)((rxbuff[3] << 4) | (rxbuff[4] >> 4));
|
tmp = (uint16_t)((rxbuff[3] << 4) | (rxbuff[4] >> 4));
|
||||||
measure->speed_aps = RAD_2_ANGLE * SPEED_SMOOTH_COEF * uint_to_float(tmp, V_MAX, V_MIN, 12) +
|
measure->speed_aps = RAD_2_ANGLE * SPEED_SMOOTH_COEF * uint_to_float(tmp, V_MIN, V_MAX, 12) +
|
||||||
(1 - SPEED_SMOOTH_COEF) * measure->speed_aps;
|
(1 - SPEED_SMOOTH_COEF) * measure->speed_aps;
|
||||||
|
|
||||||
tmp = (uint16_t)(((rxbuff[4] & 0x0f) << 8) | rxbuff[5]);
|
tmp = (uint16_t)(((rxbuff[4] & 0x0f) << 8) | rxbuff[5]);
|
||||||
measure->real_current = CURRENT_SMOOTH_COEF * uint_to_float(tmp, T_MAX, T_MIN, 12) +
|
measure->real_current = CURRENT_SMOOTH_COEF * uint_to_float(tmp, T_MIN, T_MAX, 12) +
|
||||||
(1 - CURRENT_SMOOTH_COEF) * measure->real_current;
|
(1 - CURRENT_SMOOTH_COEF) * measure->real_current;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ typedef enum
|
||||||
/* 反馈来源设定,若设为OTHER_FEED则需要指定数据来源指针,详见Motor_Controller_s*/
|
/* 反馈来源设定,若设为OTHER_FEED则需要指定数据来源指针,详见Motor_Controller_s*/
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
MOTOR_FEED,
|
MOTOR_FEED=0,
|
||||||
OTHER_FEED,
|
OTHER_FEED,
|
||||||
} Feedback_Source_e;
|
} Feedback_Source_e;
|
||||||
|
|
||||||
|
@ -94,11 +94,12 @@ typedef struct
|
||||||
/* 电机类型枚举 */
|
/* 电机类型枚举 */
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
GM6020 = 0,
|
MOTOR_TYPE_NONE = 0,
|
||||||
M3508 = 1,
|
GM6020,
|
||||||
M2006 = 2,
|
M3508,
|
||||||
LK9025 = 3,
|
M2006,
|
||||||
HT04 = 4,
|
LK9025,
|
||||||
|
HT04,
|
||||||
} Motor_Type_e;
|
} Motor_Type_e;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue