#ifndef GLOBAL_H #define GLOBAL_H #include // ── 参数文件名 ── const std::string kp_file = "./kp"; const std::string ki_file = "./ki"; const std::string kd_file = "./kd"; const std::string start_file = "./start"; const std::string showImg_file = "./showImg"; const std::string destfps_file = "./destfps"; const std::string foresee_file = "./foresee"; const std::string zebrasee_file = "./zebrasee"; const std::string saveImg_file = "./saveImg"; const std::string speed_file = "./speed"; const std::string deadband_file = "./deadband"; const std::string steer_gain_file = "./steer_gain"; const std::string center_bias_file = "./center_bias"; const std::string debug_file = "./debug"; const std::string cone_avoid_gain_file = "./cone_avoid_gain"; const std::string cone_avoid_range_file = "./cone_avoid_range"; const std::string cone_speed_file = "./cone_speed"; const std::string cone_min_frames_file = "./cone_min_frames"; const std::string cone_margin_file = "./cone_margin"; const std::string cone_thresh_file = "./cone_thresh"; const std::string cone_hold_frames_file = "./cone_hold_frames"; const std::string brake_scale_file = "./brake_scale"; const std::string brake_max_file = "./brake_max"; double readDoubleFromFile(const std::string &filename); bool readFlag(const std::string &filename); void cfg_load_all(); // ── 启动时缓存的运行参数 ── struct CfgCache { double speed = 60; // 目标速度(占空比 %) double foresee = 80; // 前瞻行 double zebrasee = 60; // 斑马线触发距离阈值 double deadband = 5; // 舵机死区 double steer_gain = 1.0; // 舵机增益 double center_bias = 0; // 中线偏移修正 int start = 0; // 1=启动 0=停止 int showImg = 0; // LCD 预览开关 int debug = 0; // debug 模式 double cone_avoid_gain = 0.3; // 锥桶中线变形推离量 (归一化) int cone_avoid_range = 30; // 变形斜坡陡峭度 double cone_speed = 0.5; // 锥桶触发时速度倍率 int cone_min_frames = 3; // 连续确认帧数 int cone_margin = 0; // 0=中心点 1=框边缘 double cone_thresh = 0.80; // 锥桶置信度阈值 int cone_hold_frames = 30; // 锥桶消失后保持变形的帧数 double brake_scale = 10; // 速度(pps) → 刹车占空比(ns) 缩放系数 int brake_max = 10000; // 最大刹车占空比 (ns) }; extern CfgCache g_cfg; extern double target_speed; #endif