自瞄上下位机通信协议
本协议适用于基于rm_serial_driver开发的上位机
接收数据包(ReceivePacket),下位机发给上位机
| struct ReceivePacket
{
uint8_t header = 0x5A;
uint8_t detect_color : 1; // 目标颜色(0-red 1-blue)
uint8_t task_mode : 2; // 任务模式 0-根据比赛时长自动判断 1-指定自瞄 2-指定打符
bool reset_tracker : 1; // 复位
uint8_t is_play : 1; // 开启/关闭消息录制
bool change_target : 1; // 切换目标
uint8_t reserved : 2; // 保留位
float roll; // 当前云台姿态
float pitch;
float yaw;
float aim_x; // 当前云台瞄准位置(用于发布marker)
float aim_y;
float aim_z;
uint16_t game_time; // (s) game time [0, 450]
uint32_t timestamp; // (ms) board time
uint16_t checksum = 0;
} __attribute__((packed));
|
发送数据包(SendPacket),上位机发给下位机
| struct SendPacket
{
uint8_t header = 0xA5;
uint8_t state : 2; // 0-untracking 1-tracking-aim 2-tracking-buff
uint8_t id : 3; // aim: 0-outpost 6-guard 7-base
uint8_t armors_num : 3; // 2-balance 3-outpost 4-normal
float x; // aim: robot-center || buff: rune-center
float y; // aim: robot-center || buff: rune-center
float z; // aim: robot-center || buff: rune-center
float yaw; // aim: robot-yaw || buff: rune-theta
// spd = a*sin(w*t)+b || spd > 0 ==> clockwise
float vx; // aim: robot-vx || buff: rune spin speed param - a
float vy; // aim: robot-vy || buff: rune spin speed param - b
float vz; // aim: robot-vz || buff: rune spin speed param - w
float v_yaw;
float r1;
float r2;
float dz;
uint32_t cap_timestamp; // (ms) frame capture time
uint16_t t_offset; // (ms) speed t offset
uint16_t checksum = 0;
} __attribute__((packed));
|