create dead-reckoning class in Constants.java
[3501/stronghold-2016] / src / org / usfirst / frc / team3501 / robot / commands / driving / TurnForTime.java
index b1b37cdda46a014977db6638828348609acbb634..acddeaa54a355c38a9883db367b4b260bcffb1fb 100755 (executable)
@@ -1,5 +1,6 @@
 package org.usfirst.frc.team3501.robot.commands.driving;
 
+import org.usfirst.frc.team3501.robot.Constants.DeadReckoning;
 import org.usfirst.frc.team3501.robot.Constants.Direction;
 import org.usfirst.frc.team3501.robot.Robot;
 
@@ -20,14 +21,19 @@ import edu.wpi.first.wpilibj.command.Command;
  */
 
 public class TurnForTime extends Command {
-  private final double SPEED = 0.5;
   private Direction direction;
   private double seconds;
   private Timer timer;
+  private double speed;
 
-  public TurnForTime(double seconds, Direction direction) {
+  public TurnForTime(double seconds, Direction direction, double speed) {
     this.seconds = seconds;
     this.direction = direction;
+    this.speed = speed;
+  }
+
+  public TurnForTime(double seconds, Direction direction) {
+    this(seconds, direction, DeadReckoning.DEFAULT_SPEED);
   }
 
   @Override
@@ -36,9 +42,9 @@ public class TurnForTime extends Command {
     timer.start();
 
     if (direction == Direction.RIGHT) {
-      Robot.driveTrain.setMotorSpeeds(SPEED, -SPEED);
+      Robot.driveTrain.setMotorSpeeds(speed, -speed);
     } else if (direction == Direction.LEFT) {
-      Robot.driveTrain.setMotorSpeeds(-SPEED, SPEED);
+      Robot.driveTrain.setMotorSpeeds(-speed, speed);
     }
   }