1 package org
.usfirst
.frc
.team3501
.robot
.subsystems
;
3 import org
.usfirst
.frc
.team3501
.robot
.Constants
;
5 import edu
.wpi
.first
.wpilibj
.AnalogPotentiometer
;
6 import edu
.wpi
.first
.wpilibj
.CANTalon
;
7 import edu
.wpi
.first
.wpilibj
.command
.Subsystem
;
10 * The IntakeArm consists of two rollers that are controlled by one motor, with
11 * a potentiometer on it.
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
21 public class IntakeArm
extends Subsystem
{
23 private CANTalon intakeRoller
;
24 private CANTalon intakeArm
;
25 private AnalogPotentiometer intakePot
;
26 private double[] potAngles
= { 0, 45, 90 };
29 intakeRoller
= new CANTalon(Constants
.IntakeArm
.ROLLER_PORT
);
30 intakeArm
= new CANTalon(Constants
.IntakeArm
.ARM_PORT
);
31 intakePot
= new AnalogPotentiometer(Constants
.IntakeArm
.POT_CHANNEL
,
32 Constants
.IntakeArm
.FULL_RANGE
, Constants
.IntakeArm
.OFFSET
);
36 * This method sets the voltage of the motor to intake the ball. The voltage
37 * values are constants in Constants class
39 public void intakeBall() {
40 intakeRoller
.set(Constants
.IntakeArm
.INTAKE_SPEED
);
44 * This method sets the voltage of the motor to output the ball. The voltage
45 * values are constants in Constants class
47 public void outputBall() {
48 intakeRoller
.set(Constants
.IntakeArm
.OUTPUT_SPEED
);
51 public void stopRollers() {
56 * This method gets you the current voltage of the motor that controls the
57 * intake arm roller. The range of voltage is from [-1,1]. A negative voltage
58 * makes the motor run backwards.
60 * @return Returns the voltage of the motor that controls the roller. The
61 * range of the voltage goes from [-1,1]. A negative voltage indicates
62 * that the motor is running backwards.
65 public double getRollerVoltage() {
66 return intakeRoller
.get();
70 * This method sets the voltage of the arm motor. The range is from [-1,1]. A
71 * negative voltage makes the direction of the motor go backwards.
74 * The voltage that you set the motor at. The range of the voltage of
75 * the arm motor is from [-1,1]. A negative voltage makes the
76 * direction of the motor go backwards.
79 public void setArmSpeed(double voltage
) {
82 else if (voltage
< -1)
85 intakeArm
.set(voltage
);
89 * This method gets you the current voltage of the motor that controls the
90 * intake arm. The range of voltage is from [-1,1]. A negative voltage makes
91 * the motor run backwards.
93 * @return Returns the voltage of the motor that controls the arm. The range
94 * of the voltage goes from [-1,1]. A negative voltage indicates that
95 * the motor is running backwards.
98 public double getArmSpeed() {
99 return intakeArm
.get();
103 * This method checks to see if the presence of the ball inside is true or
106 * @return Returns whether the ball is inside as true or false
109 public boolean isBallInside() {
114 * This method checks to see if the motors controlling the rollers are
117 * @return Returns whether the motors are currently running, and returns the
118 * state of the condition (true or false).
122 public boolean areRollersRolling() {
123 if (Math
.abs(getRollerVoltage()) < 0.02)
129 * This method gets the angle of the potentiometer on the Intake Arm.
131 * @return angle of potentiometer
134 public double getArmAngle() {
135 return intakePot
.get() + Constants
.IntakeArm
.ZERO_ANGLE
;
142 public double getAngleForLevel(double targetLevel
) {
143 return potAngles
[(int) (targetLevel
- 1)];
147 protected void initDefaultCommand() {