fix indexing piston code
[3501/2017steamworks] / src / org / usfirst / frc / team3501 / robot / commands / shooter / RunIndexWheelContinuous.java
CommitLineData
809609c9 1package org.usfirst.frc.team3501.robot.commands.shooter;
2
1fe2a13c 3import org.usfirst.frc.team3501.robot.Constants;
210ebccb 4import org.usfirst.frc.team3501.robot.Robot;
ad7e6b1e 5import org.usfirst.frc.team3501.robot.subsystems.Shooter;
210ebccb 6
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();
4f2fa45c 23
b7ef589a 24 /**
25 * See JavaDoc comment in class for details
26 *
27 * @param motorVal
28 * value range from -1 to 1
29 */
ad7e6b1e 30 public RunIndexWheelContinuous() {
00f515a1 31 requires(shooter);
4f2fa45c 32 }
33
34 // Called just before this Command runs the first time
35 @Override
36 protected void initialize() {
37 }
38
39 // Called repeatedly when this Command is scheduled to run
40 @Override
41 protected void execute() {
8e45a057 42 if (timeSinceInitialized() % 1 == 0) {
1fe2a13c
RR
43 if (Shooter.getShooter().getPistonValue() == Constants.Shooter.LOW_GEAR) {
44 Shooter.getShooter().setHighGear();
45 } else {
46 Shooter.getShooter().setLowGear();
47 }
48 }
49
d7042bec
NA
50 double shooterSpeed = shooter.getShooterRPM();
51 if (shooterSpeed > 0) {
52 shooter.setIndexWheelMotorVal(shooter.DEFAULT_INDEXING_SPEED);
53 }
4f2fa45c 54 }
55
56 // Called once after isFinished returns true
57 @Override
58 protected void end() {
135022bc 59 shooter.stopIndexWheel();
4f2fa45c 60 }
61
62 // Called when another command which requires one or more of the same
63 // subsystems is scheduled to run
64 @Override
65 protected void interrupted() {
210ebccb 66 end();
4f2fa45c 67 }
68
69 @Override
70 protected boolean isFinished() {
2a9dabb1 71 return false;
adfc0171 72
4f2fa45c 73 }
809609c9 74
75}