code review changes
[3501/2017steamworks] / src / org / usfirst / frc / team3501 / robot / commands / shooter / RunFlyWheel.java
CommitLineData
809609c9 1package org.usfirst.frc.team3501.robot.commands.shooter;
2
414d5638 3import org.usfirst.frc.team3501.robot.Robot;
ad7e6b1e 4import org.usfirst.frc.team3501.robot.subsystems.Shooter;
cf77d84e 5import org.usfirst.frc.team3501.robot.utils.PIDController;
414d5638 6
809609c9 7import edu.wpi.first.wpilibj.command.Command;
8
9/**
7ba6bc91
CZ
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(...).
809609c9 18 *
cf77d84e 19 * @author Shaina & Chris
809609c9 20 */
21public class RunFlyWheel extends Command {
ad7e6b1e 22 private Shooter shooter = Robot.getShooter();
7ba6bc91 23 double time;
cf77d84e
CZ
24
25 private PIDController wheelController;
cf77d84e 26
7ba6bc91
CZ
27 public RunFlyWheel(double time) {
28 this.time = time;
493a4f87 29 }
30
7cd65a82 31 @Override
493a4f87 32 protected void initialize() {
7ba6bc91 33 shooter.initializePIDController();
493a4f87 34 }
35
7cd65a82 36 @Override
493a4f87 37 protected void execute() {
7ba6bc91 38 shooter.setFlyWheelMotorVal(shooter.calculateShooterSpeed());
cf77d84e
CZ
39 }
40
7cd65a82 41 @Override
cf77d84e 42 protected boolean isFinished() {
7ba6bc91 43 return timeSinceInitialized() >= time;
493a4f87 44 }
45
7cd65a82 46 @Override
493a4f87 47 protected void end() {
cf77d84e 48 this.shooter.stopFlyWheel();
493a4f87 49 }
50
7cd65a82 51 @Override
493a4f87 52 protected void interrupted() {
7ba6bc91 53 end();
493a4f87 54 }
809609c9 55}