competition fixes
[3501/2017steamworks] / src / org / usfirst / frc / team3501 / robot / commands / driving / JoystickDrive.java
index aa9bfafffe20b46aa0ac71a372d57feda8e4f5cb..006a13cecc2c58568b7695da36a50c3c78a2de59 100755 (executable)
@@ -13,6 +13,9 @@ import edu.wpi.first.wpilibj.command.Command;
  */
 public class JoystickDrive extends Command {
 
+  double previousThrust = 0;
+  double previousTwist = 0;
+
   public JoystickDrive() {
     requires(Robot.getDriveTrain());
   }
@@ -23,15 +26,16 @@ public class JoystickDrive extends Command {
 
   @Override
   protected void execute() {
-    final double thrust = OI.xboxController.getY();
-    final double twist = OI.xboxController.getAxis(AxisType.kZ);
+    double thrust = OI.xboxController.getY();
+    double twist = OI.xboxController.getAxis(AxisType.kZ);
 
-    Robot.getDriveTrain().joystickDrive(-thrust, -twist);
+    thrust = (6 * previousThrust + thrust) / 7;
+    twist = (6 * previousTwist + twist) / 7;
 
-    /*
-     * double left = OI.leftJoystick.getY(); double right =
-     * OI.rightJoystick.getY(); Robot.getDriveTrain().tankDrive(-left, -right);
-     */
+    previousThrust = thrust;
+    previousTwist = twist;
+
+    Robot.getDriveTrain().joystickDrive(-thrust, -twist);
   }
 
   @Override