Implement getter and setter methods for current shooting speed
[3501/2017steamworks] / src / org / usfirst / frc / team3501 / robot / subsystems / Shooter.java
1 package org.usfirst.frc.team3501.robot.subsystems;
2
3 import org.usfirst.frc.team3501.robot.Constants;
4 import org.usfirst.frc.team3501.robot.utils.HallEffectSensor;
5
6 import com.ctre.CANTalon;
7
8 import edu.wpi.first.wpilibj.command.Subsystem;
9
10 public class Shooter extends Subsystem {
11 public double wheelP = 0, wheelI = 0, wheelD = -0;
12 private static Shooter shooter;
13 private static HallEffectSensor hallEffect;
14 private final CANTalon flyWheel1, flyWheel2, indexWheel;
15
16 public static final double DEFAULT_INDEXING_SPEED = -0.75;
17 public static final double DEFAULT_SHOOTING_SPEED = 0.75;
18 public static double CURRENT_SHOOTING_SPEED = DEFAULT_SHOOTING_SPEED;
19
20 public static final double SHOOTING_SPEED_INCREMENT = 0.05;
21
22 private Shooter() {
23 flyWheel1 = new CANTalon(Constants.Shooter.FLY_WHEEL1);
24 flyWheel2 = new CANTalon(Constants.Shooter.FLY_WHEEL2);
25 indexWheel = new CANTalon(Constants.Shooter.INDEX_WHEEL);
26
27 hallEffect = new HallEffectSensor(Constants.Shooter.HALL_EFFECT_PORT, 1);
28 }
29
30 public static HallEffectSensor getHallEffectSensor() {
31 return hallEffect;
32 }
33
34 /**
35 * Returns shooter object
36 *
37 * @return Shooter object
38 */
39 public static Shooter getShooter() {
40 if (shooter == null) {
41 shooter = new Shooter();
42 }
43 return shooter;
44 }
45
46 /**
47 * Sets fly wheel motor value to input.
48 *
49 * @param val
50 * motor value from -1 to 1(fastest forward)
51 */
52 public void setFlyWheelMotorVal(final double val) {
53 flyWheel1.set(val);
54 flyWheel2.set(val);
55 }
56
57 /**
58 * Stops fly wheel motor.
59 */
60 public void stopFlyWheel() {
61 flyWheel1.set(0);
62 flyWheel2.set(0);
63 }
64
65 /**
66 * Sets index wheel motor value to input.
67 *
68 * @param val
69 * motor value from -1 to 1(fastest forward)
70 */
71 public void setIndexWheelMotorVal(final double val) {
72 indexWheel.set(val);
73 }
74
75 /**
76 * Stops index wheel motor.
77 */
78 public void stopIndexWheel() {
79 indexWheel.set(0);
80 }
81
82 public double getCurrentShootingSpeed() {
83 return CURRENT_SHOOTING_SPEED;
84 }
85
86 public void setCurrentShootingSpeed(double Value) {
87 CURRENT_SHOOTING_SPEED = Value;
88 }
89
90 @Override
91 protected void initDefaultCommand() {
92
93 }
94
95 public double getShooterRPM() {
96 return hallEffect.getRPM();
97 }
98 }