34c7e0b4edb4df3a35f671974ee5293d833782f9
[3501/2017steamworks] / src / org / usfirst / frc / team3501 / robot / commands / shooter / RunIndexWheelContinuous.java
1 package org.usfirst.frc.team3501.robot.commands.shooter;
2
3 import org.usfirst.frc.team3501.robot.Robot;
4 import org.usfirst.frc.team3501.robot.subsystems.Shooter;
5
6 import edu.wpi.first.wpilibj.Timer;
7 import edu.wpi.first.wpilibj.command.Command;
8
9 /**
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
12 * triggering it is released.
13 *
14 * Should only be run from the operator interface.
15 *
16 * pre-condition: This command must be run by a button in OI with
17 * button.whileHeld(...).
18 *
19 * @author Shaina
20 */
21 public class RunIndexWheelContinuous extends Command {
22 private Shooter shooter = Robot.getShooter();
23 private Timer t = new Timer();
24
25 /**
26 * See JavaDoc comment in class for details
27 *
28 * @param motorVal
29 * value range from -1 to 1
30 */
31 public RunIndexWheelContinuous() {
32 requires(shooter);
33 }
34
35 // Called just before this Command runs the first time
36 @Override
37 protected void initialize() {
38 t.reset();
39 }
40
41 // Called repeatedly when this Command is scheduled to run
42 @Override
43 protected void execute() {
44 double shooterSpeed = shooter.getShooterRPM();
45 if (shooterSpeed > 0)
46 shooter.runIndexWheel();
47 }
48
49 // Called once after isFinished returns true
50 @Override
51 protected void end() {
52 shooter.stopIndexWheel();
53 }
54
55 // Called when another command which requires one or more of the same
56 // subsystems is scheduled to run
57 @Override
58 protected void interrupted() {
59 end();
60 }
61
62 @Override
63 protected boolean isFinished() {
64 return false;
65
66 }
67
68 }