203f9dce79a4eb3088eb1155e9e67dfa1fbac036
[3501/2017steamworks] / src / org / usfirst / frc / team3501 / robot / commands / shooter / RunFlyWheel.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 the fly wheel at a given speed for a given time. The fly
10 * wheel is intended to shoot balls fed by the intake wheel.
11 *
12 * @author Shaina
13 */
14 public class RunFlyWheel extends Command {
15 Timer timer;
16 private double motorVal;
17 private double time;
18
19 /**
20 * See JavaDoc comment in class for details
21 *
22 * @param motorVal
23 * value range from -1 to 1
24 * @param time
25 * in seconds, amount of time to run fly wheel motor
26 */
27 public RunFlyWheel(double motorVal, double time) {
28 requires(Robot.getShooter());
29
30 timer = new Timer();
31 this.motorVal = motorVal;
32 this.time = time;
33 }
34
35 // Called just before this Command runs the first time
36 @Override
37 protected void initialize() {
38 timer.start();
39 Robot.getShooter().setFlyWheelMotorVal(motorVal);
40 }
41
42 // Called repeatedly when this Command is scheduled to run
43 @Override
44 protected void execute() {
45 }
46
47 // Called once after isFinished returns true
48 @Override
49 protected void end() {
50 Robot.getShooter().stopFlyWheel();
51 }
52
53 // Called when another command which requires one or more of the same
54 // subsystems is scheduled to run
55 @Override
56 protected void interrupted() {
57 end();
58 }
59
60 @Override
61 protected boolean isFinished() {
62 return timer.get() >= time;
63 }
64
65 }