Added comments about the use of the boolean variables in the TeleopPeriodic method

This commit is contained in:
Jason 2016-02-11 20:40:41 -05:00
parent 71b8e5eeff
commit 86e7e2e3be
1 changed files with 17 additions and 1 deletions

View File

@ -118,6 +118,13 @@ private:
launch_spinny.Set(0);
}
/*
* Run the Shooter only while the THUMB button is held down on the operator stick.
* the 'pickupRunning' boolean is there to prevent the shooter from calling PickUp
* every itteration of the TeleopPeriodic method (once every 10ms!)
* The pickup is disabled when the thumb button is released, but the code still
* has 'pickupRunning' as true.
*/
if(operator_stick.GetRawButton(THUMB) && !pickupRunning)
{
shooter.PickUp();
@ -129,6 +136,12 @@ private:
pickupRunning = false;
}
/*
* 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.
* 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)
{
left_drive.SetInverted(!left_drive.GetInverted());
@ -140,7 +153,10 @@ private:
inverting = false;
}
if(((1.0 - operator_stick.GetThrottle()) / 2.0) > shooter_power + 0.005||((1.0 - operator_stick.GetThrottle()) / 2.0) < shooter_power -0.005)
if(((1.0 - operator_stick.GetThrottle()) / 2.0) > shooter_power + 0.005
|| ((1.0 - operator_stick.GetThrottle()) / 2.0) < shooter_power -0.005)
{
shooter_power = (1.0 - operator_stick.GetThrottle()) / 2.0;
shooter.SetPower(shooter_power);