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