Added resetPID() call when robot velocities are 0 to fix motion perserverance bug

This commit is contained in:
Patrick Goebel 2016-04-18 06:30:15 -07:00
parent d03061ae60
commit 2b4567ec08
2 changed files with 2 additions and 1 deletions

View File

@ -316,6 +316,7 @@ int runCommand() {
lastMotorCommand = millis();
if (arg1 == 0 && arg2 == 0) {
setMotorSpeeds(0, 0);
resetPID();
moving = 0;
}
else moving = 1;

View File

@ -100,7 +100,7 @@ void doPID(SetPointInfo * p) {
/*
* allow turning changes, see http://brettbeauregard.com/blog/2011/04/improving-the-beginner%E2%80%99s-pid-tuning-changes/
*/
p->ITerm += Ki * Perror;
p->ITerm += Ki * Perror;
p->output = output;
p->PrevInput = input;