package org.usfirst.frc.team3501.robot.subsystems;
-public class Shooter {
- public Shooter() {
+import org.usfirst.frc.team3501.robot.Constants;
+import org.usfirst.frc.team3501.robot.utils.HallEffectSensor;
- }
+import com.ctre.CANTalon;
- public void stopFlywheel() {
+import edu.wpi.first.wpilibj.command.Subsystem;
- }
+public class Shooter extends Subsystem {
+ private double wheelP = 0, wheelI = 0, wheelD = -0;
+ private static Shooter shooter;
+ private HallEffectSensor hallEffect;
+ private final CANTalon flyWheel1, flyWheel2, indexWheel;
- public void runFlywheel(double speed, double seconds) {
+ private static final double DEFAULT_INDEXING_SPEED = -0.75;
+ private static final double DEFAULT_SHOOTING_SPEED = 0.75;
+ private double currentShootingSpeed = DEFAULT_SHOOTING_SPEED;
- }
+ private static final double SHOOTING_SPEED_INCREMENT = 0.05;
- public void stopIndexWheel() {
+ private Shooter() {
+ flyWheel1 = new CANTalon(Constants.Shooter.FLY_WHEEL1);
+ flyWheel2 = new CANTalon(Constants.Shooter.FLY_WHEEL2);
+ indexWheel = new CANTalon(Constants.Shooter.INDEX_WHEEL);
- }
+ hallEffect = new HallEffectSensor(Constants.Shooter.HALL_EFFECT_PORT, 1);
+ }
- public void runIndexWheel(double speed, double seconds) {
+ /**
+ * Returns shooter object
+ *
+ * @return Shooter object
+ */
+ public static Shooter getShooter() {
+ if (shooter == null) {
+ shooter = new Shooter();
+ }
+ return shooter;
+ }
- }
+ /**
+ * Sets fly wheel motor value to input.
+ *
+ * @param val
+ * motor value from -1 to 1(fastest forward)
+ */
+ private void setFlyWheelMotorVal(final double val) {
+ flyWheel1.set(val);
+ flyWheel2.set(val);
+ }
- public void runFlywheelContinuous() {
+ public void incrementCurrentShootingSpeed() {
+ currentShootingSpeed += SHOOTING_SPEED_INCREMENT;
+ }
- }
+ public void runFlyWheel() {
+ flyWheel1.set(currentShootingSpeed);
+ }
- public void runIndexWheelContinuous() {
+ /**
+ * Stops fly wheel motor.
+ */
+ public void stopFlyWheel() {
+ flyWheel1.set(0);
+ flyWheel2.set(0);
+ }
+
+ /**
+ * Stops index wheel motor.
+ */
+ public void stopIndexWheel() {
+ indexWheel.set(0);
+ }
+
+ /**
+ * Run the index wheel forwards
+ */
+ public void runIndexWheelForward() {
+ indexWheel.set(currentShootingSpeed);
+ }
+
+ /**
+ * Run the index wheel backwards
+ */
+ public void runIndexWheelReverse() {
+ indexWheel.set(-currentShootingSpeed);
+ }
+
+ @Override
+ protected void initDefaultCommand() {
+
+ }
+
+ public double getShooterRPM() {
+ return hallEffect.getRPM();
+ }
+
+ public void decrementCurrentShootingSpeed() {
+ currentShootingSpeed -= SHOOTING_SPEED_INCREMENT;
+
+ }
+
+ public void resetCurrentShootingSpeed() {
+ currentShootingSpeed = DEFAULT_SHOOTING_SPEED;
+ }
+
+ /**
+ * @return the wheelP
+ */
+ public double getWheelP() {
+ return wheelP;
+ }
+
+ /**
+ * @return the wheelI
+ */
+ public double getWheelI() {
+ return wheelI;
+ }
+
+ /**
+ * @return the wheelD
+ */
+ public double getWheelD() {
+ return wheelD;
+ }
+
+ /**
+ * @return the currentShootingSpeed
+ */
+ public double getShootingSpeed() {
+ return currentShootingSpeed;
+ }
- }
}