Commit | Line | Data |
---|---|---|
809609c9 | 1 | package org.usfirst.frc.team3501.robot.commands.shooter; |
2 | ||
414d5638 | 3 | import org.usfirst.frc.team3501.robot.Robot; |
ad7e6b1e | 4 | import org.usfirst.frc.team3501.robot.subsystems.Shooter; |
414d5638 | 5 | |
809609c9 | 6 | import edu.wpi.first.wpilibj.command.Command; |
7 | ||
8 | /** | |
973f0ac4 | 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. | |
809609c9 | 11 | * |
973f0ac4 | 12 | * @author Shaina |
809609c9 | 13 | */ |
14 | public class RunFlyWheel extends Command { | |
ad7e6b1e | 15 | private Shooter shooter = Robot.getShooter(); |
493a4f87 | 16 | private double time; |
17 | ||
b7ef589a | 18 | /** |
19 | * See JavaDoc comment in class for details | |
20 | * | |
21 | * @param motorVal | |
22 | * value range from -1 to 1 | |
23 | * @param time | |
24 | * in seconds, amount of time to run fly wheel motor | |
25 | */ | |
ad7e6b1e NA |
26 | public RunFlyWheel(double time) { |
27 | requires(shooter); | |
493a4f87 | 28 | this.time = time; |
29 | } | |
30 | ||
31 | // Called just before this Command runs the first time | |
32 | @Override | |
33 | protected void initialize() { | |
34 | } | |
35 | ||
36 | // Called repeatedly when this Command is scheduled to run | |
37 | @Override | |
38 | protected void execute() { | |
00f515a1 | 39 | shooter.setFlyWheelMotorVal(shooter.CURRENT_SHOOTING_SPEED); |
493a4f87 | 40 | } |
41 | ||
42 | // Called once after isFinished returns true | |
43 | @Override | |
44 | protected void end() { | |
ad7e6b1e | 45 | shooter.stopFlyWheel(); |
493a4f87 | 46 | } |
47 | ||
48 | // Called when another command which requires one or more of the same | |
49 | // subsystems is scheduled to run | |
50 | @Override | |
51 | protected void interrupted() { | |
414d5638 | 52 | end(); |
493a4f87 | 53 | } |
54 | ||
55 | @Override | |
56 | protected boolean isFinished() { | |
00f515a1 | 57 | return timeSinceInitialized() >= time; |
493a4f87 | 58 | } |
809609c9 | 59 | |
60 | } |