driver practice changes
[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
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
24 /**
25 * See JavaDoc comment in class for details
26 */
27 public RunIndexWheelContinuous() {
28 requires(shooter);
29 }
30
31 @Override
32 protected void initialize() {
33 }
34
35 @Override
36 protected void execute() {
37 if (timeSinceInitialized() % 0.5 <= 0.02) {
38 if (Shooter.getShooter().getPistonValue() == Constants.Shooter.LOW_GEAR) {
39 Shooter.getShooter().setHighGear();
40 } else {
41 Shooter.getShooter().setLowGear();
42 }
43 }
44
45 double shooterSpeed = shooter.getShooterRPM();
46 double targetShooterSpeed = shooter.getTargetShootingSpeed();
47 double threshold = shooter.getRPMThreshold();
48 if (Math.abs(shooterSpeed - targetShooterSpeed) <= threshold)
49 shooter.runIndexWheel();
50 }
51
52 @Override
53 protected void end() {
54 shooter.stopIndexWheel();
55 }
56
57 @Override
58 protected void interrupted() {
59 end();
60 }
61
62 @Override
63 protected boolean isFinished() {
64 return false;
65 }
66
67 }