mirror of
https://gitee.com/dlmu-cone/bf_original_balance_chassis
synced 2026-07-24 03:27:45 +08:00
增加了hardfault调试支持,修复了消息队列在发布者先于订阅者创建话题时野指针的错误
This commit is contained in:
@@ -2,33 +2,149 @@
|
||||
#include "robot_def.h"
|
||||
#include "dji_motor.h"
|
||||
#include "super_cap.h"
|
||||
#include "message_center.h"
|
||||
|
||||
#ifdef CHASSIS_BOARD //使用板载IMU获取底盘转动角速度
|
||||
/* 底盘应用包含的模块和信息存储 */
|
||||
#ifdef CHASSIS_BOARD // 使用板载IMU获取底盘转动角速度
|
||||
#include "ins_task.h"
|
||||
IMU_Data_t* Chassis_IMU_data;
|
||||
IMU_Data_t *Chassis_IMU_data;
|
||||
#endif // CHASSIS_BOARD
|
||||
// static SuperCAP cap;
|
||||
static dji_motor_instance *lf; // left right forward back
|
||||
static dji_motor_instance *rf;
|
||||
static dji_motor_instance *lb;
|
||||
static dji_motor_instance *rb;
|
||||
|
||||
// SuperCAP cap;
|
||||
static dji_motor_instance* lf; //left right forward back
|
||||
static dji_motor_instance* rf;
|
||||
static dji_motor_instance* lb;
|
||||
static dji_motor_instance* rb;
|
||||
static Chassis_Ctrl_Cmd_s chassis_cmd_recv;
|
||||
static Publisher_t* chassis_pub;
|
||||
static Chassis_Upload_Data_s chassis_feedback_data;
|
||||
static Subscriber_t* chassis_sub;
|
||||
static Chassis_Ctrl_Cmd_s chassis_cmd_recv;
|
||||
|
||||
|
||||
static void mecanum_calculate()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ChassisInit()
|
||||
{
|
||||
// 左前轮
|
||||
Motor_Init_Config_s left_foward_config = {
|
||||
.can_init_config = {
|
||||
.can_handle = &hcan2,
|
||||
.tx_id = 1,
|
||||
},
|
||||
.controller_param_init_config = {
|
||||
.angle_PID = {
|
||||
.Kd = 10,
|
||||
.Ki = 1,
|
||||
.Kd = 2,
|
||||
},
|
||||
.speed_PID = {
|
||||
|
||||
},
|
||||
.current_PID = {
|
||||
|
||||
},
|
||||
},
|
||||
.controller_setting_init_config = {
|
||||
.angle_feedback_source = MOTOR_FEED,
|
||||
.speed_feedback_source = MOTOR_FEED,
|
||||
.close_loop_type = SPEED_LOOP | CURRENT_LOOP,
|
||||
.reverse_flag = MOTOR_DIRECTION_REVERSE,
|
||||
},
|
||||
.motor_type = M3508};
|
||||
// 右前轮
|
||||
Motor_Init_Config_s right_foward_config = {
|
||||
.can_init_config = {
|
||||
.can_handle = &hcan2,
|
||||
.tx_id = 2,
|
||||
},
|
||||
.controller_param_init_config = {
|
||||
.angle_PID = {
|
||||
.Kd = 10,
|
||||
.Ki = 1,
|
||||
.Kd = 2,
|
||||
},
|
||||
.speed_PID = {
|
||||
|
||||
},
|
||||
.current_PID = {
|
||||
|
||||
},
|
||||
},
|
||||
.controller_setting_init_config = {
|
||||
.angle_feedback_source = MOTOR_FEED,
|
||||
.speed_feedback_source = MOTOR_FEED,
|
||||
.close_loop_type = SPEED_LOOP | CURRENT_LOOP,
|
||||
.reverse_flag = MOTOR_DIRECTION_REVERSE,
|
||||
},
|
||||
.motor_type = M3508};
|
||||
// 左后轮
|
||||
Motor_Init_Config_s left_back_config = {
|
||||
.can_init_config = {
|
||||
.can_handle = &hcan2,
|
||||
.tx_id = 3,
|
||||
},
|
||||
.controller_param_init_config = {
|
||||
.angle_PID = {
|
||||
.Kd = 10,
|
||||
.Ki = 1,
|
||||
.Kd = 2,
|
||||
},
|
||||
.speed_PID = {
|
||||
|
||||
},
|
||||
.current_PID = {
|
||||
|
||||
},
|
||||
},
|
||||
.controller_setting_init_config = {
|
||||
.angle_feedback_source = MOTOR_FEED,
|
||||
.speed_feedback_source = MOTOR_FEED,
|
||||
.close_loop_type = SPEED_LOOP | CURRENT_LOOP,
|
||||
.reverse_flag = MOTOR_DIRECTION_REVERSE,
|
||||
},
|
||||
.motor_type = M3508};
|
||||
// 右后轮
|
||||
Motor_Init_Config_s right_back_config = {
|
||||
.can_init_config = {
|
||||
.can_handle = &hcan2,
|
||||
.tx_id = 4,
|
||||
},
|
||||
.controller_param_init_config = {
|
||||
.angle_PID = {
|
||||
.Kd = 10,
|
||||
.Ki = 1,
|
||||
.Kd = 2,
|
||||
},
|
||||
.speed_PID = {
|
||||
|
||||
},
|
||||
.current_PID = {
|
||||
|
||||
},
|
||||
},
|
||||
.controller_setting_init_config = {
|
||||
.angle_feedback_source = MOTOR_FEED,
|
||||
.speed_feedback_source = MOTOR_FEED,
|
||||
.close_loop_type = SPEED_LOOP | CURRENT_LOOP,
|
||||
.reverse_flag = MOTOR_DIRECTION_REVERSE,
|
||||
},
|
||||
.motor_type = M3508};
|
||||
|
||||
lf = DJIMotorInit(&left_foward_config);
|
||||
rf = DJIMotorInit(&right_foward_config);
|
||||
lb = DJIMotorInit(&left_back_config);
|
||||
rb = DJIMotorInit(&right_back_config);
|
||||
|
||||
// SupercapInit();
|
||||
|
||||
chassis_sub=SubRegister("chassis_cmd",sizeof(Chassis_Ctrl_Cmd_s));
|
||||
chassis_pub=PubRegister("chassis_feed",sizeof(Chassis_Upload_Data_s));
|
||||
}
|
||||
|
||||
void ChassisTask()
|
||||
void ChassisTask()
|
||||
{
|
||||
|
||||
}
|
||||
@@ -1,22 +1,38 @@
|
||||
#include "robot_def.h"
|
||||
#include "chassis_cmd.h"
|
||||
#include "referee.h"
|
||||
#include "message_center.h"
|
||||
|
||||
|
||||
/* chassis_cmd应用包含的模块和信息存储 */
|
||||
static referee_info_t *referee_data; // 裁判系统的数据
|
||||
#ifndef ONE_BOARD
|
||||
#include "can_comm.h"
|
||||
static CANCommInstance *chasiss_can_comm; // 双板通信CAN comm
|
||||
#endif // !ONE_BOARD
|
||||
|
||||
#endif // !ONE_BOARD
|
||||
//和chassis应用的交互
|
||||
static Publisher_t* chassis_cmd_pub;
|
||||
static Chassis_Ctrl_Cmd_s chassis_cmd; // 发送给chassis应用的控制信息
|
||||
static Subscriber_t* chassis_feed_sub;
|
||||
static Chassis_Upload_Data_s chassis_fetch_data; // chassis反馈的数据
|
||||
//和gimbal_cmd的交互
|
||||
static Publisher_t* chassis2gimbal_pub;
|
||||
static Chassis2Gimbal_Data_s data_to_gimbal_cmd; // 发送给gimbal_cmd的数据,包括热量限制,底盘功率等
|
||||
static Subscriber_t* gimbal2chassis_sub;
|
||||
static Gimbal2Chassis_Data_s data_from_gimbal_cmd; // 来自gimbal_cmd的数据,主要是底盘控制量
|
||||
static referee_info_t *referee_data; // 裁判系统的数据
|
||||
|
||||
|
||||
void ChassisCMDInit()
|
||||
{
|
||||
referee_data= RefereeInit(&huart6);
|
||||
|
||||
chassis_cmd_pub=PubRegister("chassis_cmd",sizeof(Chassis_Ctrl_Cmd_s));
|
||||
chassis_feed_sub=SubRegister("chassis_feed",sizeof(Chassis_Upload_Data_s));
|
||||
chassis2gimbal_pub=PubRegister("chassis2gimbal",sizeof(Chassis2Gimbal_Data_s));
|
||||
gimbal2chassis_sub=SubRegister("gimbal2chassis",sizeof(Gimbal2Chassis_Data_s));
|
||||
}
|
||||
|
||||
void ChassisCMDTask()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -3,22 +3,34 @@
|
||||
#include "remote_control.h"
|
||||
#include "ins_task.h"
|
||||
#include "master_process.h"
|
||||
#include "message_center.h"
|
||||
|
||||
|
||||
/* gimbal_cmd应用包含的模块实例指针和交互信息存储*/
|
||||
#ifndef ONE_BOARD
|
||||
#include "can_comm.h"
|
||||
static CANCommInstance *chasiss_can_comm;
|
||||
static CANCommInstance *chasiss_can_comm; //双板通信
|
||||
#endif // !ONE_BOARD
|
||||
|
||||
static Gimbal_Ctrl_Cmd_s gimbal_cmd_send; // 传递给云台的控制信息
|
||||
static Shoot_Ctrl_Cmd_s shoot_cmd_send; // 传递给发射的控制信息
|
||||
static Gimbal_Upload_Data_s gimbal_fetch_data; // 从云台获取的反馈信息
|
||||
static Shoot_Upload_Data_s shoot_fetch_data; // 从发射获取的反馈信息
|
||||
static Gimbal2Chassis_Data_s data_to_chassis_cmd; // 发送给底盘CMD应用的控制信息,主要是遥控器和UI绘制相关
|
||||
static Chassis2Gimbal_Data_s data_from_chassis_cmd; // 从底盘CMD应用接收的控制信息,底盘功率枪口热量等
|
||||
static RC_ctrl_t *remote_control_data; // 遥控器数据
|
||||
static Vision_Recv_s *vision_recv_data; // 视觉接收数据
|
||||
static Vision_Send_s *vision_send_data; // 视觉发送数据
|
||||
|
||||
static Publisher_t* gimbal_cmd_pub;
|
||||
static Gimbal_Ctrl_Cmd_s gimbal_cmd_send; // 传递给云台的控制信息
|
||||
static Subscriber_t* gimbal_cmd_feed_sub;
|
||||
static Gimbal_Upload_Data_s gimbal_fetch_data; // 从云台获取的反馈信息
|
||||
|
||||
static Publisher_t* shoot_cmd_pub;
|
||||
static Shoot_Ctrl_Cmd_s shoot_cmd_send; // 传递给发射的控制信息
|
||||
static Subscriber_t* shoot_cmd_feed_sub;
|
||||
static Shoot_Upload_Data_s shoot_fetch_data; // 从发射获取的反馈信息
|
||||
|
||||
static Publisher_t* gimbal2chassis_pub;
|
||||
static Gimbal2Chassis_Data_s data_to_chassis_cmd; // 发送给底盘CMD应用的控制信息,主要是遥控器和UI绘制相关
|
||||
static Subscriber_t* chassis2gimbal_sub;
|
||||
static Chassis2Gimbal_Data_s data_from_chassis_cmd; // 从底盘CMD应用接收的控制信息,底盘功率枪口热量等
|
||||
|
||||
|
||||
static void CalcOffsetAngle()
|
||||
{
|
||||
}
|
||||
@@ -37,6 +49,15 @@ static void SetCtrlMessage()
|
||||
|
||||
void GimbalCMDInit()
|
||||
{
|
||||
remote_control_data=RC_init(&huart3);
|
||||
vision_recv_data=VisionInit(&huart1);
|
||||
|
||||
gimbal_cmd_pub=PubRegister("gimbal_cmd",sizeof(Gimbal_Ctrl_Cmd_s));
|
||||
gimbal_cmd_feed_sub=SubRegister("gimbal_feed",sizeof(Gimbal_Upload_Data_s));
|
||||
shoot_cmd_pub=PubRegister("shoot_cmd",sizeof(Shoot_Ctrl_Cmd_s));
|
||||
shoot_cmd_feed_sub=SubRegister("shoot_feed",sizeof(Shoot_Upload_Data_s));
|
||||
gimbal2chassis_pub=PubRegister("gimbal2chassis",sizeof(Gimbal2Chassis_Data_s));
|
||||
chassis2gimbal_sub=SubRegister("chassis2gimbal",sizeof(Chassis2Gimbal_Data_s));
|
||||
}
|
||||
|
||||
void GimbalCMDTask()
|
||||
|
||||
@@ -2,15 +2,76 @@
|
||||
#include "robot_def.h"
|
||||
#include "dji_motor.h"
|
||||
#include "ins_task.h"
|
||||
#include "message_center.h"
|
||||
|
||||
static IMU_Data_t Gimbal_IMU_data; // 云台IMU数据
|
||||
static dji_motor_instance yaw; // yaw电机
|
||||
static dji_motor_instance pitch; // pitch电机
|
||||
static Gimbal_Ctrl_Cmd_s gimbal_cmd_recv; // 来自gimbal_cmd的控制信息
|
||||
|
||||
static attitude_t* Gimbal_IMU_data; // 云台IMU数据
|
||||
static dji_motor_instance* yaw_motor; // yaw电机
|
||||
static dji_motor_instance *pitch_motor; // pitch电机
|
||||
|
||||
static Publisher_t* gimbal_pub;
|
||||
static Gimbal_Upload_Data_s gimbal_feedback_data; // 回传给gimbal_cmd的云台状态信息
|
||||
static Subscriber_t* gimbal_sub;
|
||||
static Gimbal_Ctrl_Cmd_s gimbal_cmd_recv; // 来自gimbal_cmd的控制信息
|
||||
|
||||
|
||||
void GimbalInit()
|
||||
{
|
||||
Gimbal_IMU_data=INS_Init();
|
||||
|
||||
// YAW
|
||||
Motor_Init_Config_s yaw_config = {
|
||||
.can_init_config = {
|
||||
.can_handle = &hcan1,
|
||||
.tx_id = 1,
|
||||
},
|
||||
.controller_param_init_config = {
|
||||
.angle_PID = {
|
||||
.Kd = 10,
|
||||
.Ki = 1,
|
||||
.Kd = 2,
|
||||
},
|
||||
.speed_PID = {
|
||||
|
||||
},
|
||||
.other_angle_feedback_ptr=&Gimbal_IMU_data->YawTotalAngle,
|
||||
},
|
||||
.controller_setting_init_config = {
|
||||
.angle_feedback_source = MOTOR_FEED,
|
||||
.speed_feedback_source = MOTOR_FEED,
|
||||
.close_loop_type = ANGLE_LOOP | SPEED_LOOP,
|
||||
.reverse_flag = MOTOR_DIRECTION_REVERSE,
|
||||
},
|
||||
.motor_type = GM6020};
|
||||
// PITCH
|
||||
Motor_Init_Config_s pitch_config = {
|
||||
.can_init_config = {
|
||||
.can_handle = &hcan1,
|
||||
.tx_id = 2,
|
||||
},
|
||||
.controller_param_init_config = {
|
||||
.angle_PID = {
|
||||
.Kd = 10,
|
||||
.Ki = 1,
|
||||
.Kd = 2,
|
||||
},
|
||||
.speed_PID = {
|
||||
|
||||
},
|
||||
},
|
||||
.controller_setting_init_config = {
|
||||
.angle_feedback_source = MOTOR_FEED,
|
||||
.speed_feedback_source = MOTOR_FEED,
|
||||
.close_loop_type = ANGLE_LOOP | SPEED_LOOP,
|
||||
.reverse_flag = MOTOR_DIRECTION_REVERSE,
|
||||
},
|
||||
.motor_type = GM6020};
|
||||
|
||||
yaw_motor=DJIMotorInit(&yaw_config);
|
||||
pitch_motor=DJIMotorInit(&pitch_config);
|
||||
|
||||
gimbal_pub=PubRegister("gimbal_feed",sizeof(Gimbal_Upload_Data_s));
|
||||
gimbal_sub=SubRegister("gimbal_cmd",sizeof(Gimbal_Ctrl_Cmd_s));
|
||||
}
|
||||
|
||||
void GimbalTask()
|
||||
|
||||
@@ -3,32 +3,40 @@
|
||||
|
||||
#if defined(ONE_BOARD) || defined(CHASSIS_BOARD)
|
||||
#include "chassis.h"
|
||||
#include "chassis_cmd.h"
|
||||
#endif
|
||||
#if defined(ONE_BOARD) || defined(GIMBAL_BOARD)
|
||||
#include "gimbal.h"
|
||||
#include "shoot.h"
|
||||
#include "gimbal_cmd.h"
|
||||
#endif
|
||||
|
||||
|
||||
void RobotInit()
|
||||
{
|
||||
|
||||
#if defined(ONE_BOARD) || defined(CHASSIS_BOARD)
|
||||
|
||||
ChassisInit();
|
||||
ChassisCMDInit();
|
||||
#endif
|
||||
|
||||
#if defined(ONE_BOARD) || defined(GIMBAL_BOARD)
|
||||
|
||||
GimbalCMDInit();
|
||||
GimbalInit();
|
||||
ShootInit();
|
||||
#endif
|
||||
}
|
||||
|
||||
void RobotTask()
|
||||
{
|
||||
#if defined(ONE_BOARD) || defined(CHASSIS_BOARD)
|
||||
|
||||
ChassisTask();
|
||||
ChassisCMDTask();
|
||||
#endif
|
||||
|
||||
#if defined(ONE_BOARD) || defined(GIMBAL_BOARD)
|
||||
|
||||
GimbalCMDTask();
|
||||
GimbalTask();
|
||||
ShootTask();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +1,106 @@
|
||||
#include "shoot.h"
|
||||
#include "robot_def.h"
|
||||
#include "dji_motor.h"
|
||||
#include "message_center.h"
|
||||
|
||||
static dji_motor_instance *friction_l; // 左摩擦轮
|
||||
static dji_motor_instance *friction_r; // 右摩擦轮
|
||||
static dji_motor_instance *loader; // 拨盘电机
|
||||
static Shoot_Ctrl_Cmd_s shoot_cmd_recv; // 来自gimbal_cmd的发射控制信息
|
||||
static Shoot_Upload_Data_s shoot_feedback_data; // 反馈回gimbal_cmd的发射状态信息
|
||||
/* 对于双发射机构的机器人,将下面的数据封装成结构体即可,生成两份shoot应用实例
|
||||
*/
|
||||
static dji_motor_instance *friction_l; // 左摩擦轮
|
||||
static dji_motor_instance *friction_r; // 右摩擦轮
|
||||
static dji_motor_instance *loader; // 拨盘电机
|
||||
|
||||
static Publisher_t *shoot_pub;
|
||||
static Shoot_Ctrl_Cmd_s shoot_cmd_recv; // 来自gimbal_cmd的发射控制信息
|
||||
static Subscriber_t *shoot_sub;
|
||||
static Shoot_Upload_Data_s shoot_feedback_data; // 来自gimbal_cmd的发射控制信息
|
||||
|
||||
void ShootInit()
|
||||
{
|
||||
// 左摩擦轮
|
||||
Motor_Init_Config_s left_friction_config = {
|
||||
.can_init_config = {
|
||||
.can_handle = &hcan1,
|
||||
.tx_id = 1,
|
||||
},
|
||||
.controller_param_init_config = {
|
||||
.angle_PID = {
|
||||
.Kd = 10,
|
||||
.Ki = 1,
|
||||
.Kd = 2,
|
||||
},
|
||||
.speed_PID = {
|
||||
|
||||
},
|
||||
.current_PID = {
|
||||
|
||||
},
|
||||
},
|
||||
.controller_setting_init_config = {
|
||||
.angle_feedback_source = MOTOR_FEED,
|
||||
.speed_feedback_source = MOTOR_FEED,
|
||||
.close_loop_type = SPEED_LOOP | CURRENT_LOOP,
|
||||
.reverse_flag = MOTOR_DIRECTION_REVERSE,
|
||||
},
|
||||
.motor_type = M3508};
|
||||
// 右摩擦轮
|
||||
Motor_Init_Config_s right_friction_config = {
|
||||
.can_init_config = {
|
||||
.can_handle = &hcan1,
|
||||
.tx_id = 2,
|
||||
},
|
||||
.controller_param_init_config = {
|
||||
.angle_PID = {
|
||||
.Kd = 10,
|
||||
.Ki = 1,
|
||||
.Kd = 2,
|
||||
},
|
||||
.speed_PID = {
|
||||
|
||||
},
|
||||
.current_PID = {
|
||||
|
||||
},
|
||||
},
|
||||
.controller_setting_init_config = {
|
||||
.angle_feedback_source = MOTOR_FEED,
|
||||
.speed_feedback_source = MOTOR_FEED,
|
||||
.close_loop_type = SPEED_LOOP | CURRENT_LOOP,
|
||||
.reverse_flag = MOTOR_DIRECTION_REVERSE,
|
||||
},
|
||||
.motor_type = M3508};
|
||||
// 拨盘电机
|
||||
Motor_Init_Config_s loader_config = {
|
||||
.can_init_config = {
|
||||
.can_handle = &hcan1,
|
||||
.tx_id = 3,
|
||||
},
|
||||
.controller_param_init_config = {
|
||||
.angle_PID = {
|
||||
.Kd = 10,
|
||||
.Ki = 1,
|
||||
.Kd = 2,
|
||||
},
|
||||
.speed_PID = {
|
||||
|
||||
},
|
||||
.current_PID = {
|
||||
|
||||
},
|
||||
},
|
||||
.controller_setting_init_config = {
|
||||
.angle_feedback_source = MOTOR_FEED,
|
||||
.speed_feedback_source = MOTOR_FEED,
|
||||
.close_loop_type = SPEED_LOOP | CURRENT_LOOP,
|
||||
.reverse_flag = MOTOR_DIRECTION_REVERSE,
|
||||
},
|
||||
.motor_type = M2006};
|
||||
|
||||
friction_l = DJIMotorInit(&left_friction_config);
|
||||
friction_r = DJIMotorInit(&right_friction_config);
|
||||
loader = DJIMotorInit(&loader_config);
|
||||
|
||||
shoot_pub = PubRegister("shoot_feed", sizeof(Shoot_Upload_Data_s));
|
||||
shoot_sub = SubRegister("shoot_cmd", sizeof(Shoot_Ctrl_Cmd_s));
|
||||
}
|
||||
|
||||
void ShootTask()
|
||||
|
||||
Reference in New Issue
Block a user