mirror of
https://gitee.com/dlmu-cone/half-steering-basic-framework
synced 2026-10-23 09:32:20 +08:00
赛场_v1.2
This commit is contained in:
@@ -440,6 +440,9 @@ void ChassisTask()
|
||||
// 根据电机的反馈速度和IMU(如果有)计算真实速度
|
||||
EstimateSpeed();
|
||||
|
||||
// 将robot_level传递给UI数据
|
||||
ui_data.robot_level = chassis_cmd_recv.robot_level;
|
||||
|
||||
// // 获取裁判系统数据 建议将裁判系统与底盘分离,所以此处数据应使用消息中心发送
|
||||
// // 我方颜色id小于7是红色,大于7是蓝色,注意这里发送的是对方的颜色, 0:blue , 1:red
|
||||
// chassis_feedback_data.enemy_color = referee_data->GameRobotState.robot_id > 7 ? 1 : 0;
|
||||
@@ -454,4 +457,4 @@ void ChassisTask()
|
||||
#ifdef CHASSIS_BOARD
|
||||
CANCommSend(chasiss_can_comm, (void *)&chassis_feedback_data);
|
||||
#endif // CHASSIS_BOARD
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "message_center.h"
|
||||
#include "general_def.h"
|
||||
#include "dji_motor.h"
|
||||
#include "referee_task.h"
|
||||
// bsp
|
||||
#include "bsp_dwt.h"
|
||||
#include "bsp_log.h"
|
||||
@@ -255,6 +256,15 @@ static void MouseKeySet()
|
||||
rc_data[TEMP].key_count[KEY_PRESS][Key_G] = 0; // 清除计数器,防止重复执行
|
||||
}
|
||||
|
||||
// B键刷新裁判系统UI
|
||||
if (rc_data[TEMP].key[KEY_PRESS].b && rc_data[TEMP].key_count[KEY_PRESS][Key_B] > 0) {
|
||||
MyUIInit(); // 重新初始化UI
|
||||
rc_data[TEMP].key_count[KEY_PRESS][Key_B] = 0; // 清除计数器,防止重复执行
|
||||
}
|
||||
|
||||
// 将robot_level传递给底盘控制命令
|
||||
chassis_cmd_send.robot_level = robot_level;
|
||||
|
||||
switch (robot_level)
|
||||
{
|
||||
case 1:
|
||||
|
||||
@@ -85,7 +85,7 @@ void GimbalInit()
|
||||
// },
|
||||
.controller_param_init_config = {
|
||||
.angle_PID = {
|
||||
.Kp = 0.75, //0.55
|
||||
.Kp = 1.00, //0.90
|
||||
.Ki = 0.05,//0.05
|
||||
.Kd = 0.02,//0.02
|
||||
.CoefA =0.5,//0.5
|
||||
|
||||
@@ -154,7 +154,7 @@ typedef struct
|
||||
chassis_mode_e chassis_mode;
|
||||
int chassis_speed_buff;
|
||||
// UI部分
|
||||
// ...
|
||||
uint8_t robot_level; // 机器人等级
|
||||
|
||||
} Chassis_Ctrl_Cmd_s;
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ static Graph_Data_t UI_shoot_line[10]; // 射击准线
|
||||
static Graph_Data_t UI_Energy[3]; // 电容能量条
|
||||
static String_Data_t UI_State_sta[6]; // 机器人状态,静态只需画一次
|
||||
static String_Data_t UI_State_dyn[6]; // 机器人状态,动态先add才能change
|
||||
static uint32_t shoot_line_location[10] = {540, 960, 490, 515, 565};
|
||||
static uint32_t shoot_line_location[10] = {525, 950, 490, 515, 565};
|
||||
|
||||
void MyUIInit()
|
||||
{
|
||||
@@ -73,12 +73,12 @@ void MyUIInit()
|
||||
UILineDraw(&UI_shoot_line[0], "sl0", UI_Graph_ADD, 7, UI_Color_White, 3, 710, shoot_line_location[0], 1210, shoot_line_location[0]);
|
||||
UILineDraw(&UI_shoot_line[1], "sl1", UI_Graph_ADD, 7, UI_Color_White, 3, shoot_line_location[1], 340, shoot_line_location[1], 740);
|
||||
UILineDraw(&UI_shoot_line[2], "sl2", UI_Graph_ADD, 7, UI_Color_Yellow, 2, 810, shoot_line_location[2], 1110, shoot_line_location[2]);
|
||||
UILineDraw(&UI_shoot_line[3], "sl3", UI_Graph_ADD, 7, UI_Color_Yellow, 2, 810, shoot_line_location[3], 1110, shoot_line_location[3]);
|
||||
UILineDraw(&UI_shoot_line[3], "sl3", UI_Graph_ADD, 7, UI_Color_Yellow, 2, 860, 475, 1060, 475);
|
||||
UILineDraw(&UI_shoot_line[4], "sl4", UI_Graph_ADD, 7, UI_Color_Yellow, 2, 810, shoot_line_location[4], 1110, shoot_line_location[4]);
|
||||
UIGraphRefresh(&referee_recv_info->referee_id, 5, UI_shoot_line[0], UI_shoot_line[1], UI_shoot_line[2], UI_shoot_line[3], UI_shoot_line[4]);
|
||||
|
||||
// 绘制车辆状态标志指示
|
||||
UICharDraw(&UI_State_sta[0], "ss0", UI_Graph_ADD, 8, UI_Color_Main, 15, 2, 150, 750, "chassis:");
|
||||
UICharDraw(&UI_State_sta[0], "ss0", UI_Graph_ADD, 8, UI_Color_Main, 15, 2, 150, 750, "level:");
|
||||
UICharRefresh(&referee_recv_info->referee_id, UI_State_sta[0]);
|
||||
UICharDraw(&UI_State_sta[1], "ss1", UI_Graph_ADD, 8, UI_Color_Yellow, 15, 2, 150, 700, "gimbal:");
|
||||
UICharRefresh(&referee_recv_info->referee_id, UI_State_sta[1]);
|
||||
@@ -91,7 +91,7 @@ void MyUIInit()
|
||||
|
||||
// 绘制车辆状态标志,动态
|
||||
// 由于初始化时xxx_last_mode默认为0,所以此处对应UI也应该设为0时对应的UI,防止模式不变的情况下无法置位flag,导致UI无法刷新
|
||||
UICharDraw(&UI_State_dyn[0], "sd0", UI_Graph_ADD, 8, UI_Color_Main, 15, 2, 270, 750, "zeroforce");
|
||||
UICharDraw(&UI_State_dyn[0], "sd0", UI_Graph_ADD, 8, UI_Color_Main, 15, 2, 270, 750, "1");
|
||||
UICharRefresh(&referee_recv_info->referee_id, UI_State_dyn[0]);
|
||||
UICharDraw(&UI_State_dyn[1], "sd1", UI_Graph_ADD, 8, UI_Color_Yellow, 15, 2, 270, 700, "zeroforce");
|
||||
UICharRefresh(&referee_recv_info->referee_id, UI_State_dyn[1]);
|
||||
@@ -116,7 +116,7 @@ void MyUIInit()
|
||||
UIGraphRefresh(&referee_recv_info->referee_id, 2, UI_Energy[1], UI_Energy[2]);
|
||||
}
|
||||
|
||||
// 测试用函数,实现模式自动变化,用于检查该任务和裁判系统是否连接正常
|
||||
// 测试用函数,实现模式自动变化,用于检查该任务和裁判系统是否连接正常.
|
||||
static uint8_t count = 0;
|
||||
static uint16_t count1 = 0;
|
||||
static void RobotModeTest(Referee_Interactive_info_t *_Interactive_data) // 测试用函数,实现模式自动变化
|
||||
@@ -176,27 +176,15 @@ static void RobotModeTest(Referee_Interactive_info_t *_Interactive_data) // 测
|
||||
static void MyUIRefresh(referee_info_t *referee_recv_info, Referee_Interactive_info_t *_Interactive_data)
|
||||
{
|
||||
UIChangeCheck(_Interactive_data);
|
||||
// chassis
|
||||
if (_Interactive_data->Referee_Interactive_Flag.chassis_flag == 1)
|
||||
// robot level
|
||||
if (_Interactive_data->Referee_Interactive_Flag.robot_level_flag == 1)
|
||||
{
|
||||
switch (_Interactive_data->chassis_mode)
|
||||
{
|
||||
case CHASSIS_ZERO_FORCE:
|
||||
UICharDraw(&UI_State_dyn[0], "sd0", UI_Graph_Change, 8, UI_Color_Main, 15, 2, 270, 750, "zeroforce");
|
||||
break;
|
||||
case CHASSIS_ROTATE:
|
||||
UICharDraw(&UI_State_dyn[0], "sd0", UI_Graph_Change, 8, UI_Color_Main, 15, 2, 270, 750, "rotate ");
|
||||
// 此处注意字数对齐问题,字数相同才能覆盖掉
|
||||
break;
|
||||
case CHASSIS_NO_FOLLOW:
|
||||
UICharDraw(&UI_State_dyn[0], "sd0", UI_Graph_Change, 8, UI_Color_Main, 15, 2, 270, 750, "nofollow ");
|
||||
break;
|
||||
case CHASSIS_FOLLOW_GIMBAL_YAW:
|
||||
UICharDraw(&UI_State_dyn[0], "sd0", UI_Graph_Change, 8, UI_Color_Main, 15, 2, 270, 750, "follow ");
|
||||
break;
|
||||
}
|
||||
char level_str[2];
|
||||
level_str[0] = '0' + _Interactive_data->robot_level;
|
||||
level_str[1] = '\0';
|
||||
UICharDraw(&UI_State_dyn[0], "sd0", UI_Graph_Change, 8, UI_Color_Main, 15, 2, 270, 750, level_str);
|
||||
UICharRefresh(&referee_recv_info->referee_id, UI_State_dyn[0]);
|
||||
_Interactive_data->Referee_Interactive_Flag.chassis_flag = 0;
|
||||
_Interactive_data->Referee_Interactive_Flag.robot_level_flag = 0;
|
||||
}
|
||||
// gimbal
|
||||
if (_Interactive_data->Referee_Interactive_Flag.gimbal_flag == 1)
|
||||
@@ -261,6 +249,12 @@ static void MyUIRefresh(referee_info_t *referee_recv_info, Referee_Interactive_i
|
||||
*/
|
||||
static void UIChangeCheck(Referee_Interactive_info_t *_Interactive_data)
|
||||
{
|
||||
if (_Interactive_data->robot_level != _Interactive_data->robot_last_level)
|
||||
{
|
||||
_Interactive_data->Referee_Interactive_Flag.robot_level_flag = 1;
|
||||
_Interactive_data->robot_last_level = _Interactive_data->robot_level;
|
||||
}
|
||||
|
||||
if (_Interactive_data->chassis_mode != _Interactive_data->chassis_last_mode)
|
||||
{
|
||||
_Interactive_data->Referee_Interactive_Flag.chassis_flag = 1;
|
||||
@@ -296,4 +290,4 @@ static void UIChangeCheck(Referee_Interactive_info_t *_Interactive_data)
|
||||
_Interactive_data->Referee_Interactive_Flag.Power_flag = 1;
|
||||
_Interactive_data->Chassis_last_Power_Data.chassis_power_mx = _Interactive_data->Chassis_Power_Data.chassis_power_mx;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -54,6 +54,7 @@ typedef struct
|
||||
uint32_t lid_flag : 1;
|
||||
uint32_t friction_flag : 1;
|
||||
uint32_t Power_flag : 1;
|
||||
uint32_t robot_level_flag : 1;
|
||||
} Referee_Interactive_Flag_t;
|
||||
|
||||
// 此结构体包含UI绘制与机器人车间通信的需要的其他非裁判系统数据
|
||||
@@ -61,6 +62,7 @@ typedef struct
|
||||
{
|
||||
Referee_Interactive_Flag_t Referee_Interactive_Flag;
|
||||
// 为UI绘制以及交互数据所用
|
||||
uint8_t robot_level; // 机器人等级
|
||||
chassis_mode_e chassis_mode; // 底盘模式
|
||||
gimbal_mode_e gimbal_mode; // 云台模式
|
||||
shoot_mode_e shoot_mode; // 发射模式设置
|
||||
@@ -69,6 +71,7 @@ typedef struct
|
||||
Chassis_Power_Data_s Chassis_Power_Data; // 功率控制
|
||||
|
||||
// 上一次的模式,用于flag判断
|
||||
uint8_t robot_last_level;
|
||||
chassis_mode_e chassis_last_mode;
|
||||
gimbal_mode_e gimbal_last_mode;
|
||||
shoot_mode_e shoot_last_mode;
|
||||
@@ -97,4 +100,4 @@ referee_info_t *RefereeInit(UART_HandleTypeDef *referee_usart_handle);
|
||||
*/
|
||||
void RefereeSend(uint8_t *send, uint16_t tx_len);
|
||||
|
||||
#endif // !REFEREE_H
|
||||
#endif // !REFEREE_H
|
||||
Reference in New Issue
Block a user