1
Fork 0

naive pid impl

This commit is contained in:
Andy Killorin 2024-10-23 11:49:39 -04:00
parent 0534981d4b
commit 4ca507605a
Signed by: ank
GPG key ID: 23F9463ECB67FE8C

View file

@ -122,8 +122,14 @@ protected:
// Calculate the error in speed
float error = targetSpeed - speed;
sumError += error;
float errorDiff = error - prevError;
prevError = error;
// Calculate the effort from the PID gains
int16_t effort = Kp * error;
int16_t effort = Kp * error + Ki * sumError + Kd * errorDiff;
// Set the effort for the motor
SetEffort(effort);