Only run indexwheel if flywheel is running
[3501/2017steamworks] / src / org / usfirst / frc / team3501 / robot / commands / shooter / RunIndexWheel.java
1 package org.usfirst.frc.team3501.robot.commands.shooter;
2
3 import org.usfirst.frc.team3501.robot.Robot;
4 import org.usfirst.frc.team3501.robot.subsystems.Shooter;
5
6 import edu.wpi.first.wpilibj.command.Command;
7
8 /**
9 * This command runs index wheel at a given speed for given time in seconds.
10 *
11 * pre-condition: fly wheel is running at full speed to prepare for shooting
12 * fuel
13 *
14 * @author Shaina
15 */
16 public class RunIndexWheel extends Command {
17 private Shooter shooter = Robot.getShooter();
18 private double time;
19
20 /**
21 * See JavaDoc comment in class for details
22 *
23 * @param motorVal
24 * value range from -1 to 1
25 * @param time
26 * in seconds, amount of time to run index wheel motor
27 */
28 public RunIndexWheel(double time) {
29 requires(shooter);
30 this.time = time;
31 }
32
33 // Called just before this Command runs the first time
34 @Override
35 protected void initialize() {
36 }
37
38 // Called repeatedly when this Command is scheduled to run
39 @Override
40 protected void execute() {
41 double shooterSpeed = shooter.getShooterRPM();
42 if (shooterSpeed > 0) {
43 shooter.setIndexWheelMotorVal(shooter.DEFAULT_INDEXING_SPEED);
44 }
45 }
46
47 // Called once after isFinished returns true
48 @Override
49 protected void end() {
50 shooter.stopIndexWheel();
51 }
52
53 // Called when another command which requires one or more of the same
54 // subsystems is scheduled to run
55 @Override
56 protected void interrupted() {
57 end();
58 }
59
60 @Override
61 protected boolean isFinished() {
62 return timeSinceInitialized() >= time;
63 }
64
65 }