2022-10-20 17:13:02 +08:00
|
|
|
#ifndef MASTER_PROCESS_H
|
|
|
|
#define MASTER_PROCESS_H
|
|
|
|
|
|
|
|
#include "bsp_usart.h"
|
2022-11-03 20:38:55 +08:00
|
|
|
#include "seasky_protocol.h"
|
2022-10-20 17:13:02 +08:00
|
|
|
|
2023-03-22 16:37:12 +08:00
|
|
|
#define VISION_RECV_SIZE 18u // 当前为固定值,36字节
|
2022-11-03 20:38:55 +08:00
|
|
|
#define VISION_SEND_SIZE 36u
|
|
|
|
|
2023-01-01 17:32:22 +08:00
|
|
|
#pragma pack(1)
|
2022-11-29 23:11:37 +08:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
NO_FIRE = 0,
|
|
|
|
AUTO_FIRE = 1,
|
|
|
|
AUTO_AIM = 2
|
|
|
|
} Fire_Mode_e;
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
NO_TARGET = 0,
|
|
|
|
TARGET_CONVERGING = 1,
|
|
|
|
READY_TO_FIRE = 2
|
|
|
|
} Target_State_e;
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
NO_TARGET_NUM = 0,
|
|
|
|
HERO1 = 1,
|
|
|
|
ENGINEER2 = 2,
|
|
|
|
INFANTRY3 = 3,
|
|
|
|
INFANTRY4 = 4,
|
|
|
|
INFANTRY5 = 5,
|
|
|
|
OUTPOST = 6,
|
|
|
|
SENTRY = 7,
|
|
|
|
BASE = 8
|
|
|
|
} Target_Type_e;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
Fire_Mode_e fire_mode;
|
|
|
|
Target_State_e target_state;
|
|
|
|
Target_Type_e target_type;
|
|
|
|
|
|
|
|
float pitch;
|
|
|
|
float yaw;
|
|
|
|
} Vision_Recv_s;
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
2023-04-29 22:33:16 +08:00
|
|
|
COLOR_NONE = 0,
|
|
|
|
COLOR_BLUE = 1,
|
|
|
|
COLOR_RED = 2,
|
2022-11-29 23:11:37 +08:00
|
|
|
} Enemy_Color_e;
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
2022-12-14 17:15:54 +08:00
|
|
|
VISION_MODE_AIM = 0,
|
|
|
|
VISION_MODE_SMALL_BUFF = 1,
|
|
|
|
VISION_MODE_BIG_BUFF = 2
|
2022-11-29 23:11:37 +08:00
|
|
|
} Work_Mode_e;
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
2022-12-14 17:15:54 +08:00
|
|
|
BULLET_SPEED_NONE = 0,
|
2022-11-29 23:11:37 +08:00
|
|
|
BIG_AMU_10 = 10,
|
|
|
|
SMALL_AMU_15 = 15,
|
|
|
|
BIG_AMU_16 = 16,
|
|
|
|
SMALL_AMU_18 = 18,
|
|
|
|
SMALL_AMU_30 = 30,
|
|
|
|
} Bullet_Speed_e;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
Enemy_Color_e enemy_color;
|
|
|
|
Work_Mode_e work_mode;
|
|
|
|
Bullet_Speed_e bullet_speed;
|
|
|
|
|
|
|
|
float yaw;
|
|
|
|
float pitch;
|
2023-05-04 21:38:35 +08:00
|
|
|
float roll;
|
2022-11-29 23:11:37 +08:00
|
|
|
} Vision_Send_s;
|
2023-01-01 17:32:22 +08:00
|
|
|
#pragma pack()
|
2022-11-29 23:11:37 +08:00
|
|
|
|
2022-11-03 20:38:55 +08:00
|
|
|
/**
|
|
|
|
* @brief 调用此函数初始化和视觉的串口通信
|
2022-11-09 20:24:22 +08:00
|
|
|
*
|
2022-11-03 20:38:55 +08:00
|
|
|
* @param handle 用于和视觉通信的串口handle(C板上一般为USART1,丝印为USART2,4pin)
|
|
|
|
*/
|
2022-11-29 16:33:34 +08:00
|
|
|
Vision_Recv_s *VisionInit(UART_HandleTypeDef *_handle);
|
2022-11-03 20:38:55 +08:00
|
|
|
|
|
|
|
/**
|
2023-04-29 22:33:16 +08:00
|
|
|
* @brief 发送视觉数据
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void VisionSend();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief 设置视觉发送标志位
|
|
|
|
*
|
|
|
|
* @param enemy_color
|
|
|
|
* @param work_mode
|
|
|
|
* @param bullet_speed
|
|
|
|
*/
|
|
|
|
void VisionSetFlag(Enemy_Color_e enemy_color, Work_Mode_e work_mode, Bullet_Speed_e bullet_speed);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief 设置发送数据的姿态部分
|
2022-11-09 20:24:22 +08:00
|
|
|
*
|
2023-04-29 22:33:16 +08:00
|
|
|
* @param yaw
|
|
|
|
* @param pitch
|
2022-11-03 20:38:55 +08:00
|
|
|
*/
|
2023-05-04 21:38:35 +08:00
|
|
|
void VisionSetAltitude(float yaw, float pitch, float roll);
|
2022-10-20 17:13:02 +08:00
|
|
|
|
|
|
|
#endif // !MASTER_PROCESS_H
|