d56254d190
- Remove RC_ctrl_t and RemoteControlInit from robot_cmd.c - Delete GIMBAL_ZERO_FORCE, gimbal_mode_e, Robot_Status_e from robot_def.h - Remove EmergencyHandler and robot_state from robot_cmd.c - Remove emergency commands from master_machine.h - Remove remote_control and can_comm from CMakeLists.txt
76 lines
2.0 KiB
C
76 lines
2.0 KiB
C
#ifndef MASTER_MACHINE_H
|
|
#define MASTER_MACHINE_H
|
|
|
|
#include "bsp_usart.h"
|
|
#include "bsp_dwt.h"
|
|
#include "bsp_log.h"
|
|
#include "usart.h"
|
|
#include "daemon.h"
|
|
#include <string.h>
|
|
|
|
/*
|
|
* 上位机串口协议 — 三种帧类型, 通过帧头区分
|
|
*
|
|
* ---- 自动/视觉追踪数据帧 0xA5 (10 字节) ----
|
|
* [SOF:0xA5][error_x:4][error_y:4][checksum:1]
|
|
* error_x/y: float, 归一化误差, 视觉PID外环反馈值
|
|
*
|
|
* ---- 手动控制数据帧 0xA6 (11 字节) ----
|
|
* [SOF:0xA6][zero_force:1][yaw_ref:4][pitch_ref:4][checksum:1]
|
|
* zero_force: 0=正常角度控制, 1=零力/保持当前位置
|
|
* yaw_ref/pitch_ref: float, 角度参考值 (degrees)
|
|
*
|
|
* ---- 命令帧 0xA7 (3 字节) ----
|
|
* [SOF:0xA7][cmd:1][checksum:1]
|
|
* cmd: 0x01=切换到自动模式, 0x02=切换到手动模式, 0x03=激光开, 0x04=激光关
|
|
*
|
|
* checksum: 帧头到数据末尾前一字节累加和取低8位
|
|
*/
|
|
|
|
#define VISION_SOF_AUTO 0xA5
|
|
#define VISION_SOF_MANUAL 0xA6
|
|
#define VISION_SOF_CMD 0xA7
|
|
|
|
#define VISION_AUTO_LEN 10
|
|
#define VISION_MANUAL_LEN 11
|
|
#define VISION_CMD_LEN 3
|
|
|
|
/* 命令码 */
|
|
#define VISION_CMD_SWITCH_AUTO 0x01
|
|
#define VISION_CMD_SWITCH_MANUAL 0x02
|
|
#define VISION_CMD_LASER_ON 0x03
|
|
#define VISION_CMD_LASER_OFF 0x04
|
|
|
|
/* 工作模式 */
|
|
typedef enum
|
|
{
|
|
VISION_MODE_AUTO = 0, // 自动/视觉追踪
|
|
VISION_MODE_MANUAL = 1, // 手动
|
|
} Vision_Mode_e;
|
|
|
|
typedef struct
|
|
{
|
|
/* 自动模式数据 */
|
|
float error_x;
|
|
float error_y;
|
|
uint8_t auto_updated; // 收到新的自动数据帧标志
|
|
|
|
/* 手动模式数据 */
|
|
uint8_t zero_force;
|
|
float yaw_ref;
|
|
float pitch_ref;
|
|
uint8_t manual_updated; // 收到新的手动数据帧标志
|
|
|
|
/* 命令 */
|
|
uint8_t cmd; // 最新命令码
|
|
uint8_t cmd_pending; // 有待处理命令标志
|
|
|
|
float frequency; // 接收频率 (Hz)
|
|
} VisionData_t;
|
|
|
|
extern VisionData_t vision_data;
|
|
|
|
void Vision_Uart_Init(UART_HandleTypeDef *_handle);
|
|
|
|
#endif // MASTER_MACHINE_H
|