Commit | Line | Data |
---|---|---|
809609c9 | 1 | package org.usfirst.frc.team3501.robot.commands.shooter; |
2 | ||
02cde7ca | 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 | |
92d45f35 | 7 | import edu.wpi.first.wpilibj.Timer; |
809609c9 | 8 | import edu.wpi.first.wpilibj.command.Command; |
9 | ||
10 | /** | |
d4507ede | 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 | |
89a76b33 | 13 | * triggering it is released. |
357feb5c | 14 | * |
d4507ede | 15 | * Should only be run from the operator interface. |
16 | * | |
973f0ac4 | 17 | * pre-condition: This command must be run by a button in OI with |
18 | * button.whileHeld(...). | |
19 | * | |
27d2386f | 20 | * @author Shaina |
809609c9 | 21 | */ |
22 | public class RunIndexWheelContinuous extends Command { | |
ad7e6b1e | 23 | private Shooter shooter = Robot.getShooter(); |
92d45f35 | 24 | private Timer t = new Timer(); |
4f2fa45c | 25 | |
b7ef589a | 26 | /** |
27 | * See JavaDoc comment in class for details | |
28 | * | |
29 | * @param motorVal | |
30 | * value range from -1 to 1 | |
31 | */ | |
ad7e6b1e | 32 | public RunIndexWheelContinuous() { |
00f515a1 | 33 | requires(shooter); |
4f2fa45c | 34 | } |
35 | ||
36 | // Called just before this Command runs the first time | |
37 | @Override | |
38 | protected void initialize() { | |
92d45f35 | 39 | t.reset(); |
4f2fa45c | 40 | } |
41 | ||
42 | // Called repeatedly when this Command is scheduled to run | |
43 | @Override | |
44 | protected void execute() { | |
02cde7ca RR |
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 | ||
d7042bec | 53 | double shooterSpeed = shooter.getShooterRPM(); |
f625e57a CZ |
54 | if (shooterSpeed > 0) |
55 | shooter.runIndexWheel(); | |
4f2fa45c | 56 | } |
57 | ||
58 | // Called once after isFinished returns true | |
59 | @Override | |
60 | protected void end() { | |
135022bc | 61 | shooter.stopIndexWheel(); |
4f2fa45c | 62 | } |
63 | ||
64 | // Called when another command which requires one or more of the same | |
65 | // subsystems is scheduled to run | |
66 | @Override | |
67 | protected void interrupted() { | |
210ebccb | 68 | end(); |
4f2fa45c | 69 | } |
70 | ||
71 | @Override | |
72 | protected boolean isFinished() { | |
2a9dabb1 | 73 | return false; |
adfc0171 | 74 | |
4f2fa45c | 75 | } |
809609c9 | 76 | |
77 | } |