1 package org
.usfirst
.frc
.team3501
.robot
.subsystems
;
3 import org
.usfirst
.frc
.team3501
.robot
.Constants
;
4 import org
.usfirst
.frc
.team3501
.robot
.utils
.HallEffectSensor
;
6 import com
.ctre
.CANTalon
;
8 import edu
.wpi
.first
.wpilibj
.command
.Subsystem
;
10 public class Shooter
extends Subsystem
{
11 private double wheelP
= 0, wheelI
= 0, wheelD
= -0;
12 private static Shooter shooter
;
13 private HallEffectSensor hallEffect
;
14 private final CANTalon flyWheel1
, flyWheel2
, indexWheel
;
16 private static final double DEFAULT_INDEXING_SPEED
= -0.75;
17 private static final double DEFAULT_SHOOTING_SPEED
= 0.75;
18 private double currentShootingSpeed
= DEFAULT_SHOOTING_SPEED
;
20 private static final double SHOOTING_SPEED_INCREMENT
= 0.05;
23 flyWheel1
= new CANTalon(Constants
.Shooter
.FLY_WHEEL1
);
24 flyWheel2
= new CANTalon(Constants
.Shooter
.FLY_WHEEL2
);
25 indexWheel
= new CANTalon(Constants
.Shooter
.INDEX_WHEEL
);
27 hallEffect
= new HallEffectSensor(Constants
.Shooter
.HALL_EFFECT_PORT
, 1);
31 * Returns shooter object
33 * @return Shooter object
35 public static Shooter
getShooter() {
36 if (shooter
== null) {
37 shooter
= new Shooter();
43 * Sets fly wheel motor value to input.
46 * motor value from -1 to 1(fastest forward)
48 private void setFlyWheelMotorVal(final double val
) {
53 public void incrementCurrentShootingSpeed() {
54 currentShootingSpeed
+= SHOOTING_SPEED_INCREMENT
;
57 public void runFlyWheel() {
58 flyWheel1
.set(currentShootingSpeed
);
62 * Stops fly wheel motor.
64 public void stopFlyWheel() {
70 * Stops index wheel motor.
72 public void stopIndexWheel() {
77 * Run the index wheel forwards
79 public void runIndexWheelForward() {
80 indexWheel
.set(currentShootingSpeed
);
84 * Run the index wheel backwards
86 public void runIndexWheelReverse() {
87 indexWheel
.set(-currentShootingSpeed
);
91 protected void initDefaultCommand() {
95 public double getShooterRPM() {
96 return hallEffect
.getRPM();
99 public void decrementCurrentShootingSpeed() {
100 currentShootingSpeed
-= SHOOTING_SPEED_INCREMENT
;
104 public void resetCurrentShootingSpeed() {
105 currentShootingSpeed
= DEFAULT_SHOOTING_SPEED
;
111 public double getWheelP() {
118 public double getWheelI() {
125 public double getWheelD() {
130 * @return the currentShootingSpeed
132 public double getShootingSpeed() {
133 return currentShootingSpeed
;