93 lines
2.0 KiB
C
93 lines
2.0 KiB
C
/*
|
||
视觉与电控通信协议
|
||
*/
|
||
|
||
#pragma once
|
||
|
||
#include <stdint.h>
|
||
|
||
#ifdef __cplusplus
|
||
extern "C"
|
||
{
|
||
#endif
|
||
|
||
#define AI_NOTICE_AUTOAIM (1 << 0)
|
||
#define AI_NOTICE_HITBUFF (1 << 1)
|
||
#define AI_NOTICE_AUTOMATIC (1 << 2)
|
||
#define AI_NOTICE_FIRE (1 << 3)
|
||
|
||
#define AI_ID_MCU (0xC4)
|
||
#define AI_ID_REF (0xA8)
|
||
|
||
#define AI_TEAM_RED (0x01)
|
||
#define AI_TEAM_BLUE (0x02)
|
||
|
||
typedef uint8_t Protocol_ID_t;
|
||
|
||
/* 电控 -> 视觉 MCU数据结构体*/
|
||
typedef struct __attribute__((packed))
|
||
{
|
||
struct __attribute__((packed))
|
||
{
|
||
float q0;
|
||
float q1;
|
||
float q2;
|
||
float q3;
|
||
} quat; /* 四元数 */
|
||
struct __attribute__((packed))
|
||
{
|
||
float yaw;
|
||
float pit;
|
||
float rol;
|
||
} gimbal; /* 欧拉角 */
|
||
uint8_t notice; /* 控制命令 */
|
||
} Protocol_UpDataMCU_t;
|
||
|
||
/* 电控 -> 视觉 裁判系统数据结构体*/
|
||
typedef struct __attribute__((packed))
|
||
{
|
||
uint16_t remain_hp; /* 剩余血量 */
|
||
uint16_t stage_remain_time; /* 比赛剩余时间 */
|
||
} Protocol_UpDataReferee_t;
|
||
|
||
/* 视觉 -> 电控 数据结构体*/
|
||
typedef struct __attribute__((packed))
|
||
{
|
||
struct __attribute__((packed))
|
||
{
|
||
float yaw; /* 偏航角(Yaw angle) */
|
||
float pit; /* 俯仰角(Pitch angle) */
|
||
float rol; /* 翻滚角(Roll angle) */
|
||
} gimbal; /* 欧拉角 */
|
||
|
||
struct __attribute__((packed))
|
||
{
|
||
float vx; /* x轴移动速度 */
|
||
float vy; /* y轴移动速度 */
|
||
float wz; /* z轴转动速度 */
|
||
} chassis_move_vec; /* 底盘移动向量 */
|
||
uint8_t notice; /* 控制命令 */
|
||
} Protocol_DownData_t;
|
||
|
||
typedef struct __attribute__((packed))
|
||
{
|
||
Protocol_UpDataMCU_t data;
|
||
uint16_t crc16;
|
||
} Protocol_UpPackageMCU_t;
|
||
|
||
typedef struct __attribute__((packed))
|
||
{
|
||
Protocol_UpDataReferee_t data;
|
||
uint16_t crc16;
|
||
} Protocol_UpPackageReferee_t;
|
||
|
||
typedef struct __attribute__((packed))
|
||
{
|
||
Protocol_DownData_t data;
|
||
uint16_t crc16;
|
||
} Protocol_DownPackage_t;
|
||
|
||
#ifdef __cplusplus
|
||
}
|
||
#endif
|