Simplify driving code
This commit is contained in:
parent
d115ea3782
commit
3076436202
@ -182,6 +182,21 @@ private:
|
||||
}
|
||||
|
||||
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 y = -driver_stick.GetY();
|
||||
@ -198,6 +213,7 @@ private:
|
||||
drive.TankDrive(left, right);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
Robot():
|
||||
@ -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))
|
||||
|
Reference in New Issue
Block a user