清理编码器+死代码+可读性整理: 删除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:
+17
-20
@@ -1,37 +1,34 @@
|
||||
#include "global.h"
|
||||
#include <fstream>
|
||||
|
||||
CfgCache g_cfg;
|
||||
double target_speed;
|
||||
|
||||
// 从文件读取双精度值
|
||||
double readDoubleFromFile(const std::string &filename)
|
||||
{
|
||||
std::ifstream file(filename);
|
||||
double value = 0.0;
|
||||
if (file.is_open())
|
||||
{
|
||||
file >> value; // 读取文件中的值
|
||||
file.close();
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "Failed to open " << filename << std::endl;
|
||||
}
|
||||
if (file.is_open()) { file >> value; file.close(); }
|
||||
return value;
|
||||
}
|
||||
|
||||
// 从文件中读取标志
|
||||
bool readFlag(const std::string &filename)
|
||||
{
|
||||
std::ifstream file(filename);
|
||||
int flag = 0;
|
||||
if (file.is_open())
|
||||
{
|
||||
file >> flag; // 读取文件中的更新标志
|
||||
file.close();
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "Failed to open " << filename << std::endl;
|
||||
}
|
||||
if (file.is_open()) { file >> flag; file.close(); }
|
||||
return flag;
|
||||
}
|
||||
|
||||
void cfg_load_all()
|
||||
{
|
||||
g_cfg.speed = readDoubleFromFile(speed_file);
|
||||
g_cfg.foresee = readDoubleFromFile(foresee_file);
|
||||
g_cfg.zebrasee = readDoubleFromFile(zebrasee_file);
|
||||
g_cfg.deadband = readDoubleFromFile(deadband_file);
|
||||
g_cfg.steer_gain = readDoubleFromFile(steer_gain_file);
|
||||
g_cfg.center_bias = readDoubleFromFile(center_bias_file);
|
||||
g_cfg.start = readFlag(start_file);
|
||||
g_cfg.showImg = readFlag(showImg_file);
|
||||
g_cfg.debug = readFlag(debug_file);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user