Advertisement
Trainlover08

PID class

May 13th, 2024
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. class PID{
  2.     double proportional_gain = 1.0f;
  3.     double intigral_gain = 1.0f;
  4.     double derivitve_gain = 1.0f;
  5.    
  6.     private:
  7.    
  8.         double x_1;
  9.         double x_2;
  10.        
  11.         double intigral;
  12.    
  13.    
  14.     public:
  15.    
  16.     double PID(double error) {
  17.         x_1 = x_2;
  18.         x_2 = error;
  19.         intigral = intigral + error;
  20.        
  21.         return ((intigral * intigral_gain) + (error * proprotional_gain) + ((x_2 - x_1) * derivitive_gain));
  22.     }
  23. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement