4c8cd54d102573329a4ee36dc4ca10288249ff20
[3501/2017steamworks] / src / org / usfirst / frc / team3501 / robot / commands / shooter / RunIndexWheel.java
1 package org.usfirst.frc.team3501.robot.commands.shooter;
2
3 import org.usfirst.frc.team3501.robot.Robot;
4
5 import edu.wpi.first.wpilibj.Timer;
6 import edu.wpi.first.wpilibj.command.Command;
7
8 /**
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 *
14 * @author Shaina
15 */
16 public class RunIndexWheel extends Command {
17 Timer timer;
18 private double time;
19 private double motorVal;
20
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 */
29 public RunIndexWheel(double motorVal, double time) {
30 requires(Robot.getShooter());
31
32 timer = new Timer();
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() {
40 timer.start();
41 Robot.getShooter().setIndexWheelMotorVal(motorVal);
42 }
43
44 // Called repeatedly when this Command is scheduled to run
45 @Override
46 protected void execute() {
47 }
48
49 // Called once after isFinished returns true
50 @Override
51 protected void end() {
52 Robot.getShooter().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 timer.get() >= time;
65 }
66
67 }