Actually use the autonomous chooser

This commit is contained in:
Adam Goldsmith 2016-03-09 19:11:28 -05:00
parent e57db04c97
commit a76d3359c2

View File

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