move setmotorvalues to execute and set wheels to constant speeds
[3501/2017steamworks] / src / org / usfirst / frc / team3501 / robot / commands / shooter / RunFlyWheel.java
index 85543ce6b15aec119ad506e05d356e82886fcd33..6ac5d69f3e1934c557adde63add9c5a72d4c5982 100644 (file)
@@ -1,22 +1,30 @@
 package org.usfirst.frc.team3501.robot.commands.shooter;
 
+import org.usfirst.frc.team3501.robot.Robot;
+import org.usfirst.frc.team3501.robot.subsystems.Shooter;
+
 import edu.wpi.first.wpilibj.command.Command;
 
 /**
- * Runs the fly wheel at a given speed for a given time (sec)
+ * This command runs the fly wheel at a given speed for a given time. The fly
+ * wheel is intended to shoot balls fed by the intake wheel.
  *
- * @param motorVal
- *          [-1,1]
- * @param time
- *          in seconds
- * @author shaina
+ * @author Shaina
  */
 public class RunFlyWheel extends Command {
-  private double motorVal;
+  private Shooter shooter = Robot.getShooter();
   private double time;
 
-  public RunFlyWheel(double motorVal, double time) {
-    this.motorVal = motorVal;
+  /**
+   * See JavaDoc comment in class for details
+   *
+   * @param motorVal
+   *          value range from -1 to 1
+   * @param time
+   *          in seconds, amount of time to run fly wheel motor
+   */
+  public RunFlyWheel(double time) {
+    requires(shooter);
     this.time = time;
   }
 
@@ -28,22 +36,25 @@ public class RunFlyWheel extends Command {
   // Called repeatedly when this Command is scheduled to run
   @Override
   protected void execute() {
+    shooter.setFlyWheelMotorVal(shooter.CURRENT_SHOOTING_SPEED);
   }
 
   // Called once after isFinished returns true
   @Override
   protected void end() {
+    shooter.stopFlyWheel();
   }
 
   // Called when another command which requires one or more of the same
   // subsystems is scheduled to run
   @Override
   protected void interrupted() {
+    end();
   }
 
   @Override
   protected boolean isFinished() {
-    return false;
+    return timeSinceInitialized() >= time;
   }
 
 }