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