809609c9 |
1 | package org.usfirst.frc.team3501.robot.commands.shooter; |
2 | |
414d5638 |
3 | import org.usfirst.frc.team3501.robot.Robot; |
4 | |
5 | import edu.wpi.first.wpilibj.Timer; |
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 { |
414d5638 |
15 | Timer timer; |
493a4f87 |
16 | private double motorVal; |
17 | private double time; |
18 | |
b7ef589a |
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 | */ |
493a4f87 |
27 | public RunFlyWheel(double motorVal, double time) { |
414d5638 |
28 | requires(Robot.getShooter()); |
29 | |
30 | timer = new Timer(); |
493a4f87 |
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() { |
414d5638 |
38 | timer.start(); |
39 | Robot.getShooter().setFlyWheelMotorVal(motorVal); |
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() { |
414d5638 |
50 | Robot.getShooter().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 | } |