Skip to content

Commit

Permalink
empty queue protections
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewmcalinden committed Apr 18, 2022
1 parent bfa6fb9 commit 7629486
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions Competition/src/main/cpp/subsystems/Feeder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,12 @@ void Feeder::analyzeDashboard()
table->PutNumber("Average Amps", state.instCurrent);
table->PutBoolean("Spiked: ", state.spiked);
table->PutBoolean("Banner: ", state.bannerTripped);
table->PutBoolean("Queue top", state.ballHistory.front());
if (!(state.ballHistory.empty())){
table->PutBoolean("Queue top", state.ballHistory.front());
}
else{
table->PutBoolean("Queue top", false);
}

if (state.autoPoopEnabled){
if (isRed()){
Expand Down Expand Up @@ -168,7 +173,10 @@ void Feeder::assignOutputs()
}
else if (state.feederState == FeederState::FEEDER_SHOOT) {
if (state.autoPoopEnabled){
bool currentBall = state.ballHistory.front();
bool currentBall = false;
if (!(state.ballHistory.empty())){
currentBall = state.ballHistory.front();
}
if (currentBall){
shooter->state.offsetTurret = true;
state.counter = 16;
Expand Down Expand Up @@ -272,7 +280,7 @@ void Feeder::updateQueue(){
double target = shooter->state.flywheelTarget;

double diff = fabs((current - target) / target);
if (diff > .15){
if (diff > .15 && !(state.ballHistory.empty())){
state.ballHistory.pop();
}
}
Expand Down

0 comments on commit 7629486

Please sign in to comment.