Commit | Line | Data |
---|---|---|
809609c9 | 1 | package org.usfirst.frc.team3501.robot.commands.shooter; |
2 | ||
eedddcb4 | 3 | import org.usfirst.frc.team3501.robot.Constants; |
210ebccb | 4 | import org.usfirst.frc.team3501.robot.Robot; |
ad7e6b1e | 5 | import org.usfirst.frc.team3501.robot.subsystems.Shooter; |
210ebccb | 6 | |
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(); |
4f2fa45c | 23 | |
b7ef589a | 24 | /** |
25 | * See JavaDoc comment in class for details | |
b7ef589a | 26 | */ |
ad7e6b1e | 27 | public RunIndexWheelContinuous() { |
00f515a1 | 28 | requires(shooter); |
4f2fa45c | 29 | } |
30 | ||
4f2fa45c | 31 | @Override |
32 | protected void initialize() { | |
33 | } | |
34 | ||
4f2fa45c | 35 | @Override |
36 | protected void execute() { | |
82fa994f | 37 | if (timeSinceInitialized() % 1 == 0) { |
eedddcb4 RR |
38 | if (Shooter.getShooter().getPistonValue() == Constants.Shooter.LOW_GEAR) { |
39 | Shooter.getShooter().setHighGear(); | |
40 | } else { | |
41 | Shooter.getShooter().setLowGear(); | |
42 | } | |
43 | } | |
44 | ||
d7042bec | 45 | double shooterSpeed = shooter.getShooterRPM(); |
7ba6bc91 CZ |
46 | double targetShooterSpeed = shooter.getTargetShootingSpeed(); |
47 | double threshold = shooter.getRPMThreshold(); | |
b70398a7 CZ |
48 | if (Math.abs(shooterSpeed - targetShooterSpeed) <= threshold) |
49 | shooter.runIndexWheel(); | |
4f2fa45c | 50 | } |
51 | ||
4f2fa45c | 52 | @Override |
53 | protected void end() { | |
135022bc | 54 | shooter.stopIndexWheel(); |
4f2fa45c | 55 | } |
56 | ||
4f2fa45c | 57 | @Override |
58 | protected void interrupted() { | |
210ebccb | 59 | end(); |
4f2fa45c | 60 | } |
61 | ||
62 | @Override | |
63 | protected boolean isFinished() { | |
2a9dabb1 | 64 | return false; |
4f2fa45c | 65 | } |
809609c9 | 66 | |
67 | } |