move_xrobot/Middlewares/Third_Party/Protocol/protocol.h
2025-03-04 17:20:57 +08:00

93 lines
2.0 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
视觉与电控通信协议
*/
#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 team; /* 本身队伍 */
uint16_t 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