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 | |
6 | import edu.wpi.first.wpilibj.Timer; | |
809609c9 | 7 | import edu.wpi.first.wpilibj.command.Command; |
8 | ||
9 | /** | |
973f0ac4 | 10 | * This command runs the fly wheel at a given speed for a given time. The fly |
11 | * wheel is intended to shoot balls fed by the intake wheel. | |
809609c9 | 12 | * |
973f0ac4 | 13 | * @author Shaina |
809609c9 | 14 | */ |
15 | public class RunFlyWheel extends Command { | |
ad7e6b1e | 16 | private Shooter shooter = Robot.getShooter(); |
414d5638 | 17 | Timer timer; |
493a4f87 | 18 | private double time; |
19 | ||
b7ef589a | 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 fly wheel motor | |
27 | */ | |
ad7e6b1e NA |
28 | public RunFlyWheel(double time) { |
29 | requires(shooter); | |
414d5638 | 30 | |
31 | timer = new Timer(); | |
493a4f87 | 32 | this.time = time; |
33 | } | |
34 | ||
35 | // Called just before this Command runs the first time | |
36 | @Override | |
37 | protected void initialize() { | |
414d5638 | 38 | timer.start(); |
ad7e6b1e | 39 | shooter.setFlyWheelMotorVal(shooter.CURRENT_SHOOTING_SPEED); |
493a4f87 | 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() { | |
ad7e6b1e | 50 | shooter.stopFlyWheel(); |
493a4f87 | 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() { | |
414d5638 | 57 | end(); |
493a4f87 | 58 | } |
59 | ||
60 | @Override | |
61 | protected boolean isFinished() { | |
414d5638 | 62 | return timer.get() >= time; |
493a4f87 | 63 | } |
809609c9 | 64 | |
65 | } |