From 5153aaa161ebf407abf7fff7ef63b07e080d09c2 Mon Sep 17 00:00:00 2001 From: Jason Cox Date: Sun, 21 Feb 2016 20:50:24 -0500 Subject: [PATCH] Added a defined TURN_FACTOR for easily testing variations of the SimpleDrive method --- Robot2016/src/Robot.cpp | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/Robot2016/src/Robot.cpp b/Robot2016/src/Robot.cpp index ac53015..e656fd4 100644 --- a/Robot2016/src/Robot.cpp +++ b/Robot2016/src/Robot.cpp @@ -10,10 +10,15 @@ #define RAMP_LOWER 4 // Button 4 to lower ramp. #define UNJAM 11 -#define DEADZONE_RADIUS 0.01 // Deadzone Radius prevents tiny twitches in the joystick's value from +#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. +#define TURN_FACTOR 1.5 // Left(x,y) = y*(1 + TF*x) : x < 0 + // = y : x >= 0 + // Right(x,y) = y : x < 0 + // = y*(1 - TF*x) : x >= 0 + #endif // BUTTON_LAYOUT class Robot: public IterativeRobot @@ -246,6 +251,27 @@ private: lw->Run(); } + void SimpleDrive() + { + float x = -driver_stick.GetX(); + float y = -driver_stick.GetY(); + float left = 0; + float right = 0; + + if (x > 0) + { + right = y; + left = (1- x*TURN_FACTOR)*y ; + } + else + { + left = y; + right = (1+x*TURN_FACTOR)*y; + } + + drive.TankDrive(left, right); + } + void UpdateDrive() { float x = -driver_stick.GetX();