referee.h文件中的枚举整合至_def.h
This commit is contained in:
parent
85a97abb9d
commit
9b16407b57
|
@ -33,7 +33,7 @@
|
|||
/* Private includes ----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Includes */
|
||||
#include "robot.h"
|
||||
//////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////syhtodo
|
||||
#include "referee_UI.h"
|
||||
#include "referee.h"
|
||||
//////////////////////////////////////////////////
|
||||
|
@ -118,11 +118,11 @@ int main(void)
|
|||
RobotInit();
|
||||
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
//////////////////////////////////////////////////syhtodo
|
||||
Graph_Data graph[5];
|
||||
Graph_Data num[2];
|
||||
String_Data sdata[1];
|
||||
memset(sdata[0].show_Data, 0, 30); //使用memset方法
|
||||
memset(sdata[0].show_Data, 0, 30); //使用memset方法 syhtodo 数据存在初始化未默认为0的情况
|
||||
UI_Delete(UI_Data_Del_ALL,0);
|
||||
|
||||
Line_Draw(&graph[0],"s0",UI_Graph_ADD,0,UI_Color_White,3,710,540,1210,540);
|
||||
|
@ -136,7 +136,7 @@ int main(void)
|
|||
UI_ReFresh(7,graph[0],graph[1],graph[2],graph[3],graph[4],num[0],num[1]);
|
||||
|
||||
Char_Draw(&sdata[0],"s7",UI_Graph_ADD,0,UI_Color_Green,20,2,620,710);
|
||||
Char_Write(&sdata[0],"number:%d",1234);
|
||||
Char_Write(&sdata[0],"number:%d",12345);
|
||||
Char_ReFresh(sdata[0]);
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
|
|
|
@ -238,9 +238,9 @@ void ChassisTask()
|
|||
|
||||
// 获取裁判系统数据
|
||||
// 我方颜色id小于7是红色,大于7是蓝色,注意这里发送的是对方的颜色, 0:blue , 1:red
|
||||
chassis_feedback_data.enemy_color = referee_data->GameRobotStat.robot_id > 7 ? 1 : 0;
|
||||
chassis_feedback_data.enemy_color = referee_data->GameRobotState.robot_id > 7 ? 1 : 0;
|
||||
// 当前只做了17mm热量的数据获取,后续根据robot_def中的宏切换双枪管和英雄42mm的情况
|
||||
chassis_feedback_data.bullet_speed = referee_data->GameRobotStat.shooter_id1_17mm_speed_limit;
|
||||
chassis_feedback_data.bullet_speed = referee_data->GameRobotState.shooter_id1_17mm_speed_limit;
|
||||
chassis_feedback_data.rest_heat = referee_data->PowerHeatData.shooter_heat0;
|
||||
|
||||
// 推送反馈消息
|
||||
|
|
|
@ -11,9 +11,6 @@ static referee_info_t referee_info;
|
|||
static void JudgeReadData(uint8_t *ReadFromUsart);
|
||||
static void RefereeRxCallback();
|
||||
|
||||
// static uint8_t Judge_Self_ID; // 当前机器人的ID
|
||||
// static uint16_t Judge_SelfClient_ID; // 发送者机器人对应的客户端ID
|
||||
|
||||
/* 裁判系统通信初始化 */
|
||||
referee_info_t *RefereeInit(UART_HandleTypeDef *referee_usart_handle)
|
||||
{
|
||||
|
@ -77,50 +74,50 @@ static void JudgeReadData(uint8_t *ReadFromUsart)
|
|||
switch (referee_info.CmdID)
|
||||
{
|
||||
case ID_game_state: // 0x0001
|
||||
memcpy(&referee_info.GameState, (ReadFromUsart + DATA), LEN_game_state);
|
||||
memcpy(&referee_info.GameState, (ReadFromUsart + DATA_Offset), LEN_game_state);
|
||||
break;
|
||||
|
||||
case ID_game_result: // 0x0002
|
||||
memcpy(&referee_info.GameResult, (ReadFromUsart + DATA), LEN_game_result);
|
||||
memcpy(&referee_info.GameResult, (ReadFromUsart + DATA_Offset), LEN_game_result);
|
||||
break;
|
||||
|
||||
case ID_game_robot_survivors: // 0x0003
|
||||
memcpy(&referee_info.GameRobotHP, (ReadFromUsart + DATA), LEN_game_robot_HP);
|
||||
memcpy(&referee_info.GameRobotHP, (ReadFromUsart + DATA_Offset), LEN_game_robot_HP);
|
||||
break;
|
||||
|
||||
case ID_event_data: // 0x0101
|
||||
memcpy(&referee_info.EventData, (ReadFromUsart + DATA), LEN_event_data);
|
||||
memcpy(&referee_info.EventData, (ReadFromUsart + DATA_Offset), LEN_event_data);
|
||||
break;
|
||||
|
||||
case ID_supply_projectile_action: // 0x0102
|
||||
memcpy(&referee_info.SupplyProjectileAction, (ReadFromUsart + DATA), LEN_supply_projectile_action);
|
||||
memcpy(&referee_info.SupplyProjectileAction, (ReadFromUsart + DATA_Offset), LEN_supply_projectile_action);
|
||||
break;
|
||||
|
||||
case ID_game_robot_state: // 0x0201
|
||||
memcpy(&referee_info.GameRobotStat, (ReadFromUsart + DATA), LEN_game_robot_state);
|
||||
memcpy(&referee_info.GameRobotState, (ReadFromUsart + DATA_Offset), LEN_game_robot_state);
|
||||
break;
|
||||
case ID_power_heat_data: // 0x0202
|
||||
memcpy(&referee_info.PowerHeatData, (ReadFromUsart + DATA), LEN_power_heat_data);
|
||||
memcpy(&referee_info.PowerHeatData, (ReadFromUsart + DATA_Offset), LEN_power_heat_data);
|
||||
break;
|
||||
|
||||
case ID_game_robot_pos: // 0x0203
|
||||
memcpy(&referee_info.GameRobotPos, (ReadFromUsart + DATA), LEN_game_robot_pos);
|
||||
memcpy(&referee_info.GameRobotPos, (ReadFromUsart + DATA_Offset), LEN_game_robot_pos);
|
||||
break;
|
||||
|
||||
case ID_buff_musk: // 0x0204
|
||||
memcpy(&referee_info.BuffMusk, (ReadFromUsart + DATA), LEN_buff_musk);
|
||||
memcpy(&referee_info.BuffMusk, (ReadFromUsart + DATA_Offset), LEN_buff_musk);
|
||||
break;
|
||||
|
||||
case ID_aerial_robot_energy: // 0x0205
|
||||
memcpy(&referee_info.AerialRobotEnergy, (ReadFromUsart + DATA), LEN_aerial_robot_energy);
|
||||
memcpy(&referee_info.AerialRobotEnergy, (ReadFromUsart + DATA_Offset), LEN_aerial_robot_energy);
|
||||
break;
|
||||
|
||||
case ID_robot_hurt: // 0x0206
|
||||
memcpy(&referee_info.RobotHurt, (ReadFromUsart + DATA), LEN_robot_hurt);
|
||||
memcpy(&referee_info.RobotHurt, (ReadFromUsart + DATA_Offset), LEN_robot_hurt);
|
||||
break;
|
||||
|
||||
case ID_shoot_data: // 0x0207
|
||||
memcpy(&referee_info.ShootData, (ReadFromUsart + DATA), LEN_shoot_data);
|
||||
memcpy(&referee_info.ShootData, (ReadFromUsart + DATA_Offset), LEN_shoot_data);
|
||||
// JUDGE_ShootNumCount();//发弹量统计
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -23,135 +23,8 @@
|
|||
#define JUDGE_DATA_ERROR 0
|
||||
#define JUDGE_DATA_CORRECT 1
|
||||
|
||||
#define LEN_HEADER 5 // 帧头长
|
||||
#define LEN_CMDID 2 // 命令码长度
|
||||
#define LEN_TAIL 2 // 帧尾CRC16
|
||||
|
||||
// 起始字节,协议固定为0xA5
|
||||
#define JUDGE_FRAME_HEADER (0xA5)
|
||||
|
||||
#pragma pack(1)
|
||||
|
||||
/* ID: 0x0001 Byte: 3 比赛状态数据 */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t game_type : 4;
|
||||
uint8_t game_progress : 4;
|
||||
uint16_t stage_remain_time;
|
||||
} ext_game_state_t;
|
||||
|
||||
/* ID: 0x0002 Byte: 1 比赛结果数据 */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t winner;
|
||||
} ext_game_result_t;
|
||||
|
||||
/* ID: 0x0003 Byte: 32 比赛机器人血量数据 */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t red_1_robot_HP;
|
||||
uint16_t red_2_robot_HP;
|
||||
uint16_t red_3_robot_HP;
|
||||
uint16_t red_4_robot_HP;
|
||||
uint16_t red_5_robot_HP;
|
||||
uint16_t red_7_robot_HP;
|
||||
uint16_t red_outpost_HP;
|
||||
uint16_t red_base_HP;
|
||||
uint16_t blue_1_robot_HP;
|
||||
uint16_t blue_2_robot_HP;
|
||||
uint16_t blue_3_robot_HP;
|
||||
uint16_t blue_4_robot_HP;
|
||||
uint16_t blue_5_robot_HP;
|
||||
uint16_t blue_7_robot_HP;
|
||||
uint16_t blue_outpost_HP;
|
||||
uint16_t blue_base_HP;
|
||||
} ext_game_robot_HP_t;
|
||||
|
||||
/* ID: 0x0101 Byte: 4 场地事件数据 */
|
||||
typedef struct
|
||||
{
|
||||
uint32_t event_type;
|
||||
} ext_event_data_t;
|
||||
|
||||
/* ID: 0x0102 Byte: 3 场地补给站动作标识数据 */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t supply_projectile_id;
|
||||
uint8_t supply_robot_id;
|
||||
uint8_t supply_projectile_step;
|
||||
uint8_t supply_projectile_num;
|
||||
} ext_supply_projectile_action_t;
|
||||
|
||||
/* ID: 0X0201 Byte: 27 机器人状态数据 */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t robot_id;
|
||||
uint8_t robot_level;
|
||||
uint16_t remain_HP;
|
||||
uint16_t max_HP;
|
||||
uint16_t shooter_id1_17mm_cooling_rate;
|
||||
uint16_t shooter_id1_17mm_cooling_limit;
|
||||
uint16_t shooter_id1_17mm_speed_limit;
|
||||
uint16_t shooter_id2_17mm_cooling_rate;
|
||||
uint16_t shooter_id2_17mm_cooling_limit;
|
||||
uint16_t shooter_id2_17mm_speed_limit;
|
||||
uint16_t shooter_id1_42mm_cooling_rate;
|
||||
uint16_t shooter_id1_42mm_cooling_limit;
|
||||
uint16_t shooter_id1_42mm_speed_limit;
|
||||
uint16_t chassis_power_limit;
|
||||
uint8_t mains_power_gimbal_output : 1;
|
||||
uint8_t mains_power_chassis_output : 1;
|
||||
uint8_t mains_power_shooter_output : 1;
|
||||
} ext_game_robot_state_t;
|
||||
|
||||
/* ID: 0X0202 Byte: 14 实时功率热量数据 */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t chassis_volt;
|
||||
uint16_t chassis_current;
|
||||
float chassis_power; // 瞬时功率
|
||||
uint16_t chassis_power_buffer; // 60焦耳缓冲能量
|
||||
uint16_t shooter_heat0; // 17mm
|
||||
uint16_t shooter_heat1;
|
||||
} ext_power_heat_data_t;
|
||||
|
||||
/* ID: 0x0203 Byte: 16 机器人位置数据 */
|
||||
typedef struct
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
float yaw;
|
||||
} ext_game_robot_pos_t;
|
||||
|
||||
/* ID: 0x0204 Byte: 1 机器人增益数据 */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t power_rune_buff;
|
||||
} ext_buff_musk_t;
|
||||
|
||||
/* ID: 0x0205 Byte: 1 空中机器人能量状态数据 */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t attack_time;
|
||||
} aerial_robot_energy_t;
|
||||
|
||||
/* ID: 0x0206 Byte: 1 伤害状态数据 */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t armor_id : 4;
|
||||
uint8_t hurt_type : 4;
|
||||
} ext_robot_hurt_t;
|
||||
|
||||
/* ID: 0x0207 Byte: 7 实时射击数据 */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t bullet_type;
|
||||
uint8_t shooter_id;
|
||||
uint8_t bullet_freq;
|
||||
float bullet_speed;
|
||||
} ext_shoot_data_t;
|
||||
|
||||
// 裁判系统接收数据整合进一个结构体
|
||||
typedef struct
|
||||
{
|
||||
|
@ -162,7 +35,7 @@ typedef struct
|
|||
ext_game_robot_HP_t GameRobotHP; // 0x0003
|
||||
ext_event_data_t EventData; // 0x0101
|
||||
ext_supply_projectile_action_t SupplyProjectileAction; // 0x0102
|
||||
ext_game_robot_state_t GameRobotStat; // 0x0201
|
||||
ext_game_robot_state_t GameRobotState; // 0x0201
|
||||
ext_power_heat_data_t PowerHeatData; // 0x0202
|
||||
ext_game_robot_pos_t GameRobotPos; // 0x0203
|
||||
ext_buff_musk_t BuffMusk; // 0x0204
|
||||
|
|
|
@ -15,14 +15,30 @@
|
|||
|
||||
#pragma pack(1)
|
||||
|
||||
/****************************通信协议格式****************************/
|
||||
/****************************通信协议格式****************************/
|
||||
|
||||
/* 通信协议格式偏移,枚举类型,代替#define声明 */
|
||||
typedef enum
|
||||
{
|
||||
FRAME_HEADER = 0,
|
||||
CMD_ID = 5,
|
||||
DATA = 7,
|
||||
FRAME_HEADER_Offset = 0,
|
||||
CMD_ID_Offset = 5,
|
||||
DATA_Offset = 7,
|
||||
} JudgeFrameOffset;
|
||||
|
||||
/* 通信协议长度 */
|
||||
typedef enum
|
||||
{
|
||||
LEN_HEADER = 5, // 帧头长
|
||||
LEN_CMDID = 2, // 命令码长度
|
||||
LEN_TAIL = 2, // 帧尾CRC16
|
||||
} JudgeFrameLength;
|
||||
|
||||
/****************************帧头****************************/
|
||||
/****************************帧头****************************/
|
||||
|
||||
#define JUDGE_FRAME_HEADER (0xA5) // 起始字节,协议固定为0xA5
|
||||
|
||||
/* 帧头偏移 */
|
||||
typedef enum
|
||||
{
|
||||
|
@ -41,6 +57,10 @@ typedef struct
|
|||
uint8_t CRC8;
|
||||
} xFrameHeader;
|
||||
|
||||
|
||||
/****************************cmd_id命令码说明****************************/
|
||||
/****************************cmd_id命令码说明****************************/
|
||||
|
||||
/* 命令码ID,用来判断接收的是什么数据 */
|
||||
typedef enum
|
||||
{
|
||||
|
@ -57,7 +77,7 @@ typedef enum
|
|||
ID_aerial_robot_energy = 0x0205, // 空中机器人能量状态数据
|
||||
ID_robot_hurt = 0x0206, // 伤害状态数据
|
||||
ID_shoot_data = 0x0207, // 实时射击数据
|
||||
|
||||
ID_student_interactive = 0x0301, // 机器人间交互数据
|
||||
} CmdID;
|
||||
|
||||
/* 命令码数据段长,根据官方协议来定义长度 */
|
||||
|
@ -77,6 +97,130 @@ typedef enum
|
|||
LEN_shoot_data = 7, // 0x0207
|
||||
} JudgeDataLength;
|
||||
|
||||
/****************************接收数据的详细说明****************************/
|
||||
/****************************接收数据的详细说明****************************/
|
||||
|
||||
/* ID: 0x0001 Byte: 3 比赛状态数据 */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t game_type : 4;
|
||||
uint8_t game_progress : 4;
|
||||
uint16_t stage_remain_time;
|
||||
} ext_game_state_t;
|
||||
|
||||
/* ID: 0x0002 Byte: 1 比赛结果数据 */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t winner;
|
||||
} ext_game_result_t;
|
||||
|
||||
/* ID: 0x0003 Byte: 32 比赛机器人血量数据 */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t red_1_robot_HP;
|
||||
uint16_t red_2_robot_HP;
|
||||
uint16_t red_3_robot_HP;
|
||||
uint16_t red_4_robot_HP;
|
||||
uint16_t red_5_robot_HP;
|
||||
uint16_t red_7_robot_HP;
|
||||
uint16_t red_outpost_HP;
|
||||
uint16_t red_base_HP;
|
||||
uint16_t blue_1_robot_HP;
|
||||
uint16_t blue_2_robot_HP;
|
||||
uint16_t blue_3_robot_HP;
|
||||
uint16_t blue_4_robot_HP;
|
||||
uint16_t blue_5_robot_HP;
|
||||
uint16_t blue_7_robot_HP;
|
||||
uint16_t blue_outpost_HP;
|
||||
uint16_t blue_base_HP;
|
||||
} ext_game_robot_HP_t;
|
||||
|
||||
/* ID: 0x0101 Byte: 4 场地事件数据 */
|
||||
typedef struct
|
||||
{
|
||||
uint32_t event_type;
|
||||
} ext_event_data_t;
|
||||
|
||||
/* ID: 0x0102 Byte: 3 场地补给站动作标识数据 */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t supply_projectile_id;
|
||||
uint8_t supply_robot_id;
|
||||
uint8_t supply_projectile_step;
|
||||
uint8_t supply_projectile_num;
|
||||
} ext_supply_projectile_action_t;
|
||||
|
||||
/* ID: 0X0201 Byte: 27 机器人状态数据 */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t robot_id;
|
||||
uint8_t robot_level;
|
||||
uint16_t remain_HP;
|
||||
uint16_t max_HP;
|
||||
uint16_t shooter_id1_17mm_cooling_rate;
|
||||
uint16_t shooter_id1_17mm_cooling_limit;
|
||||
uint16_t shooter_id1_17mm_speed_limit;
|
||||
uint16_t shooter_id2_17mm_cooling_rate;
|
||||
uint16_t shooter_id2_17mm_cooling_limit;
|
||||
uint16_t shooter_id2_17mm_speed_limit;
|
||||
uint16_t shooter_id1_42mm_cooling_rate;
|
||||
uint16_t shooter_id1_42mm_cooling_limit;
|
||||
uint16_t shooter_id1_42mm_speed_limit;
|
||||
uint16_t chassis_power_limit;
|
||||
uint8_t mains_power_gimbal_output : 1;
|
||||
uint8_t mains_power_chassis_output : 1;
|
||||
uint8_t mains_power_shooter_output : 1;
|
||||
} ext_game_robot_state_t;
|
||||
|
||||
/* ID: 0X0202 Byte: 14 实时功率热量数据 */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t chassis_volt;
|
||||
uint16_t chassis_current;
|
||||
float chassis_power; // 瞬时功率
|
||||
uint16_t chassis_power_buffer; // 60焦耳缓冲能量
|
||||
uint16_t shooter_heat0; // 17mm
|
||||
uint16_t shooter_heat1;
|
||||
} ext_power_heat_data_t;
|
||||
|
||||
/* ID: 0x0203 Byte: 16 机器人位置数据 */
|
||||
typedef struct
|
||||
{
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
float yaw;
|
||||
} ext_game_robot_pos_t;
|
||||
|
||||
/* ID: 0x0204 Byte: 1 机器人增益数据 */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t power_rune_buff;
|
||||
} ext_buff_musk_t;
|
||||
|
||||
/* ID: 0x0205 Byte: 1 空中机器人能量状态数据 */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t attack_time;
|
||||
} aerial_robot_energy_t;
|
||||
|
||||
/* ID: 0x0206 Byte: 1 伤害状态数据 */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t armor_id : 4;
|
||||
uint8_t hurt_type : 4;
|
||||
} ext_robot_hurt_t;
|
||||
|
||||
/* ID: 0x0207 Byte: 7 实时射击数据 */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t bullet_type;
|
||||
uint8_t shooter_id;
|
||||
uint8_t bullet_freq;
|
||||
float bullet_speed;
|
||||
} ext_shoot_data_t;
|
||||
|
||||
|
||||
#pragma pack()
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue