添加灰度传感器索引宏和右转90度位置环子任务
- GrayscaleSensor: 添加 GS_L4~GS_R4 枚举索引、GS_IS_ON_BLACK 阈值宏 - 提取 yaw_correct() 工具函数,消除角度修正重复代码 - 位置环新增 T型路口检测和自动右转90度子任务
This commit is contained in:
@@ -3,8 +3,18 @@
|
||||
|
||||
#include "zf_common_typedef.h"
|
||||
|
||||
enum {
|
||||
GS_L4=0,GS_L3,GS_L2,GS_L1,GS_R1,GS_R2,GS_R3,GS_R4
|
||||
};
|
||||
|
||||
extern volatile float grayscale_sensor_position; // 存储小车相对于黑线的位置
|
||||
|
||||
extern volatile float adc_normalized[8];
|
||||
|
||||
//模拟量转数字量的阈值
|
||||
#define GS_THRESHOLD 0.5
|
||||
#define GS_IS_ON_BLACK(x) (adc_normalized[x]>GS_THRESHOLD)
|
||||
|
||||
void grayscale_sensor_init(void);
|
||||
void grayscale_sensor_scan(void);
|
||||
void grayscale_sensor_set_white(void);
|
||||
|
||||
Reference in New Issue
Block a user