refactor: replace vision error_x/y with measure/ref in 0xA5 frame
Change 0xA5 frame from 2-float (error_x, error_y) to 4-float (measure_x, ref_x, measure_y, ref_y) so PIDCalculate receives actual measurement and reference values internally computing error.
This commit is contained in:
@@ -29,8 +29,10 @@ static void DecodeVision()
|
||||
{
|
||||
if (calc_checksum(buf, VISION_AUTO_LEN) != buf[VISION_AUTO_LEN - 1])
|
||||
return;
|
||||
memcpy(&vision_data.error_x, buf + 1, 4);
|
||||
memcpy(&vision_data.error_y, buf + 5, 4);
|
||||
memcpy(&vision_data.measure_x, buf + 1, 4);
|
||||
memcpy(&vision_data.ref_x, buf + 5, 4);
|
||||
memcpy(&vision_data.measure_y, buf + 9, 4);
|
||||
memcpy(&vision_data.ref_y, buf + 13, 4);
|
||||
vision_data.auto_updated = 1;
|
||||
}
|
||||
else if (sof == VISION_SOF_MANUAL && len == VISION_MANUAL_LEN)
|
||||
|
||||
@@ -11,9 +11,10 @@
|
||||
/*
|
||||
* 上位机串口协议 — 四种帧类型, 通过帧头区分
|
||||
*
|
||||
* ---- 自动/视觉追踪数据帧 0xA5 (10 字节) ----
|
||||
* [SOF:0xA5][error_x:4][error_y:4][checksum:1]
|
||||
* error_x/y: float, 归一化误差, 视觉PID外环反馈值
|
||||
* ---- 自动/视觉追踪数据帧 0xA5 (18 字节) ----
|
||||
* [SOF:0xA5][measure_x:4][ref_x:4][measure_y:4][ref_y:4][checksum:1]
|
||||
* measure_x/y: float, 视觉检测目标位置 (测量值)
|
||||
* ref_x/y: float, 期望目标位置 (参考值)
|
||||
*
|
||||
* ---- 手动控制数据帧 0xA6 (10 字节) ----
|
||||
* [SOF:0xA6][yaw_velocity:4][pitch_velocity:4][checksum:1]
|
||||
@@ -38,7 +39,7 @@
|
||||
#define VISION_SOF_CMD 0xA7
|
||||
#define VISION_SOF_DEBUG 0xA8
|
||||
|
||||
#define VISION_AUTO_LEN 10
|
||||
#define VISION_AUTO_LEN 18
|
||||
#define VISION_MANUAL_LEN 10
|
||||
#define VISION_CMD_LEN 3
|
||||
#define VISION_DEBUG_LEN 50
|
||||
@@ -61,8 +62,10 @@ typedef enum
|
||||
typedef struct
|
||||
{
|
||||
/* 自动模式数据 */
|
||||
float error_x;
|
||||
float error_y;
|
||||
float measure_x;
|
||||
float ref_x;
|
||||
float measure_y;
|
||||
float ref_y;
|
||||
uint8_t auto_updated; // 收到新的自动数据帧标志
|
||||
|
||||
/* 手动模式数据 */
|
||||
|
||||
Reference in New Issue
Block a user