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 public static final double DEFAULT_INDEXING_SPEED
= -0.75;
18 public static final double DEFAULT_SHOOTING_SPEED
= 2700; // rpm
19 private static double CURRENT_SHOOTING_SPEED
= DEFAULT_SHOOTING_SPEED
;
21 public static final double SHOOTING_SPEED_INCREMENT
= 25;
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);
31 public static HallEffectSensor
getHallEffectSensor() {
36 * Returns shooter object
38 * @return Shooter object
40 public static Shooter
getShooter() {
41 if (shooter
== null) {
42 shooter
= new Shooter();
48 * Sets fly wheel motor value to input.
51 * motor value from -1 to 1(fastest forward)
53 public void setFlyWheelMotorVal(double val
) {
54 val
= MathLib
.restrictToRange(val
, 0.0, 1.0);
60 * Stops fly wheel motor.
62 public void stopFlyWheel() {
68 * Sets index wheel motor value to input.
71 * motor value from -1 to 1(fastest forward)
73 public void setIndexWheelMotorVal(double val
) {
74 val
= MathLib
.restrictToRange(val
, -1.0, 1.0);
79 * Stops index wheel motor.
81 public void stopIndexWheel() {
85 public double getCurrentShootingSpeed() {
86 return CURRENT_SHOOTING_SPEED
;
89 public void setCurrentShootingSpeed(double Value
) {
90 CURRENT_SHOOTING_SPEED
= Value
;
94 protected void initDefaultCommand() {
98 public double getShooterRPM() {
99 return hallEffect
.getRPM();