48f3546560c895c1bf4a8ae681503aa694f19d94
[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.Constants;
4 import org.usfirst.frc.team3501.robot.Robot;
5 import org.usfirst.frc.team3501.robot.subsystems.Shooter;
6 import edu.wpi.first.wpilibj.Timer;
7 import edu.wpi.first.wpilibj.command.Command;
8
9 /**
10 * This command runs index wheel continuously when OI button managing index
11 * wheel is pressed. The command will run the index wheel motor until the button
12 * triggering it is released.
13 *
14 * Should only be run from the operator interface.
15 *
16 * pre-condition: This command must be run by a button in OI with
17 * button.whileHeld(...).
18 *
19 * @author Shaina
20 */
21 public class RunIndexWheelContinuous extends Command {
22 private Shooter shooter = Robot.getShooter();
23 private Timer t = new Timer();
24
25 /**
26 * See JavaDoc comment in class for details
27 */
28 public RunIndexWheelContinuous() {
29 requires(shooter);
30 }
31
32 @Override
33 protected void initialize() {
34 t.start();
35 }
36
37 @Override
38 protected void execute() {
39 if (t.get() > 1) {
40 if (Shooter.getShooter().getPistonValue() == Constants.Shooter.LOW_GEAR) {
41 Shooter.getShooter().setHighGear();
42 } else {
43 Shooter.getShooter().setLowGear();
44 }
45 t.reset();
46 }
47
48 if (shooter.isShooterRPMWithinRangeOfTargetSpeed(25))
49 shooter.runIndexWheel();
50
51 }
52
53 @Override
54 protected void end() {
55 shooter.stopIndexWheel();
56 }
57
58 @Override
59 protected void interrupted() {
60 end();
61 }
62
63 @Override
64 protected boolean isFinished() {
65 return false;
66 }
67
68 }