1 package org
.usfirst
.frc
.team3501
.robot
.subsystems
;
3 import org
.usfirst
.frc
.team3501
.robot
.Constants
;
4 import org
.usfirst
.frc
.team3501
.robot
.MathLib
;
5 import org
.usfirst
.frc
.team3501
.robot
.utils
.HallEffectSensor
;
7 import com
.ctre
.CANTalon
;
9 import edu
.wpi
.first
.wpilibj
.command
.Subsystem
;
11 public class Shooter
extends Subsystem
{
12 public double wheelP
= 0.0001, wheelI
= 0, wheelD
= 0.0004;
13 private static Shooter shooter
;
14 private static HallEffectSensor hallEffect
;
15 private final CANTalon flyWheel1
, flyWheel2
, indexWheel
;
17 private static final double DEFAULT_INDEXING_SPEED
= -0.75;
18 private static final double DEFAULT_SHOOTING_SPEED
= 2700; // rpm
19 private static final double SHOOTING_SPEED_INCREMENT
= 25;
21 private double currentShootingSpeed
= DEFAULT_SHOOTING_SPEED
;
24 flyWheel1
= new CANTalon(Constants
.Shooter
.FLY_WHEEL1
);
25 flyWheel2
= new CANTalon(Constants
.Shooter
.FLY_WHEEL2
);
26 indexWheel
= new CANTalon(Constants
.Shooter
.INDEX_WHEEL
);
28 hallEffect
= new HallEffectSensor(Constants
.Shooter
.HALL_EFFECT_PORT
, 1);
32 * Returns shooter object
34 * @return Shooter object
36 public static Shooter
getShooter() {
37 if (shooter
== null) {
38 shooter
= new Shooter();
44 * Sets fly wheel motor value to input.
47 * motor value from -1 to 1(fastest forward)
49 public void setFlyWheelMotorVal(double val
) {
50 val
= MathLib
.restrictToRange(val
, 0.0, 1.0);
56 * Stops fly wheel motor.
58 public void stopFlyWheel() {
64 * Sets index wheel motor value to input.
67 * motor value from -1 to 1(fastest forward)
69 public void setIndexWheelMotorVal(double val
) {
70 val
= MathLib
.restrictToRange(val
, -1.0, 1.0);
75 * Stops index wheel motor.
77 public void stopIndexWheel() {
82 protected void initDefaultCommand() {
86 public double getShooterRPM() {
87 return hallEffect
.getRPM();
90 public void setCurrentShootingSpeed(double Value
) {
91 currentShootingSpeed
= Value
;
94 public void decrementCurrentShootingSpeed() {
95 this.currentShootingSpeed
-= this.SHOOTING_SPEED_INCREMENT
;
98 public void incrementCurrentShootingSpeed() {
99 this.currentShootingSpeed
+= this.SHOOTING_SPEED_INCREMENT
;
102 public void resetCurrentShootingSpeed() {
103 this.currentShootingSpeed
= this.DEFAULT_SHOOTING_SPEED
;
106 public double getCurrentShootingSpeed() {
107 return currentShootingSpeed
;
110 public void reverseIndexWheel() {
111 this.setIndexWheelMotorVal(-DEFAULT_INDEXING_SPEED
);
114 public void runIndexWheel() {
115 this.setIndexWheelMotorVal(DEFAULT_INDEXING_SPEED
);