forked from logzhan/RobotHardware-UESTC
40 lines
828 B
C++
40 lines
828 B
C++
#ifndef PIBOT_PID_H_
|
||
#define PIBOT_PID_H_
|
||
|
||
//pid接口
|
||
class PID
|
||
{
|
||
public:
|
||
/* pid构造函数
|
||
* @param input pid输入的地址
|
||
* @param output pid输出的地址
|
||
* @param kp, ki, kd pid参数
|
||
* @param max_output 输出结构的限制值
|
||
*/
|
||
PID(float* input, float* feedback, float kp, float ki, float kd, unsigned short max_output);
|
||
|
||
// pid计算
|
||
short Compute(float interval);
|
||
|
||
// 重置pid的值
|
||
void Clear();
|
||
|
||
//更新pid参数
|
||
void Update(float kp, float ki, float kd, unsigned short _maxOutput);
|
||
private:
|
||
float kp;
|
||
float ki;
|
||
float kd;
|
||
float max_output;
|
||
float* input;
|
||
float* feedback;
|
||
|
||
float err; //比例值
|
||
float integra;//积分值
|
||
float derivative;//微分值
|
||
|
||
float preErr; //上一次的输入反馈差值
|
||
};
|
||
|
||
#endif
|