Code: Comments

This commit is contained in:
2023-05-20 20:27:39 -03:00
parent 3aff3e79a7
commit ef20de582b

View File

@@ -35,15 +35,15 @@ void Motor::pid(float inputRevPerTick){
error = inputRevPerTick - currentRevPerTick;
derror = error - lastError;
ierror += error;
if(ierror > 1){
if(ierror > 1){ // Anti-windup
ierror = 1;
}else if(ierror < -1){
ierror = -1;
}
float pid = kp*error + ki*ierror + kd*derror;
if(pid > 1){
if(pid > 1){ // Clamp
pid = 1;
}else if(pid<-1){
}else if(pid < -1){
pid = -1;
}
setPower(pid);