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()
{
float x = -driver_stick.GetX();
float y = -driver_stick.GetY();
if (x > 0)
// 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)
{
float right = y * SaneThrottle(driver_stick.GetThrottle());
float left = (1-x)*y * SaneThrottle(driver_stick.GetThrottle());
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
else //Normal Drive
{
float left = y * SaneThrottle(driver_stick.GetThrottle());
float right = (1+x)*y * SaneThrottle(driver_stick.GetThrottle());
drive.TankDrive(left, right);
float x = -driver_stick.GetX();
float y = -driver_stick.GetY();
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()
{
LogCSVData();
UpdateDrive();
std::cout << "arm encoder position: " << arms.GetEncPosition() << 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;
// This is shit code for testing. Replace it with real code.
if(!ramping && operator_stick.GetRawButton(RAMP_RAISE))