drive: only drive when the PID is calculated

no need to recalibrate the pid
pull/1/head
EmaMaker 2021-05-10 20:37:13 +02:00
parent 714b00ee25
commit 15ba2991a1
2 changed files with 42 additions and 42 deletions

View File

@ -52,7 +52,7 @@ void loop() {
striker->play(striker_condition); striker->play(striker_condition);
keeper->play(keeper_condition); keeper->play(keeper_condition);
// testmenu->testMenu(); testmenu->testMenu();
// Last thing to do: movement and update status vector // Last thing to do: movement and update status vector
drive->drivePrepared(); drive->drivePrepared();

View File

@ -96,8 +96,7 @@ void DriveController::drive(int dir, int speed, int tilt){
input = delta; input = delta;
setpoint = tilt; setpoint = tilt;
pid->Compute(); if(pid->Compute()){
pidfactor = -output; pidfactor = -output;
speed1 += pidfactor; speed1 += pidfactor;
speed2 += pidfactor; speed2 += pidfactor;
@ -143,6 +142,7 @@ void DriveController::drive(int dir, int speed, int tilt){
m4->drive((int) speed4); m4->drive((int) speed4);
oldSpeed = speed; oldSpeed = speed;
}
CURRENT_DATA_WRITE.dir = dir; CURRENT_DATA_WRITE.dir = dir;
CURRENT_DATA_WRITE.speed = speed; CURRENT_DATA_WRITE.speed = speed;