| 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 flyWheel, indexWheel; |
| 15 | |
| 16 | public static final double DEFAULT_INDEXING_SPEED = 0; |
| 17 | public static final double DEFAULT_SHOOTING_SPEED = 0; |
| 18 | public static double CURRENT_SHOOTING_SPEED = DEFAULT_SHOOTING_SPEED; |
| 19 | |
| 20 | public static final double SHOOTING_SPEED_INCREMENT = 0; |
| 21 | |
| 22 | private Shooter() { |
| 23 | flyWheel = new CANTalon(Constants.Shooter.FLY_WHEEL); |
| 24 | indexWheel = new CANTalon(Constants.Shooter.INDEX_WHEEL); |
| 25 | |
| 26 | hallEffect = new HallEffectSensor(Constants.Shooter.HALL_EFFECT_PORT, 1); |
| 27 | } |
| 28 | |
| 29 | public static HallEffectSensor getHallEffectSensor() { |
| 30 | return hallEffect; |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * Returns shooter object |
| 35 | * |
| 36 | * @return Shooter object |
| 37 | */ |
| 38 | public static Shooter getShooter() { |
| 39 | if (shooter == null) { |
| 40 | shooter = new Shooter(); |
| 41 | } |
| 42 | return shooter; |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * Sets fly wheel motor value to input. |
| 47 | * |
| 48 | * @param val |
| 49 | * motor value from -1 to 1(fastest forward) |
| 50 | */ |
| 51 | public void setFlyWheelMotorVal(final double val) { |
| 52 | flyWheel.set(val); |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Stops fly wheel motor. |
| 57 | */ |
| 58 | public void stopFlyWheel() { |
| 59 | flyWheel.set(0); |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * Sets index wheel motor value to input. |
| 64 | * |
| 65 | * @param val |
| 66 | * motor value from -1 to 1(fastest forward) |
| 67 | */ |
| 68 | public void setIndexWheelMotorVal(final double val) { |
| 69 | indexWheel.set(val); |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * Stops index wheel motor. |
| 74 | */ |
| 75 | public void stopIndexWheel() { |
| 76 | indexWheel.set(0); |
| 77 | } |
| 78 | |
| 79 | @Override |
| 80 | protected void initDefaultCommand() { |
| 81 | |
| 82 | } |
| 83 | |
| 84 | public double getShooterRPM() { |
| 85 | return hallEffect.getRPM(); |
| 86 | } |
| 87 | } |