4ba29d0fef26e58639d4a6a49c4d377b3c27abff
[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.Timer;
8 import edu.wpi.first.wpilibj.command.Command;
9
10 /**
11 * This command runs index wheel continuously when OI button managing index
12 * wheel is pressed. The command will run the index wheel motor until the button
13 * triggering it is released.
14 *
15 * Should only be run from the operator interface.
16 *
17 * pre-condition: This command must be run by a button in OI with
18 * button.whileHeld(...).
19 *
20 * @author Shaina
21 */
22 public class RunIndexWheelContinuous extends Command {
23 private Shooter shooter = Robot.getShooter();
24 private Timer t = new Timer();
25
26 /**
27 * See JavaDoc comment in class for details
28 *
29 * @param motorVal
30 * value range from -1 to 1
31 */
32 public RunIndexWheelContinuous() {
33 requires(shooter);
34 }
35
36 // Called just before this Command runs the first time
37 @Override
38 protected void initialize() {
39 t.reset();
40 }
41
42 // Called repeatedly when this Command is scheduled to run
43 @Override
44 protected void execute() {
45 if (t.get() % 1 == 0) {
46 if (Shooter.getShooter().getPistonValue() == Constants.Shooter.LOW_GEAR) {
47 Shooter.getShooter().setHighGear();
48 } else {
49 Shooter.getShooter().setLowGear();
50 }
51 }
52
53 double shooterSpeed = shooter.getShooterRPM();
54 if (shooterSpeed > 0) {
55 shooter.setIndexWheelMotorVal(shooter.DEFAULT_INDEXING_SPEED);
56 }
57 }
58
59 // Called once after isFinished returns true
60 @Override
61 protected void end() {
62 shooter.stopIndexWheel();
63 }
64
65 // Called when another command which requires one or more of the same
66 // subsystems is scheduled to run
67 @Override
68 protected void interrupted() {
69 end();
70 }
71
72 @Override
73 protected boolean isFinished() {
74 return false;
75
76 }
77
78 }