fill in execute() and isFinished()
authorMeryem Esa <meresa14@gmail.com>
Wed, 3 Feb 2016 04:27:10 +0000 (20:27 -0800)
committerMeryem Esa <meresa14@gmail.com>
Mon, 15 Feb 2016 01:01:16 +0000 (17:01 -0800)
src/org/usfirst/frc/team3501/robot/commands/driving/TurnForTime.java

index aef24840ae97ca833bd41659770d87818095b85f..f2e2540c7bd091966ac722f9534cbe3026047e2a 100755 (executable)
@@ -1,14 +1,16 @@
 package org.usfirst.frc.team3501.robot.commands.driving;
 
 import org.usfirst.frc.team3501.robot.Constants.Direction;
+import org.usfirst.frc.team3501.robot.Robot;
 
 import edu.wpi.first.wpilibj.Timer;
 import edu.wpi.first.wpilibj.command.Command;
 
 public class TurnForTime extends Command {
-  Direction direction;
-  double seconds;
-  Timer timer;
+  private final double SPEED = 0.5;
+  private Direction direction;
+  private double seconds;
+  private Timer timer;
 
   public TurnForTime(double seconds, Direction direction) {
     this.seconds = seconds;
@@ -23,18 +25,18 @@ public class TurnForTime extends Command {
 
   @Override
   protected void execute() {
-    /*
-     * if direction is right make the left motor run forward make the right
-     * motor run backward if direction is left make right motor run forward make
-     * the left motor run backward
-     */
+
+    if (direction == Direction.RIGHT) {
+      Robot.driveTrain.setMotorSpeeds(SPEED, -SPEED);
+    } else if (direction == Direction.LEFT) {
+      Robot.driveTrain.setMotorSpeeds(-SPEED, SPEED);
+    }
   }
 
   @Override
   protected boolean isFinished() {
-    /*
-     * when time is up return true
-     */
+    if (timer.get() >= seconds)
+      return true;
     return false;
   }