Simplify driving code

This commit is contained in:
Adam Goldsmith 2016-03-12 10:21:18 -05:00
parent 9f6bfd3c10
commit 65f7795023

View File

@ -182,6 +182,21 @@ private:
} }
void UpdateDrive() void UpdateDrive()
{
// Enable arcade mode if button 7 is pressed, disable if
// button 8 is pressed
arcade = (driver_stick.GetRawButton(7) || arcade) && !driver_stick.GetRawButton(8);
if (arcade)
{
drive.ArcadeDrive(driver_stick);
}
else if (driver_stick.GetRawButton(THUMB)) //Turning
{
float left = driver_stick.GetTwist();
float right = -driver_stick.GetTwist();
drive.TankDrive(left, right);
}
else //Normal Drive
{ {
float x = -driver_stick.GetX(); float x = -driver_stick.GetX();
float y = -driver_stick.GetY(); float y = -driver_stick.GetY();
@ -198,6 +213,7 @@ private:
drive.TankDrive(left, right); drive.TankDrive(left, right);
} }
} }
}
public: public:
Robot(): Robot():
@ -304,34 +320,10 @@ public:
void TeleopPeriodic() void TeleopPeriodic()
{ {
LogCSVData(); LogCSVData();
UpdateDrive();
std::cout << "arm encoder position: " << arms.GetEncPosition() << std::endl; std::cout << "arm encoder position: " << arms.GetEncPosition() << std::endl;
std::cout << "arm encoder velocity: " << arms.GetEncVel() << std::endl; std::cout << "arm encoder velocity: " << arms.GetEncVel() << std::endl;
if(driver_stick.GetRawButton(7))
{
arcade = true;
}
if(driver_stick.GetRawButton(8))
{
arcade = false;
}
if (arcade)
{
drive.ArcadeDrive(driver_stick);
}
else
{
if (driver_stick.GetRawButton(THUMB))
{
float left = driver_stick.GetTwist();
float right = -driver_stick.GetTwist();
drive.TankDrive(left, right);
}
else
{
UpdateDrive();
}
}
//bool rampDoing = false; //bool rampDoing = false;
// This is shit code for testing. Replace it with real code. // This is shit code for testing. Replace it with real code.
if(!ramping && operator_stick.GetRawButton(RAMP_RAISE)) if(!ramping && operator_stick.GetRawButton(RAMP_RAISE))