RobotHardware-UESTC/Hardware/银星机器人底盘/PiRobot-YH_Firmware v1.0/STM32/Lib/PID/pid.h

40 lines
838 B
C
Raw Normal View History

2024-01-20 13:19:09 +08:00
#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 max_output);
private:
float kp;
float ki;
float kd;
float max_output;
float* input;
float* feedback;
float error; //比例值
float integra;//积分值
float derivative;//微分值
float previous_error; //上一次的输入反馈差值
};
#endif