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