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