Commit | Line | Data |
---|---|---|
809609c9 | 1 | package org.usfirst.frc.team3501.robot.commands.shooter; |
2 | ||
fe04fc8e | 3 | import org.usfirst.frc.team3501.robot.Constants; |
b30e6822 | 4 | import org.usfirst.frc.team3501.robot.Robot; |
ad7e6b1e | 5 | import org.usfirst.frc.team3501.robot.subsystems.Shooter; |
66945150 | 6 | import edu.wpi.first.wpilibj.Timer; |
809609c9 | 7 | import 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 | */ |
21 | public 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 | |
b7ef589a | 27 | */ |
ad7e6b1e | 28 | public RunIndexWheelContinuous() { |
00f515a1 | 29 | requires(shooter); |
4f2fa45c | 30 | } |
31 | ||
4f2fa45c | 32 | @Override |
33 | protected void initialize() { | |
2d810c3c | 34 | t.start(); |
4f2fa45c | 35 | } |
36 | ||
4f2fa45c | 37 | @Override |
38 | protected void execute() { | |
b30e6822 | 39 | if (t.get() >= 1) { |
2d810c3c RR |
40 | if (Shooter.getShooter().getPistonValue() == Constants.Shooter.LOW_GEAR) { |
41 | Shooter.getShooter().setHighGear(); | |
42 | } else { | |
43 | Shooter.getShooter().setLowGear(); | |
44 | } | |
45 | t.reset(); | |
46 | } | |
02cde7ca | 47 | |
dd4a8793 | 48 | if (shooter.isShooterRPMWithinRangeOfTargetSpeed(25)) |
f625e57a | 49 | shooter.runIndexWheel(); |
6bc81b55 | 50 | |
4f2fa45c | 51 | } |
52 | ||
4f2fa45c | 53 | @Override |
54 | protected void end() { | |
135022bc | 55 | shooter.stopIndexWheel(); |
4f2fa45c | 56 | } |
57 | ||
4f2fa45c | 58 | @Override |
59 | protected void interrupted() { | |
210ebccb | 60 | end(); |
4f2fa45c | 61 | } |
62 | ||
63 | @Override | |
64 | protected boolean isFinished() { | |
2a9dabb1 | 65 | return false; |
4f2fa45c | 66 | } |
809609c9 | 67 | |
68 | } |