fix merge conflicts
[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.AnalogPotentiometer;
6 import edu.wpi.first.wpilibj.CANTalon;
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 private CANTalon intakeRoller;
23 private CANTalon intakeArm;
24 private AnalogPotentiometer intakePot;
25 private double[] potAngles = { 0, 45, 90 };
26
27 public IntakeArm() {
28 intakeRoller = new CANTalon(Constants.IntakeArm.ROLLER_PORT);
29 intakeArm = new CANTalon(Constants.IntakeArm.ARM_PORT);
30 intakePot = new AnalogPotentiometer(Constants.IntakeArm.POT_CHANNEL, Constants.IntakeArm.FULL_RANGE,
31 Constants.IntakeArm.OFFSET);
32
33 }
34
35 /***
36 * This method sets the voltage of the motor to intake the ball. The voltage
37 * values are constants in Constants class
38 */
39 public void intakeBall() {
40 intakeRoller.set(Constants.IntakeArm.INTAKE_SPEED);
41 }
42
43 /***
44 * This method sets the voltage of the motor to output the ball. The voltage
45 * values are constants in Constants class
46 */
47 public void outputBall() {
48 intakeRoller.set(Constants.IntakeArm.OUTPUT_SPEED);
49 }
50
51 /***
52 * This method gets you the current voltage of the motor that controls the
53 * intake arm roller. The range of voltage is from [-1,1]. A negative
54 * voltage makes the motor run backwards.
55 *
56 * @return Returns the voltage of the motor that controls the roller. The
57 * range of the voltage goes from [-1,1]. A negative voltage
58 * indicates that the motor is running backwards.
59 */
60
61 public double getRollerVoltage() {
62 return intakeRoller.get();
63 }
64
65 /***
66 * This method sets the voltage of the arm motor. The range is from [-1,1].
67 * A negative voltage makes the direction of the motor go backwards.
68 *
69 * @param voltage
70 * The voltage that you set the motor at. The range of the
71 * voltage of the arm motor is from [-1,1]. A negative voltage
72 * makes the direction of the motor go backwards.
73 */
74
75 public void setArmSpeed(double voltage) {
76 if (voltage > 1)
77 voltage = 1;
78 else if (voltage < -1)
79 voltage = -1;
80
81 intakeArm.set(voltage);
82 }
83
84 /***
85 * This method gets you the current voltage of the motor that controls the
86 * intake arm. The range of voltage is from [-1,1]. A negative voltage makes
87 * the motor run backwards.
88 *
89 * @return Returns the voltage of the motor that controls the arm. The range
90 * of the voltage goes from [-1,1]. A negative voltage indicates
91 * that the motor is running backwards.
92 */
93
94 public double getArmSpeed() {
95 return intakeArm.get();
96 }
97
98 /***
99 * This method checks to see if the presence of the ball inside is true or
100 * false.
101 *
102 * @return Returns whether the ball is inside as true or false
103 */
104
105 public boolean isBallInside() {
106 return true;
107 }
108
109 /***
110 * This method checks to see if the motors controlling the rollers are
111 * currently running.
112 *
113 * @return Returns whether the motors are currently running, and returns the
114 * state of the condition (true or false).
115 *
116 */
117
118 public boolean areRollersRolling() {
119 return true;
120 }
121
122 /***
123 * This method gets the angle of the potentiometer on the Intake Arm.
124 *
125 * @return angle of potentiometer
126 */
127
128 public double getArmAngle() {
129 return intakePot.get() + Constants.IntakeArm.ZERO_ANGLE;
130 }
131
132 public void stop() {
133 setArmSpeed(0);
134 }
135
136 public double getAngleForLevel(double targetLevel) {
137 return potAngles[(int) (targetLevel - 1)];
138 }
139
140 @Override
141 protected void initDefaultCommand() {
142
143 }
144 }