Code: Comments
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user