code review changes
[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 import org.usfirst.frc.team3501.robot.subsystems.Shooter;
5 import org.usfirst.frc.team3501.robot.utils.PIDController;
6
7 import edu.wpi.first.wpilibj.command.Command;
8
9 /**
10 * This command runs the fly wheel continuously at a set speed using a PID
11 * Controller when OI button managing fly wheel is pressed. The command will run
12 * the fly wheel motor until the button triggering it is released.
13 *
14 * Should only be run from the operator interface.
15 *
16 * pre-condition: This command must be run by a button in OI, with
17 * button.whileHeld(...).
18 *
19 * @author Shaina & Chris
20 */
21 public class RunFlyWheel extends Command {
22 private Shooter shooter = Robot.getShooter();
23 double time;
24
25 private PIDController wheelController;
26
27 public RunFlyWheel(double time) {
28 this.time = time;
29 }
30
31 @Override
32 protected void initialize() {
33 shooter.initializePIDController();
34 }
35
36 @Override
37 protected void execute() {
38 shooter.setFlyWheelMotorVal(shooter.calculateShooterSpeed());
39 }
40
41 @Override
42 protected boolean isFinished() {
43 return timeSinceInitialized() >= time;
44 }
45
46 @Override
47 protected void end() {
48 this.shooter.stopFlyWheel();
49 }
50
51 @Override
52 protected void interrupted() {
53 end();
54 }
55 }