| 1 | package org.usfirst.frc.team3501.robot.subsystems; |
| 2 | |
| 3 | import org.usfirst.frc.team3501.robot.Constants; |
| 4 | import org.usfirst.frc.team3501.robot.MathLib; |
| 5 | |
| 6 | import com.ctre.CANTalon; |
| 7 | |
| 8 | import edu.wpi.first.wpilibj.command.Subsystem; |
| 9 | |
| 10 | /** |
| 11 | * @author Meeta |
| 12 | */ |
| 13 | public class Intake extends Subsystem { |
| 14 | private static Intake intake = null; |
| 15 | private CANTalon intakeWheel; |
| 16 | public static final double INTAKE_SPEED = 1; |
| 17 | public static final double REVERSE_SPEED = -1; |
| 18 | |
| 19 | public Intake() { |
| 20 | intakeWheel = new CANTalon(Constants.Intake.INTAKE_ROLLER_PORT); |
| 21 | } |
| 22 | |
| 23 | /*** |
| 24 | * It gets the intake instance, and if intake has not been initialized, then |
| 25 | * it will be initialized. |
| 26 | * |
| 27 | * @returns intake |
| 28 | */ |
| 29 | public static Intake getIntake() { |
| 30 | if (intake == null) { |
| 31 | intake = new Intake(); |
| 32 | } |
| 33 | return intake; |
| 34 | } |
| 35 | |
| 36 | @Override |
| 37 | protected void initDefaultCommand() { |
| 38 | |
| 39 | } |
| 40 | |
| 41 | /*** |
| 42 | * Sets speed of intake wheel to input speed |
| 43 | * |
| 44 | * @param speed |
| 45 | * from -1 to 1 |
| 46 | */ |
| 47 | public void setSpeed(double speed) { |
| 48 | speed = MathLib.restrictToRange(speed, -1.0, 1.0); |
| 49 | intakeWheel.set(speed); |
| 50 | } |
| 51 | |
| 52 | /*** |
| 53 | * Runs the intake wheel at the set intake speed. |
| 54 | */ |
| 55 | public void runIntake() { |
| 56 | setSpeed(INTAKE_SPEED); |
| 57 | } |
| 58 | |
| 59 | /*** |
| 60 | * Stops the intake wheel by setting intake wheel's speed to 0. |
| 61 | */ |
| 62 | public void stopIntake() { |
| 63 | setSpeed(0); |
| 64 | } |
| 65 | |
| 66 | /*** |
| 67 | * Purpose is to release all balls from the ball container to the outside of |
| 68 | * the robot. Reverses intake wheel by setting wheel speed to reverse speed. |
| 69 | * |
| 70 | */ |
| 71 | public void runReverseIntake() { |
| 72 | setSpeed(REVERSE_SPEED); |
| 73 | } |
| 74 | |
| 75 | } |