d2d386ab040422c72ac3a7863dcc7d8262022f67
[3501/2017steamworks] / src / org / usfirst / frc / team3501 / robot / commands / shooter / RunIndexWheelContinuous.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 continuously when OI button managing index
10 * wheel is pressed. The command will run the index wheel motor until the button
11 * triggering it is released.
12 *
13 * Should only be run from the operator interface.
14 *
15 * pre-condition: This command must be run by a button in OI with
16 * button.whileHeld(...).
17 *
18 * @author Shaina
19 */
20 public class RunIndexWheelContinuous extends Command {
21 private Shooter shooter = Robot.getShooter();
22
23 /**
24 * See JavaDoc comment in class for details
25 */
26 public RunIndexWheelContinuous() {
27 requires(shooter);
28 }
29
30 @Override
31 protected void initialize() {
32 }
33
34 @Override
35 protected void execute() {
36 double shooterSpeed = shooter.getShooterRPM();
37 double targetShooterSpeed = shooter.getTargetShootingSpeed();
38 double threshold = shooter.getRPMThreshold();
39 if (Math.abs(shooterSpeed - targetShooterSpeed) <= threshold)
40 shooter.runIndexWheel();
41 }
42
43 @Override
44 protected void end() {
45 shooter.stopIndexWheel();
46 }
47
48 @Override
49 protected void interrupted() {
50 end();
51 }
52
53 @Override
54 protected boolean isFinished() {
55 return false;
56
57 }
58
59 }