添加了pid以及gui
This commit is contained in:
46
inc/PidController.h
Normal file
46
inc/PidController.h
Normal file
@@ -0,0 +1,46 @@
|
||||
#ifndef PID_CONTROLLER_H
|
||||
#define PID_CONTROLLER_H
|
||||
|
||||
#include <opencv2/opencv.hpp>
|
||||
|
||||
class PidController {
|
||||
public:
|
||||
// 构造函数
|
||||
PidController(float kp = 0.0f, float ki = 0.0f, float kd = 0.0f);
|
||||
|
||||
// 更新PID计算
|
||||
float update(float setpoint, float measured_value, float dt);
|
||||
|
||||
// 重置PID控制器
|
||||
void reset();
|
||||
|
||||
// 设置PID参数
|
||||
void setKp(float kp);
|
||||
void setKi(float ki);
|
||||
void setKd(float kd);
|
||||
void setParameters(float kp, float ki, float kd);
|
||||
|
||||
// 获取PID参数
|
||||
float getKp() const;
|
||||
float getKi() const;
|
||||
float getKd() const;
|
||||
|
||||
// 设置输出限制
|
||||
void setOutputLimits(float min, float max);
|
||||
|
||||
// 获取输出
|
||||
float getOutput() const;
|
||||
|
||||
// 获取误差
|
||||
float getError() const;
|
||||
|
||||
private:
|
||||
float kp_, ki_, kd_; // PID参数
|
||||
float last_error_; // 上一次误差
|
||||
float integral_; // 积分项
|
||||
float output_; // 输出值
|
||||
float output_min_, output_max_; // 输出限制
|
||||
bool first_iteration_; // 是否为第一次迭代
|
||||
};
|
||||
|
||||
#endif // PID_CONTROLLER_H
|
||||
Reference in New Issue
Block a user