competition fixes
[3501/2017steamworks] / src / org / usfirst / frc / team3501 / robot / subsystems / Intake.java
CommitLineData
0ceab9a4
M
1package org.usfirst.frc.team3501.robot.subsystems;
2
c9eb0d1c 3import org.usfirst.frc.team3501.robot.Constants;
ac77a7b8 4import org.usfirst.frc.team3501.robot.MathLib;
c9eb0d1c 5
dab6e7d6
AD
6import com.ctre.CANTalon;
7
0ceab9a4
M
8import edu.wpi.first.wpilibj.command.Subsystem;
9
dab6e7d6 10/**
0ceab9a4 11 * @author Meeta
0ceab9a4
M
12 */
13public class Intake extends Subsystem {
5868b2cf 14 private static Intake intake = null;
dab6e7d6 15 private CANTalon intakeWheel;
8e04baaf
CZ
16 public static final double INTAKE_SPEED = 1;
17 public static final double REVERSE_SPEED = -1;
0ceab9a4 18
dab6e7d6 19 public Intake() {
c9eb0d1c 20 intakeWheel = new CANTalon(Constants.Intake.INTAKE_ROLLER_PORT);
0ceab9a4
M
21 }
22
66b47d2c
AD
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 */
dab6e7d6
AD
29 public static Intake getIntake() {
30 if (intake == null) {
31 intake = new Intake();
32 }
33 return intake;
0ceab9a4
M
34 }
35
36 @Override
37 protected void initDefaultCommand() {
0ceab9a4
M
38
39 }
40
66b47d2c
AD
41 /***
42 * Sets speed of intake wheel to input speed
43 *
44 * @param speed
45 * from -1 to 1
46 */
f74d236d 47 public void setSpeed(double speed) {
ac77a7b8 48 speed = MathLib.restrictToRange(speed, -1.0, 1.0);
c9eb0d1c 49 intakeWheel.set(speed);
dab6e7d6
AD
50 }
51
5868b2cf
AD
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 */
1436824b 71 public void runReverseIntake() {
5868b2cf
AD
72 setSpeed(REVERSE_SPEED);
73 }
74
0ceab9a4 75}