code review changes
[3501/2017steamworks] / src / org / usfirst / frc / team3501 / robot / commands / shooter / RunIndexWheel.java
CommitLineData
809609c9 1package org.usfirst.frc.team3501.robot.commands.shooter;
2
5b1f2bc5 3import org.usfirst.frc.team3501.robot.Robot;
00f515a1 4import org.usfirst.frc.team3501.robot.subsystems.Shooter;
5b1f2bc5 5
809609c9 6import edu.wpi.first.wpilibj.command.Command;
7
8/**
973f0ac4 9 * This command runs index wheel at a given speed for given time in seconds.
10 *
11 * pre-condition: fly wheel is running at full speed to prepare for shooting
12 * fuel
13 *
27d2386f 14 * @author Shaina
809609c9 15 */
16public class RunIndexWheel extends Command {
00f515a1 17 private Shooter shooter = Robot.getShooter();
c0860df7 18 private double time;
c0860df7 19
b7ef589a 20 /**
21 * See JavaDoc comment in class for details
22 *
23 * @param motorVal
24 * value range from -1 to 1
25 * @param time
26 * in seconds, amount of time to run index wheel motor
27 */
00f515a1
CZ
28 public RunIndexWheel(double time) {
29 requires(shooter);
c0860df7 30 this.time = time;
31 }
32
33 // Called just before this Command runs the first time
34 @Override
35 protected void initialize() {
36 }
37
38 // Called repeatedly when this Command is scheduled to run
39 @Override
40 protected void execute() {
d7042bec 41 double shooterSpeed = shooter.getShooterRPM();
7ba6bc91
CZ
42 double targetShooterSpeed = shooter.getTargetShootingSpeed();
43 double threshold = shooter.getRPMThreshold();
44 if (Math.abs(shooterSpeed - targetShooterSpeed) <= threshold)
f625e57a 45 shooter.runIndexWheel();
c0860df7 46 }
47
48 // Called once after isFinished returns true
49 @Override
50 protected void end() {
00f515a1 51 shooter.stopIndexWheel();
c0860df7 52 }
53
54 // Called when another command which requires one or more of the same
55 // subsystems is scheduled to run
56 @Override
57 protected void interrupted() {
5b1f2bc5 58 end();
c0860df7 59 }
60
61 @Override
62 protected boolean isFinished() {
00f515a1 63 return timeSinceInitialized() >= time;
c0860df7 64 }
809609c9 65
66}