1 package org
.usfirst
.frc
.team3501
.robot
.commands
.shooter
;
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
;
7 import edu
.wpi
.first
.wpilibj
.command
.Command
;
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.
14 * Should only be run from the operator interface.
16 * pre-condition: This command must be run by a button in OI, with
17 * button.whileHeld(...).
19 * @author Shaina & Chris
21 public class RunFlyWheelContinuous
extends Command
{
22 private Shooter shooter
= Robot
.getShooter();
24 private PIDController wheelController
;
25 private double wheelP
;
26 private double wheelI
;
27 private double wheelD
;
28 private double target
;
30 public RunFlyWheelContinuous() {
31 // Use requires() here to declare subsystem dependencies
32 // eg. requires(chassis);
34 this.wheelP
= this.shooter
.wheelP
;
35 this.wheelI
= this.shooter
.wheelI
;
36 this.wheelD
= this.shooter
.wheelD
;
37 this.wheelController
= new PIDController(this.wheelP
, this.wheelI
,
39 this.wheelController
.setDoneRange(0.5);
40 this.wheelController
.setMaxOutput(1.0);
41 this.wheelController
.setMinDoneCycles(3);
42 this.target
= this.shooter
.CURRENT_SHOOTING_SPEED
;
45 // Called just before this Command runs the first time
47 protected void initialize() {
48 this.wheelController
.setSetPoint(this.target
);
51 // Called repeatedly when this Command is scheduled to run
53 protected void execute() {
54 double shooterSpeed
= this.wheelController
55 .calcPID(this.shooter
.getShooterRPM());
57 this.shooter
.setFlyWheelMotorVal(shooterSpeed
);
60 // Make this return true when this Command no longer needs to run execute()
62 protected boolean isFinished() {
66 // Called once after isFinished returns true
68 protected void end() {
69 this.shooter
.stopFlyWheel();
72 // Called when another command which requires one or more of the same
73 // subsystems is scheduled to run
75 protected void interrupted() {