Implement getter and setter methods for current shooting speed
[3501/2017steamworks] / src / org / usfirst / frc / team3501 / robot / commands / shooter / RunFlyWheelContinuous.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 RunFlyWheelContinuous extends Command {
22 private Shooter shooter = Robot.getShooter();
23
24 private PIDController wheelController;
25 private double wheelP;
26 private double wheelI;
27 private double wheelD;
28 private double target;
29
30 public RunFlyWheelContinuous() {
31 this.wheelP = this.shooter.wheelP;
32 this.wheelI = this.shooter.wheelI;
33 this.wheelD = this.shooter.wheelD;
34 this.wheelController = new PIDController(this.wheelP, this.wheelI,
35 this.wheelD);
36 this.wheelController.setDoneRange(0.5);
37 this.wheelController.setMaxOutput(1.0);
38 this.wheelController.setMinDoneCycles(3);
39 this.target = this.shooter.getCurrentShootingSpeed();
40 }
41
42 @Override
43 protected void initialize() {
44 this.wheelController.setSetPoint(this.target);
45 }
46
47 @Override
48 protected void execute() {
49 // double shooterSpeed = this.wheelController
50 // .calcPID(this.shooter.getShooterRPM());
51 //
52 // this.shooter.setFlyWheelMotorVal(shooterSpeed);
53 System.out.println(shooter.getShooterRPM());
54 this.shooter.setFlyWheelMotorVal(this.shooter.CURRENT_SHOOTING_SPEED);
55 }
56
57 @Override
58 protected boolean isFinished() {
59 return false;
60 }
61
62 @Override
63 protected void end() {
64 this.shooter.stopFlyWheel();
65 }
66
67 @Override
68 protected void interrupted() {
69 end();
70 }
71 }