Implement RunIndexWheel class
[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;
4
5import edu.wpi.first.wpilibj.Timer;
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 {
5b1f2bc5 17 Timer timer;
c0860df7 18 private double time;
19 private double motorVal;
20
b7ef589a 21 /**
22 * See JavaDoc comment in class for details
23 *
24 * @param motorVal
25 * value range from -1 to 1
26 * @param time
27 * in seconds, amount of time to run index wheel motor
28 */
c0860df7 29 public RunIndexWheel(double motorVal, double time) {
5b1f2bc5 30 requires(Robot.getShooter());
31
32 timer = new Timer();
c0860df7 33 this.motorVal = motorVal;
34 this.time = time;
35 }
36
37 // Called just before this Command runs the first time
38 @Override
39 protected void initialize() {
5b1f2bc5 40 timer.start();
41 Robot.getShooter().setIndexWheelMotorVal(motorVal);
42
c0860df7 43 }
44
45 // Called repeatedly when this Command is scheduled to run
46 @Override
47 protected void execute() {
48 }
49
50 // Called once after isFinished returns true
51 @Override
52 protected void end() {
5b1f2bc5 53 Robot.getShooter().stopIndexWheel();
54
c0860df7 55 }
56
57 // Called when another command which requires one or more of the same
58 // subsystems is scheduled to run
59 @Override
60 protected void interrupted() {
5b1f2bc5 61 end();
c0860df7 62 }
63
64 @Override
65 protected boolean isFinished() {
5b1f2bc5 66 return timer.get() >= time;
c0860df7 67 }
809609c9 68
69}