Actually use the autonomous chooser

This commit is contained in:
Adam Goldsmith 2016-03-09 19:11:28 -05:00
parent 623a4022ae
commit 09cbe471a9

View File

@ -69,8 +69,10 @@ private:
LiveWindow *lw = LiveWindow::GetInstance(); LiveWindow *lw = LiveWindow::GetInstance();
SendableChooser *chooser; SendableChooser *chooser;
const std::string autoNameDefault = "Default"; const std::string autoNameDefault = "1.7 Seconds (Slightly Longer)";
const std::string autoNameCustom = "My Auto"; const std::string autoNameShort = "1.5 Seconds (Short, good on the moat)";
const std::string autoNameOne = "1 Seconds";
const std::string autoNameDisable = "Disable Autonomous (set time to 0)";
std::string autoSelected; std::string autoSelected;
void LogCSVData() void LogCSVData()
@ -206,8 +208,11 @@ public:
void RobotInit() void RobotInit()
{ {
chooser = new SendableChooser(); chooser = new SendableChooser();
chooser->AddDefault(autoNameDefault, (void*)&autoNameDefault); chooser->AddDefault(autoNameDefault, (void*)&autoNameDefault);
chooser->AddObject(autoNameCustom, (void*)&autoNameCustom); chooser->AddObject(autoNameShort, (void*)&autoNameShort);
chooser->AddObject(autoNameOne, (void*)&autoNameOne);
chooser->AddObject(autoNameDisable, (void*)&autoNameDisable);
SmartDashboard::PutData("Auto Modes", chooser); SmartDashboard::PutData("Auto Modes", chooser);
shooter1.Enable(); shooter1.Enable();
shooter2.Enable(); shooter2.Enable();
@ -231,50 +236,46 @@ public:
//std::string autoSelected = SmartDashboard::GetString("Auto Selector", autoNameDefault); //std::string autoSelected = SmartDashboard::GetString("Auto Selector", autoNameDefault);
std::cout << "Auto selected: " << autoSelected << std::endl; std::cout << "Auto selected: " << autoSelected << std::endl;
if(autoSelected == autoNameCustom){ auto_status = START;
//Custom Auto goes here
} else {
//Default Auto goes here
auto_status = START;
}
} }
void AutonomousPeriodic() void AutonomousPeriodic()
{ {
const float drivePower = 1; const float drivePower = 1;
const float driveTime = 3; //Seconds to drive forward float driveTime = 1.7;
LogCSVData(); LogCSVData();
if(autoSelected == autoNameCustom){ if (autoSelected == autoNameDisable) driveTime = 0;
//Custom Auto goes here else if (autoSelected == autoNameShort) driveTime = 1.5;
} else { else if (autoSelected == autoNameOne) driveTime = 1;
//Default Auto goes here else driveTime = 1.7;
switch (auto_status)
//Default Auto goes here
switch (auto_status)
{
case START:
{
auto_clock.Start();
auto_status = DRIVING_FORWARD;
break;
}
case DRIVING_FORWARD:
{
if (auto_clock.Get() > driveTime)
{ {
case START: drive.TankDrive(0.0, 0.0);
{ auto_status = STOP;
auto_clock.Start();
auto_status = DRIVING_FORWARD;
break;
}
case DRIVING_FORWARD:
{
if (auto_clock.Get() > driveTime)
{
drive.TankDrive(0.0, 0.0);
auto_status = STOP;
}
else
{
drive.TankDrive(drivePower, drivePower);
}
break;
}
case STOP:
{
std::cout << "All done!\n" ;
break;
}
} }
else
{
drive.TankDrive(drivePower, drivePower);
}
break;
}
case STOP:
{
std::cout << "All done!\n" ;
break;
}
} }
} }