create and implement reset shooting speed command
[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);
c0860df7 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() {
5b1f2bc5 52 Robot.getShooter().stopIndexWheel();
c0860df7 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() {
5b1f2bc5 59 end();
c0860df7 60 }
61
62 @Override
63 protected boolean isFinished() {
5b1f2bc5 64 return timer.get() >= time;
c0860df7 65 }
809609c9 66
67}