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
.DoubleSolenoid
;
10 import edu
.wpi
.first
.wpilibj
.DoubleSolenoid
.Value
;
11 import edu
.wpi
.first
.wpilibj
.command
.Subsystem
;
13 public class Shooter
extends Subsystem
{
14 public double wheelP
= 0.0003, wheelI
= 0, wheelD
= -0.00004;
15 private static Shooter shooter
;
16 private static HallEffectSensor hallEffect
;
17 private final CANTalon flyWheel1
, flyWheel2
, indexWheel
;
19 public static final double DEFAULT_INDEXING_SPEED
= -1.0;
20 public static final double DEFAULT_SHOOTING_SPEED
= 0.75;
21 public static double CURRENT_SHOOTING_SPEED
= DEFAULT_SHOOTING_SPEED
;
23 public static final double SHOOTING_SPEED_INCREMENT
= 0.05;
25 private final DoubleSolenoid piston
;
28 flyWheel1
= new CANTalon(Constants
.Shooter
.FLY_WHEEL1
);
29 flyWheel2
= new CANTalon(Constants
.Shooter
.FLY_WHEEL2
);
30 indexWheel
= new CANTalon(Constants
.Shooter
.INDEX_WHEEL
);
32 hallEffect
= new HallEffectSensor(Constants
.Shooter
.HALL_EFFECT_PORT
, 1);
34 piston
= new DoubleSolenoid(Constants
.Shooter
.MODULE_NUMBER
,
35 Constants
.Shooter
.PISTON_FORWARD
, Constants
.Shooter
.PISTON_REVERSE
);
38 public static HallEffectSensor
getHallEffectSensor() {
43 * Returns shooter object
45 * @return Shooter object
47 public static Shooter
getShooter() {
48 if (shooter
== null) {
49 shooter
= new Shooter();
55 * Sets fly wheel motor value to input.
58 * motor value from -1 to 1(fastest forward)
60 public void setFlyWheelMotorVal(double val
) {
61 val
= MathLib
.restrictToRange(val
, 0.0, 1.0);
67 * Stops fly wheel motor.
69 public void stopFlyWheel() {
75 * Sets index wheel motor value to input.
78 * motor value from -1 to 1(fastest forward)
80 public void setIndexWheelMotorVal(double val
) {
81 val
= MathLib
.restrictToRange(val
, -1.0, 1.0);
86 * Stops index wheel motor.
88 public void stopIndexWheel() {
92 public double getCurrentShootingSpeed() {
93 return CURRENT_SHOOTING_SPEED
;
96 public void setCurrentShootingSpeed(double Value
) {
97 CURRENT_SHOOTING_SPEED
= Value
;
101 protected void initDefaultCommand() {
105 public double getShooterRPM() {
106 return hallEffect
.getRPM();
109 public Value
getPistonValue() {
113 public void setHighGear() {
114 changeGear(Constants
.Shooter
.HIGH_GEAR
);
117 public void setLowGear() {
118 changeGear(Constants
.Shooter
.LOW_GEAR
);
121 private void changeGear(DoubleSolenoid
.Value gear
) {