wpi-32u4-library
PIDcontroller.cpp
Go to the documentation of this file.
1#include <PIDcontroller.h>
2#include <math.h>
3
8float PIDController::calcEffort(float error)
9{
10 currError = error; //store in case we want it later
12
13 if(errorBound > 0) //cap error; errorBound == 0 means don't cap
14 {
15 if(fabs(sumError) > errorBound)
16 {
17 sumError -= currError; //if we exceeded the limit, just subtract it off again
18 }
19 }
20
21 float derivError = currError - prevError;
23
24 currEffort = Kp * currError + Ki * sumError + Kd * derivError;
25
26 return currEffort;
27}
float calcEffort(float error)
Used to calculate the effort from the error.