X-Git-Url: http://challenge-bot.com/repos/?a=blobdiff_plain;f=src%2Forg%2Fusfirst%2Ffrc%2Fteam3501%2Frobot%2Fsubsystems%2FShooter.java;h=b9ccb42dff3967cabcfd551a0d71bb7c1ca31ad9;hb=09e509d3b1f6e73a06d62e41c5a959e6eed2e5c6;hp=759a232e443617a67715c80ccc09c9fe6ff1e0cd;hpb=809609c90af820574d54545300485fd5e0ff85e7;p=3501%2F2017steamworks diff --git a/src/org/usfirst/frc/team3501/robot/subsystems/Shooter.java b/src/org/usfirst/frc/team3501/robot/subsystems/Shooter.java index 759a232..b9ccb42 100644 --- a/src/org/usfirst/frc/team3501/robot/subsystems/Shooter.java +++ b/src/org/usfirst/frc/team3501/robot/subsystems/Shooter.java @@ -1,59 +1,98 @@ package org.usfirst.frc.team3501.robot.subsystems; -public class Shooter { - public Shooter() { - - } - - /** - * Stops fly wheel - */ - public void stopFlywheel() { - - } - - /** - * Runs the fly wheel at a given speed in () for input time in seconds - * - * @param speed - * in () - * @param time - * in seconds - */ - public void runFlywheel(double speed, double time) { - - } - - /** - * Stops index wheel - */ - public void stopIndexWheel() { - - } - - /** - * Runs index wheel at a given speed in () for input time in seconds - * - * @param speed - * in () - * @param time - * in seconds - */ - public void runIndexWheel(double speed, double time) { - - } - - /** - * Runs fly wheel continuously until ________ - */ - public void runFlywheelContinuous() { - - } - - /** - * Runs index wheel continuously until ________ - */ - public void runIndexWheelContinuous() { - - } +import org.usfirst.frc.team3501.robot.Constants; +import org.usfirst.frc.team3501.robot.utils.HallEffectSensor; + +import com.ctre.CANTalon; + +import edu.wpi.first.wpilibj.command.Subsystem; + +public class Shooter extends Subsystem { + public double wheelP = 0, wheelI = 0, wheelD = -0; + private static Shooter shooter; + private static HallEffectSensor hallEffect; + private final CANTalon flyWheel1, flyWheel2, indexWheel; + + public static final double DEFAULT_INDEXING_SPEED = -0.75; + public static final double DEFAULT_SHOOTING_SPEED = 0.75; + public static double CURRENT_SHOOTING_SPEED = DEFAULT_SHOOTING_SPEED; + + public static final double SHOOTING_SPEED_INCREMENT = 0.05; + + 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 static HallEffectSensor getHallEffectSensor() { + return hallEffect; + } + + /** + * 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) + */ + public void setFlyWheelMotorVal(final double val) { + flyWheel1.set(val); + flyWheel2.set(val); + } + + /** + * Stops fly wheel motor. + */ + public void stopFlyWheel() { + flyWheel1.set(0); + flyWheel2.set(0); + } + + /** + * Sets index wheel motor value to input. + * + * @param val + * motor value from -1 to 1(fastest forward) + */ + public void setIndexWheelMotorVal(final double val) { + indexWheel.set(val); + } + + /** + * Stops index wheel motor. + */ + public void stopIndexWheel() { + indexWheel.set(0); + } + + public double getCurrentShootingSpeed() { + return CURRENT_SHOOTING_SPEED; + } + + public void setCurrentShootingSpeed(double Value) { + CURRENT_SHOOTING_SPEED = Value; + } + + @Override + protected void initDefaultCommand() { + + } + + public double getShooterRPM() { + return hallEffect.getRPM(); + } }