agv-control/Plugin/Driver/pid_controller.h
CaiXiang 4be62027c6 引入PID控制器并更新相关功能
在多个文件中进行了重要更改:
- 更新 `Driver.rc` 和 `resource.h` 的二进制文件。
- 在 `Driver.vcxproj` 中添加了多线程调试DLL的运行库设置。
- 引入 `pid_controller.h` 和 `pid_controller.cpp`,实现PID控制器功能。
- 在 `DriverMainDlg.cpp` 中添加了对PID控制的支持,包括新成员变量和方法。
- 增加了自动发送和车辆位置更新的功能。
- 在 `Protocol.h` 中添加了新的消息类型 `GUIDE_FAST`。
2025-06-16 11:16:20 +08:00

45 lines
1.0 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef PID_CONTROLLER_H
#define PID_CONTROLLER_H
class PIDController {
private:
// PID参数
float kp; // 比例系数
float ki; // 积分系数
float kd; // 微分系数
// 积分项和输出限制
float integralLimitLow;
float integralLimitHigh;
float outputLimitLow;
float outputLimitHigh;
// 状态变量
float prevError; // 上一次误差
float integral; // 积分项
float prevMeasurement; // 上一次测量值
// 时间相关
float dt; // 时间步长
bool firstRun; // 是否首次运行
public:
// 构造函数初始化PID参数和限制
PIDController(float proportionalGain, float integralGain, float derivativeGain,
float iLimitLow, float iLimitHigh, float oLimitLow, float oLimitHigh, float timeStep);
// 重置控制器状态
void reset();
// 计算PID输出
float compute(float setpoint, float measurement);
// 获取当前PID参数
void getTunings(float& p, float& i, float& d) const;
// 设置PID参数
void setTunings(float p, float i, float d);
};
#endif // PID_CONTROLLER_H