implement ShootAtHighGoal and add some helper methods
[3501/stronghold-2016] / src / org / usfirst / frc / team3501 / robot / subsystems / IntakeArm.java
CommitLineData
7b11350e
KZ
1package org.usfirst.frc.team3501.robot.subsystems;
2
3import org.usfirst.frc.team3501.robot.Constants;
4
5import edu.wpi.first.wpilibj.CANTalon;
5cff8910 6import edu.wpi.first.wpilibj.DoubleSolenoid;
7b11350e
KZ
7import edu.wpi.first.wpilibj.command.Subsystem;
8
add57fee 9/***
1eb84222
SC
10 * The IntakeArm consists of two rollers that are controlled by one motor, with
11 * a potentiometer on it.
fee6b62e 12 *
dc394eb0
SG
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.
fee6b62e 16 *
add57fee 17 * @author superuser
fee6b62e 18 *
add57fee
YA
19 */
20
7b11350e 21public class IntakeArm extends Subsystem {
4e0d6389
LM
22
23 private CANTalon intakeRoller;
5cff8910 24 private DoubleSolenoid leftIntake, rightIntake;
54c588d9 25 public static double moveIntakeArmSpeed = 0;
4e0d6389
LM
26
27 public IntakeArm() {
a68e4347 28 intakeRoller = new CANTalon(Constants.IntakeArm.INTAKE_ROLLER_PORT);
5cff8910 29
a68e4347 30 leftIntake = new DoubleSolenoid(Constants.IntakeArm.LEFT_INTAKE_MODULE,
7988f380
HD
31 Constants.IntakeArm.LEFT_INTAKE_FORWARD,
32 Constants.IntakeArm.LEFT_INTAKE_REVERSE);
5cff8910 33
a68e4347 34 rightIntake = new DoubleSolenoid(Constants.IntakeArm.RIGHT_INTAKE_MODULE,
7988f380
HD
35 Constants.IntakeArm.RIGHT_INTAKE_FORWARD,
36 Constants.IntakeArm.RIGHT_INTAKE_REVERSE);
4e0d6389
LM
37 }
38
2781cca0
ME
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
fee6b62e
ME
49 public boolean isExtended() {
50 return (leftIntake.get() == Constants.IntakeArm.EXTEND
51 && rightIntake.get() == Constants.IntakeArm.EXTEND);
52 }
53
4e0d6389
LM
54 /***
55 * This method sets the voltage of the motor to intake the ball. The voltage
56 * values are constants in Constants class
57 */
58 public void intakeBall() {
59 intakeRoller.set(Constants.IntakeArm.INTAKE_SPEED);
60 }
61
62 /***
63 * This method sets the voltage of the motor to output the ball. The voltage
64 * values are constants in Constants class
65 */
66 public void outputBall() {
67 intakeRoller.set(Constants.IntakeArm.OUTPUT_SPEED);
68 }
69
2b65c91d 70 public void stopRollers() {
33141cdd 71 intakeRoller.set(0);
2b65c91d
LM
72 }
73
4e0d6389
LM
74 /***
75 * This method gets you the current voltage of the motor that controls the
76 * intake arm roller. The range of voltage is from [-1,1]. A negative voltage
77 * makes the motor run backwards.
fee6b62e 78 *
4e0d6389
LM
79 * @return Returns the voltage of the motor that controls the roller. The
80 * range of the voltage goes from [-1,1]. A negative voltage indicates
81 * that the motor is running backwards.
82 */
83
84 public double getRollerVoltage() {
85 return intakeRoller.get();
86 }
87
4e0d6389
LM
88 /***
89 * This method checks to see if the presence of the ball inside is true or
90 * false.
fee6b62e 91 *
4e0d6389
LM
92 * @return Returns whether the ball is inside as true or false
93 */
94
95 public boolean isBallInside() {
96 return true;
97 }
98
99 /***
100 * This method checks to see if the motors controlling the rollers are
101 * currently running.
fee6b62e 102 *
4e0d6389
LM
103 * @return Returns whether the motors are currently running, and returns the
104 * state of the condition (true or false).
fee6b62e 105 *
4e0d6389
LM
106 */
107
108 public boolean areRollersRolling() {
42c4c734
LM
109 if (Math.abs(getRollerVoltage()) < 0.02)
110 return false;
4e0d6389
LM
111 return true;
112 }
113
4e0d6389
LM
114 @Override
115 protected void initDefaultCommand() {
116
117 }
7b11350e 118}