2
0
mirror of https://github.com/team2059/Zaphod synced 2024-12-18 20:12:28 -05:00

Changed the auto sequencing to a switch-case instead of a bunch of if statements

This commit is contained in:
Adam Long 2014-03-22 20:00:36 -04:00
parent 3fa5c4bcc0
commit 5030b06c38

View File

@ -254,6 +254,7 @@ public:
int c=0; int c=0;
float power=SmartDashboard::GetNumber("AutoPower"); float power=SmartDashboard::GetNumber("AutoPower");
float correction=SmartDashboard::GetNumber("AutoCorrection"); float correction=SmartDashboard::GetNumber("AutoCorrection");
float autoSeq=SmartDashboard::GetNumber("Autonomous Sequence");
int currentStep=0; int currentStep=0;
compressing=false; compressing=false;
collectorSole1.Set(false); collectorSole1.Set(false);
@ -265,8 +266,9 @@ public:
SmartDashboard::PutBoolean("CollectorState",true); SmartDashboard::PutBoolean("CollectorState",true);
//}}} //}}}
while(IsEnabled()&&IsAutonomous()) { while(IsEnabled()&&IsAutonomous()) {
if(SmartDashboard::GetNumber("Autonomous sequence")==0){ switch (autoSeq) {
//Autonomous0{{{ //Autonomous0{{{
case 0:
//Drive{{{ //Drive{{{
if(currentStep==0){ if(currentStep==0){
if(voltToDistance(WallSonicLeft.GetAverageVoltage(),true)>=SmartDashboard::GetNumber("Auto Distance")){ if(voltToDistance(WallSonicLeft.GetAverageVoltage(),true)>=SmartDashboard::GetNumber("Auto Distance")){
@ -311,9 +313,10 @@ public:
} }
} }
//}}} //}}}
break;
//}}} //}}}
}else if(SmartDashboard::GetNumber("Autonomous sequence")==1){
//Autonomous1{{{ //Autonomous1{{{
case 1:
//Drive{{{ //Drive{{{
if(currentStep==0){ if(currentStep==0){
if(voltToDistance(WallSonicLeft.GetAverageVoltage(),true)>=SmartDashboard::GetNumber("Auto Distance")){ if(voltToDistance(WallSonicLeft.GetAverageVoltage(),true)>=SmartDashboard::GetNumber("Auto Distance")){
@ -390,9 +393,10 @@ public:
} }
} }
//}}} //}}}
break;
//}}} //}}}
}else if(SmartDashboard::GetNumber("Autonomous sequence")==2){
//Autonomous2{{{ //Autonomous2{{{
case 2:
//Drive{{{ //Drive{{{
if(currentStep==0&&c>SmartDashboard::GetNumber("Initial Drive Delay")*200){ if(currentStep==0&&c>SmartDashboard::GetNumber("Initial Drive Delay")*200){
setMotorValue(6, 1, SmartDashboard::GetNumber("Collector Speed")); setMotorValue(6, 1, SmartDashboard::GetNumber("Collector Speed"));
@ -473,6 +477,7 @@ public:
} }
} }
//}}} //}}}
break;
//}}} //}}}
} }
SmartDashboard::PutNumber("Autonomous step", currentStep); SmartDashboard::PutNumber("Autonomous step", currentStep);