Fix code to swap camera feed
[3501/2017steamworks] / src / org / usfirst / frc / team3501 / robot / subsystems / Intake.java
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 private int intakeCameraFeed = 1;
20
21 public Intake() {
22 intakeWheel = new CANTalon(Constants.Intake.INTAKE_ROLLER_PORT);
23 }
24
25 /***
26 * It gets the intake instance, and if intake has not been initialized, then
27 * it will be initialized.
28 *
29 * @returns intake
30 */
31 public static Intake getIntake() {
32 if (intake == null) {
33 intake = new Intake();
34 }
35 return intake;
36 }
37
38 @Override
39 protected void initDefaultCommand() {
40
41 }
42
43 /***
44 * Sets speed of intake wheel to input speed
45 *
46 * @param speed
47 * from -1 to 1
48 */
49 private void setSpeed(double speed) {
50 speed = MathLib.restrictToRange(speed, -1.0, 1.0);
51 intakeWheel.set(speed);
52 }
53
54 /***
55 * Runs the intake wheel at the set intake speed.
56 */
57 public void runIntake() {
58 setSpeed(INTAKE_SPEED);
59 }
60
61 /***
62 * Stops the intake wheel by setting intake wheel's speed to 0.
63 */
64 public void stopIntake() {
65 setSpeed(0);
66 }
67
68 public int getIntakeCameraFeed() {
69 return this.intakeCameraFeed;
70 }
71
72 public void setIntakeCameraFeed(int intakeCamFeed) {
73 this.intakeCameraFeed = intakeCamFeed;
74 }
75
76 /***
77 * Purpose is to release all balls from the ball container to the outside of
78 * the robot. Reverses intake wheel by setting wheel speed to reverse speed.
79 *
80 */
81 public void runReverseIntake() {
82 setSpeed(REVERSE_SPEED);
83 }
84
85 }