I wrote code for incrreasing and decreasing shooting speed and added necessary consta...
[3501/2017steamworks] / src / org / usfirst / frc / team3501 / robot / commands / shooter / RunFlyWheel.java
index 6a6e9502ed0332f116e0611f8b148b11c3b0897a..78506882140bd14c817d8f05014baa11018afb30 100644 (file)
@@ -1,21 +1,65 @@
 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.Timer;
 import edu.wpi.first.wpilibj.command.Command;
 
 /**
- * Runs the fly wheel at a given speed in () for input time in seconds
+ * 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 speed
- *            in ()
- * @param time
- *            in seconds
+ * @author Shaina
  */
 public class RunFlyWheel extends Command {
+  private Shooter shooter = Robot.getShooter();
+  Timer timer;
+  private double time;
+
+  /**
+   * 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);
+
+    timer = new Timer();
+    this.time = time;
+  }
+
+  // Called just before this Command runs the first time
+  @Override
+  protected void initialize() {
+    timer.start();
+    shooter.setFlyWheelMotorVal(shooter.CURRENT_SHOOTING_SPEED);
+  }
+
+  // Called repeatedly when this Command is scheduled to run
+  @Override
+  protected void execute() {
+  }
+
+  // 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() {
-               // TODO Auto-generated method stub
-               return false;
-       }
+  @Override
+  protected boolean isFinished() {
+    return timer.get() >= time;
+  }
 
 }