diff --git a/src/Robot.cpp b/src/Robot.cpp index ce3e84e..ac53015 100644 --- a/src/Robot.cpp +++ b/src/Robot.cpp @@ -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); } } };