Initial commit: SmartCar Framework v0.1 — 龙芯2K0300智能车开发框架\n\n- HAL: GPIO/PWM/Encoder/Framebuffer 驱动\n- Control: PID/IMU/Motor/Servo 控制\n- Vision: HSV双Otsu→4点标定IPM→洪泛填充→逐行搜线\n- Strategy: 三区前瞻偏差+速度策略\n- Debug: 文件热调参+LCD预览+cv截帧\n- Scheduler: 5ms timerfd+epoll 中央调度器

This commit is contained in:
2026-05-25 10:31:55 +08:00
commit 28d9c6da58
52 changed files with 2599 additions and 0 deletions

24
control/imu.hpp Normal file
View File

@@ -0,0 +1,24 @@
#pragma once
#include "types.hpp"
#include <cstdint>
class YawTracker {
public:
YawTracker();
bool begin(const char* device = IMU_DEVICE, int baud = IMU_BAUDRATE);
void update(float dt);
void calibrate(int samples = 200);
float yaw() const { return _yaw; }
float unbounded_yaw() const { return _unbounded_yaw; }
float gyro_z() const { return _gyro_z; }
bool ready() const { return _ready; }
private:
int _fd;
float _yaw, _unbounded_yaw;
float _gyro_z;
float _gyro_bias;
bool _ready;
int _parseJY62();
};