mirror of
https://gitee.com/dlmu-cone/bf_original_balance_chassis
synced 2026-07-24 03:27:45 +08:00
重新组织了裁判系统相关模块的结构
This commit is contained in:
@@ -2,30 +2,25 @@
|
||||
#define RM_REFEREE_H
|
||||
|
||||
#include "usart.h"
|
||||
#include "referee_def.h"
|
||||
#include "referee_protocol.h"
|
||||
#include "robot_def.h"
|
||||
#include "bsp_usart.h"
|
||||
extern uint8_t UI_Seq;
|
||||
#include "FreeRTOS.h"
|
||||
|
||||
extern uint8_t UI_Seq;
|
||||
|
||||
#pragma pack(1)
|
||||
#define RE_TX_BUFFER_SIZE 512
|
||||
//发送缓冲区结构体定义
|
||||
typedef struct
|
||||
{
|
||||
uint8_t buffer[RE_TX_BUFFER_SIZE];
|
||||
uint16_t pos;
|
||||
} referee_tx_buffer_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t Robot_Color; //机器人颜色
|
||||
uint16_t Robot_ID; //本机器人ID
|
||||
uint16_t Cilent_ID; //本机器人对应的客户端ID
|
||||
uint16_t Receiver_Robot_ID; //机器人车间通信时接收者的ID,必须和本机器人同颜色
|
||||
uint8_t Robot_Color; // 机器人颜色
|
||||
uint16_t Robot_ID; // 本机器人ID
|
||||
uint16_t Cilent_ID; // 本机器人对应的客户端ID
|
||||
uint16_t Receiver_Robot_ID; // 机器人车间通信时接收者的ID,必须和本机器人同颜色
|
||||
} referee_id_t;
|
||||
|
||||
// 此结构体包含裁判系统接收数据以及UI绘制与机器人车间通信的相关信息
|
||||
typedef struct
|
||||
{
|
||||
{
|
||||
referee_id_t referee_id;
|
||||
|
||||
xFrameHeader FrameHeader; // 接收到的帧头信息
|
||||
@@ -43,33 +38,79 @@ typedef struct
|
||||
ext_robot_hurt_t RobotHurt; // 0x0206
|
||||
ext_shoot_data_t ShootData; // 0x0207
|
||||
|
||||
//自定义交互数据的接收
|
||||
// 自定义交互数据的接收
|
||||
Communicate_ReceiveData_t ReceiveData;
|
||||
|
||||
} referee_info_t;
|
||||
|
||||
// 模式是否切换标志位,0为未切换,1为切换,static定义默认为0
|
||||
typedef struct
|
||||
{
|
||||
uint32_t chassis_flag : 1;
|
||||
uint32_t gimbal_flag : 1;
|
||||
uint32_t shoot_flag : 1;
|
||||
uint32_t lid_flag : 1;
|
||||
uint32_t friction_flag : 1;
|
||||
uint32_t Power_flag : 1;
|
||||
} Referee_Interactive_Flag_t;
|
||||
|
||||
// 此结构体包含UI绘制与机器人车间通信的需要的其他非裁判系统数据
|
||||
typedef struct
|
||||
{
|
||||
Referee_Interactive_Flag_t Referee_Interactive_Flag;
|
||||
// 为UI绘制以及交互数据所用
|
||||
Robot_Status_e Robot_Status; // 机器人状态
|
||||
App_Status_e App_Status; // 应用状态
|
||||
chassis_mode_e chassis_mode; // 底盘模式
|
||||
gimbal_mode_e gimbal_mode; // 云台模式
|
||||
shoot_mode_e shoot_mode; // 发射模式设置
|
||||
friction_mode_e friction_mode; // 摩擦轮关闭
|
||||
lid_mode_e lid_mode; // 弹舱盖打开
|
||||
loader_mode_e loader_mode; // 单发...连发
|
||||
Chassis_Power_Data_s Chassis_Power_Data; // 功率控制
|
||||
|
||||
//上一次的模式,用于flag判断
|
||||
chassis_mode_e chassis_last_mode; // 底盘模式
|
||||
gimbal_mode_e gimbal_last_mode; // 云台模式
|
||||
shoot_mode_e shoot_last_mode; // 发射模式设置
|
||||
friction_mode_e friction_last_mode; // 摩擦轮关闭
|
||||
lid_mode_e lid_last_mode; // 弹舱盖打开
|
||||
|
||||
} Referee_Interactive_info_t;
|
||||
|
||||
#pragma pack()
|
||||
|
||||
/**
|
||||
* @brief 初始化裁判系统,返回接收数据指针
|
||||
*
|
||||
* @param referee_usart_handle
|
||||
* @return referee_info_t*
|
||||
* @brief 裁判系统通信初始化, 该函数会初始化裁判系统串口,开启中断,同时将UI绘制的数据指针传入
|
||||
*
|
||||
* @param referee_usart_handle 串口handle,C板一般用串口6
|
||||
* @param UI_data UI绘制数据指针,即保存着UI绘制的各种状态数据
|
||||
* @return referee_info_t* 返回裁判系统反馈的数据,包括热量/血量/状态等
|
||||
*/
|
||||
referee_info_t *RefereeInit(UART_HandleTypeDef *referee_usart_handle);
|
||||
|
||||
referee_info_t *RefereeInit(UART_HandleTypeDef *referee_usart_handle, Referee_Interactive_info_t *UI_data);
|
||||
|
||||
/**
|
||||
* @brief 载入缓存区函数
|
||||
* @param send 待载入的数据
|
||||
* @brief 由UI绘制的任务初始化调用,用于获取裁判系统反馈的数据指针和UI绘制的数据指针,以便UI绘制任务使用
|
||||
*
|
||||
* @param recv_info_pp 指向裁判系统反馈的数据指针
|
||||
* @param UI_data_pp
|
||||
*/
|
||||
void RefereeLoadToBuffer(uint8_t *send, uint16_t tx_len);
|
||||
void RefereeGetUIData(referee_info_t **recv_info_pp, Referee_Interactive_info_t **UI_data_pp);
|
||||
|
||||
/**
|
||||
* @brief 发送机器人间的交互数据
|
||||
* @param referee_id_t *_id sender为本机器人,receiver为接收方机器人,发送前设置Receiver_Robot_ID再调用该函数
|
||||
* robot_interactive_data_t *data 数据段
|
||||
* @retval none
|
||||
* @attention
|
||||
*/
|
||||
void CommBetweenRobotSend(referee_id_t *_id, robot_interactive_data_t *_data);
|
||||
|
||||
/**
|
||||
* @brief 发送函数
|
||||
* @todo
|
||||
* @param
|
||||
* @param
|
||||
*/
|
||||
void RefereeSend(void);
|
||||
void RefereeSend(uint8_t *send, uint16_t tx_len);
|
||||
|
||||
#endif // !REFEREE_H
|
||||
|
||||
Reference in New Issue
Block a user