Added a define for DEADZONE_RADIUS and implemented it in the shooter power setting within TeleopPeriodic.

This commit is contained in:
Jason 2016-02-11 20:48:03 -05:00
parent a51cdfcb07
commit b4bbdf092b
1 changed files with 16 additions and 5 deletions

View File

@ -9,6 +9,10 @@
#define RAMP_RAISE 3 // Button 3 for Raising Ramp
#define RAMP_LOWER 4 // Button 4 to lower ramp.
#define DEADZONE_RADIUS 0.05 // Deadzone Radius prevents tiny twitches in the joystick's value from
// affecting the robot. Use this for cleaning up drive train and shooter.
// Also used for detecting changes in an axis' value.
#endif // BUTTON_LAYOUT
class Robot: public IterativeRobot
@ -153,16 +157,23 @@ private:
inverting = false;
}
float opThrottle = SaneThrottle(operator_stick.GetThrottle());
if(((1.0 - operator_stick.GetThrottle()) / 2.0) > shooter_power + 0.005
|| ((1.0 - operator_stick.GetThrottle()) / 2.0) < shooter_power -0.005)
if( opThrottle > shooter_power + DEADZONE_RADIUS
|| opThrottle < shooter_power - DEADZONE_RADIUS)
{
shooter_power = (1.0 - operator_stick.GetThrottle()) / 2.0;
shooter.SetPower(shooter_power);
shooter.SetPower(opThrottle);
}
}
/**
* Takes the gross raw throttle input from joystick and returns a
* value between 0.0-1.0 (no negative values)
*/
float SaneThrottle(float rawThrottle)
{
return ((1.0 - rawThrottle) / 2.0);
}
void TestPeriodic()
{