Moderately streamline imports of constants
[3501/stronghold-2016] / src / org / usfirst / frc / team3501 / robot / subsystems / IntakeArm.java
1 package org.usfirst.frc.team3501.robot.subsystems;
2
3 import org.usfirst.frc.team3501.robot.Constants;
4
5 import edu.wpi.first.wpilibj.CANTalon;
6 import edu.wpi.first.wpilibj.DoubleSolenoid;
7 import edu.wpi.first.wpilibj.command.Subsystem;
8
9 /***
10 * The IntakeArm consists of two rollers that are controlled by one motor, with
11 * a potentiometer on it.
12 *
13 * The motor controls the rollers, making them roll forwards and backwards. The
14 * Intake rollers are on the back of the robot. As the rollers run, they intake
15 * the ball.
16 *
17 * @author superuser
18 *
19 */
20
21 public class IntakeArm extends Subsystem {
22
23 private CANTalon intakeRoller;
24 private DoubleSolenoid leftIntake, rightIntake;
25 public static double moveIntakeArmSpeed = 0;
26
27 public IntakeArm() {
28 intakeRoller = new CANTalon(Constants.IntakeArm.INTAKE_ROLLER_PORT);
29
30 leftIntake = new DoubleSolenoid(Constants.IntakeArm.LEFT_INTAKE_MODULE,
31 Constants.IntakeArm.LEFT_INTAKE_FORWARD,
32 Constants.IntakeArm.LEFT_INTAKE_REVERSE);
33
34 rightIntake = new DoubleSolenoid(Constants.IntakeArm.RIGHT_INTAKE_MODULE,
35 Constants.IntakeArm.RIGHT_INTAKE_FORWARD,
36 Constants.IntakeArm.RIGHT_INTAKE_REVERSE);
37 }
38
39 public void retractPistons() {
40 leftIntake.set(Constants.IntakeArm.RETRACT);
41 rightIntake.set(Constants.IntakeArm.RETRACT);
42 }
43
44 public void extendPistons() {
45 leftIntake.set(Constants.IntakeArm.EXTEND);
46 rightIntake.set(Constants.IntakeArm.EXTEND);
47 }
48
49 /***
50 * This method sets the voltage of the motor to intake the ball. The voltage
51 * values are constants in Constants class
52 */
53 public void intakeBall() {
54 intakeRoller.set(Constants.IntakeArm.INTAKE_SPEED);
55 }
56
57 /***
58 * This method sets the voltage of the motor to output the ball. The voltage
59 * values are constants in Constants class
60 */
61 public void outputBall() {
62 intakeRoller.set(Constants.IntakeArm.OUTPUT_SPEED);
63 }
64
65 public void stopRollers() {
66 intakeRoller.set(0);
67 }
68
69 /***
70 * This method gets you the current voltage of the motor that controls the
71 * intake arm roller. The range of voltage is from [-1,1]. A negative voltage
72 * makes the motor run backwards.
73 *
74 * @return Returns the voltage of the motor that controls the roller. The
75 * range of the voltage goes from [-1,1]. A negative voltage indicates
76 * that the motor is running backwards.
77 */
78
79 public double getRollerVoltage() {
80 return intakeRoller.get();
81 }
82
83 /***
84 * This method checks to see if the presence of the ball inside is true or
85 * false.
86 *
87 * @return Returns whether the ball is inside as true or false
88 */
89
90 public boolean isBallInside() {
91 return true;
92 }
93
94 /***
95 * This method checks to see if the motors controlling the rollers are
96 * currently running.
97 *
98 * @return Returns whether the motors are currently running, and returns the
99 * state of the condition (true or false).
100 *
101 */
102
103 public boolean areRollersRolling() {
104 if (Math.abs(getRollerVoltage()) < 0.02)
105 return false;
106 return true;
107 }
108
109 @Override
110 protected void initDefaultCommand() {
111
112 }
113 }