Implement ReverseIndexWheel
[3501/2017steamworks] / src / org / usfirst / frc / team3501 / robot / commands / shooter / ReverseIndexWheel.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 reverses the index wheel at a given speed for given time in
10 * seconds.
11 *
12 * @author shivanighanta
13 */
14
15 public class ReverseIndexWheel extends Command {
16 Timer timer;
17 private double time;
18 private double motorVal;
19
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 */
28
29 public ReverseIndexWheel(double time, double motorVal) {
30 requires(Robot.getDriveTrain());
31 timer = new Timer();
32 this.time = time;
33 this.motorVal = motorVal;
34 }
35
36 @Override
37 protected void initialize() {
38 timer.start();
39
40 }
41
42 @Override
43 protected void execute() {
44 Robot.getShooter().setIndexWheelMotorVal(-motorVal);
45
46 }
47
48 @Override
49 protected boolean isFinished() {
50 return timer.get() >= time;
51 }
52
53 @Override
54 protected void end() {
55 Robot.getShooter().stopIndexWheel();
56
57 }
58
59 @Override
60 protected void interrupted() {
61 end();
62 }
63 }