清理编码器+死代码+可读性整理: 删除ENCODER类(含UB析构), MotorController简化为PWM+GPIO裸控制器, 移除mortor_kp/ki/kd全局变量, 排除vl53l0x/zebra_detect死代码, 修复image_cv行列写反, 清理无关include
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -1,4 +1,13 @@
|
||||
# 主程序
|
||||
add_executable(smartcar_demo1 main.cpp)
|
||||
|
||||
# 暂时排除激光测距(未使用),保留源文件
|
||||
set(EXCLUDE_VL53L0X vl53l0x.cpp)
|
||||
|
||||
# 排除死代码:斑马线传统检测(已由 nanodet 模型替代)、编码器采集(开环控制不需要)
|
||||
set(EXCLUDE_DEAD zebra_detect.cpp encoder.cpp)
|
||||
|
||||
# 从静态库源文件列表中移除
|
||||
list(FILTER DIR_SRCS EXCLUDE REGEX "(${EXCLUDE_VL53L0X}|${EXCLUDE_DEAD})")
|
||||
|
||||
target_link_libraries(smartcar_demo1 common_lib ${OpenCV_LIBS})
|
||||
+11
-13
@@ -24,31 +24,29 @@ int main(void)
|
||||
double dest_fps = readDoubleFromFile(destfps_file);
|
||||
if (dest_fps <= 0) dest_fps = 30.0;
|
||||
|
||||
cfg_load_all();
|
||||
|
||||
if (CameraInit(0, dest_fps, 320, 240) < 0) {
|
||||
std::cerr << "CameraInit failed" << std::endl;
|
||||
return -1;
|
||||
}
|
||||
ControlInit();
|
||||
std::cout << "All services started (single-thread mode)" << std::endl;
|
||||
std::cout << "All services started" << std::endl;
|
||||
|
||||
int tick = 0;
|
||||
while (running.load())
|
||||
{
|
||||
if (CameraHandler() < 0) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(5));
|
||||
continue;
|
||||
CameraHandler();
|
||||
|
||||
if (++tick % 7 == 0) {
|
||||
g_cfg.debug = readFlag(debug_file);
|
||||
}
|
||||
|
||||
if (++tick % 15 == 0)
|
||||
{
|
||||
target_speed = readDoubleFromFile(speed_file);
|
||||
mortor_kp = readDoubleFromFile(mortor_kp_file);
|
||||
mortor_ki = readDoubleFromFile(mortor_ki_file);
|
||||
mortor_kd = readDoubleFromFile(mortor_kd_file);
|
||||
kp = readDoubleFromFile(kp_file);
|
||||
ki = readDoubleFromFile(ki_file);
|
||||
kd = readDoubleFromFile(kd_file);
|
||||
if (g_cfg.debug) {
|
||||
cfg_load_all();
|
||||
}
|
||||
|
||||
target_speed = g_cfg.speed;
|
||||
}
|
||||
|
||||
std::cout << "Stopping..." << std::endl;
|
||||
|
||||
Reference in New Issue
Block a user