Simplify driving code

This commit is contained in:
Adam Goldsmith 2016-03-12 10:21:18 -05:00
parent d115ea3782
commit 3076436202

View File

@ -183,19 +183,35 @@ private:
void UpdateDrive() void UpdateDrive()
{ {
float x = -driver_stick.GetX(); // Enable arcade mode if button 7 is pressed, disable if
float y = -driver_stick.GetY(); // button 8 is pressed
if (x > 0) arcade = (driver_stick.GetRawButton(7) || arcade) && !driver_stick.GetRawButton(8);
if (arcade)
{ {
float right = y * SaneThrottle(driver_stick.GetThrottle()); drive.ArcadeDrive(driver_stick);
float left = (1-x)*y * SaneThrottle(driver_stick.GetThrottle()); }
else if (driver_stick.GetRawButton(THUMB)) //Turning
{
float left = driver_stick.GetTwist();
float right = -driver_stick.GetTwist();
drive.TankDrive(left, right); drive.TankDrive(left, right);
} }
else else //Normal Drive
{ {
float left = y * SaneThrottle(driver_stick.GetThrottle()); float x = -driver_stick.GetX();
float right = (1+x)*y * SaneThrottle(driver_stick.GetThrottle()); float y = -driver_stick.GetY();
drive.TankDrive(left, right); if (x > 0)
{
float right = y * SaneThrottle(driver_stick.GetThrottle());
float left = (1-x)*y * SaneThrottle(driver_stick.GetThrottle());
drive.TankDrive(left, right);
}
else
{
float left = y * SaneThrottle(driver_stick.GetThrottle());
float right = (1+x)*y * SaneThrottle(driver_stick.GetThrottle());
drive.TankDrive(left, right);
}
} }
} }
@ -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))