Actually sane now. Really, I mean it. ...although the turning circle is somewhat ... elephantine ...

This commit is contained in:
Aidan Ferguson 2016-02-20 16:47:00 -05:00
parent c32e95768c
commit 4044f448d7
1 changed files with 20 additions and 23 deletions

View File

@ -44,7 +44,6 @@ private:
// instance variables
bool pickupRunning; // don't want to spam the Talon with set messages. Toggle the pickup when a button is pressed or released.
bool inverting;
float oldXY;
bool ramping;
bool shooting;
bool unjamming;
@ -117,8 +116,10 @@ private:
{
if (driver_stick.GetRawButton(THUMB))
{
left_drive.Set(driver_stick.GetThrottle() * driver_stick.GetTwist());
right_drive.Set(-1 * driver_stick.GetThrottle() * driver_stick.GetTwist());
float left = driver_stick.GetTwist();
float right = -driver_stick.GetTwist();
drive.TankDrive(left, right);
}
else
{
@ -187,25 +188,25 @@ private:
/*
* The 'inverting' variable is used to make sure that the drive train isn't getting
* inverted every itteration of the TeleopPeriodic method while the button is held down.
* inverted every iteration of the TeleopPeriodic method while the button is held down.
* This is important because the TeleopPeriodic method executes something like once every 10ms.
* Thus, this if-else if pair make the button a toggle.
*/
if(driver_stick.GetRawButton(THUMB) && !inverting)
if(driver_stick.GetRawButton(TRIGGER) && !inverting)
{
std::cout << "Inverting Drive Train.";
left_drive.SetInverted(!left_drive.GetInverted());
right_drive.SetInverted(!right_drive.GetInverted());
inverting = true;
}
else if(!driver_stick.GetRawButton(THUMB))
else if(!driver_stick.GetRawButton(TRIGGER))
{
inverting = false;
}
/*
* Unlike the previous actions, this method does need to be called every itteration of
* Unlike the previous actions, this method does need to be called every iteration of
* TeleopPeriodic. This is because the logic running this operation needs to be checked
* Every time the method is called. This cannot be a loop in the Shoot method because
* that would lock the robot every time the trigger is hit.
@ -247,23 +248,19 @@ private:
void UpdateDrive()
{
float x = driver_stick.GetX();
float y = driver_stick.GetY();
if ((x + y) != oldXY)
float x = -driver_stick.GetX();
float y = -driver_stick.GetY();
if (x > 0)
{
oldXY = x + y;
if (x > 0)
{
float left = y * driver_stick.GetThrottle();
float right = (1-x)*y * driver_stick.GetThrottle();
drive.TankDrive(left, right);
}
else
{
float left = y * driver_stick.GetThrottle();
float right = (1+x)*y * driver_stick.GetThrottle();
drive.TankDrive(left, right);
}
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);
}
}
};