Add code to toggle agitator pistons in RunIndexWheelContinuous
[3501/2017steamworks] / src / org / usfirst / frc / team3501 / robot / commands / shooter / RunIndexWheelContinuous.java
CommitLineData
809609c9 1package org.usfirst.frc.team3501.robot.commands.shooter;
2
2d810c3c 3import org.usfirst.frc.team3501.robot.Constants;
210ebccb 4import org.usfirst.frc.team3501.robot.Robot;
ad7e6b1e 5import org.usfirst.frc.team3501.robot.subsystems.Shooter;
66945150 6import edu.wpi.first.wpilibj.Timer;
809609c9 7import edu.wpi.first.wpilibj.command.Command;
8
9/**
d4507ede 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
89a76b33 12 * triggering it is released.
357feb5c 13 *
d4507ede 14 * Should only be run from the operator interface.
15 *
973f0ac4 16 * pre-condition: This command must be run by a button in OI with
17 * button.whileHeld(...).
18 *
27d2386f 19 * @author Shaina
809609c9 20 */
21public class RunIndexWheelContinuous extends Command {
ad7e6b1e 22 private Shooter shooter = Robot.getShooter();
66945150 23 private Timer t = new Timer();
4f2fa45c 24
b7ef589a 25 /**
26 * See JavaDoc comment in class for details
27 *
28 * @param motorVal
29 * value range from -1 to 1
30 */
ad7e6b1e 31 public RunIndexWheelContinuous() {
00f515a1 32 requires(shooter);
4f2fa45c 33 }
34
35 // Called just before this Command runs the first time
36 @Override
37 protected void initialize() {
2d810c3c 38 t.start();
4f2fa45c 39 }
40
41 // Called repeatedly when this Command is scheduled to run
42 @Override
43 protected void execute() {
2d810c3c
RR
44
45 if (t.get() >= 1) {
46 if (Shooter.getShooter().getPistonValue() == Constants.Shooter.LOW_GEAR) {
47 Shooter.getShooter().setHighGear();
48 } else {
49 Shooter.getShooter().setLowGear();
50 }
51 t.reset();
52 }
02cde7ca 53
d7042bec 54 double shooterSpeed = shooter.getShooterRPM();
f625e57a
CZ
55 if (shooterSpeed > 0)
56 shooter.runIndexWheel();
4f2fa45c 57 }
58
59 // Called once after isFinished returns true
60 @Override
61 protected void end() {
135022bc 62 shooter.stopIndexWheel();
4f2fa45c 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() {
210ebccb 69 end();
4f2fa45c 70 }
71
72 @Override
73 protected boolean isFinished() {
2a9dabb1 74 return false;
adfc0171 75
4f2fa45c 76 }
809609c9 77
78}