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
;
9 public class DefenseArm
extends Subsystem
{
10 private AnalogPotentiometer defenseArmPotentiometer
;
11 private AnalogPotentiometer defenseHandPotentiometer
;
12 private CANTalon defenseArm
;
13 private CANTalon defenseHand
;
14 private double hookHeight
;
15 private double footHeight
;
16 private double[] potAngles
;
17 // angles corresponding to pre-determined heights we will need
20 defenseArmPotentiometer
= new AnalogPotentiometer(
21 Constants
.DefenseArm
.ARM_CHANNEL
,
22 Constants
.DefenseArm
.FULL_RANGE
,
23 Constants
.DefenseArm
.OFFSET
);
24 defenseHandPotentiometer
= new AnalogPotentiometer(
25 Constants
.DefenseArm
.HAND_CHANNEL
,
26 Constants
.DefenseArm
.FULL_RANGE
,
27 Constants
.DefenseArm
.OFFSET
);
29 defenseArm
= new CANTalon(Constants
.DefenseArm
.ARM_PORT
);
30 defenseHand
= new CANTalon(Constants
.DefenseArm
.HAND_PORT
);
31 potAngles
= createPotArray();
34 public double getArmPotAngle() {
35 return defenseArmPotentiometer
.get();
38 public double getHandPotAngle() {
39 return defenseHandPotentiometer
.get();
43 * This method takes an arm location as input (range of [0,2])
44 * Returns the angle of the arm corresponding to that arm location
46 * @param desiredArmLocation
47 * takes an arm location ranging from [0,2]
48 * 0 is the lowest position of arm
49 * 2 is the highest position of arm
51 * the angle of the arm corresponding to that arm location
53 public double getAngleForLocation(int desiredArmLocation
) {
54 return potAngles
[desiredArmLocation
];
57 public double[] createPotArray() {
58 double[] arr
= new double[3];
60 for (int i
= 0; i
< 3; i
++) {
67 * This method sets the voltage of the arm motor. The range is from [-1,1]. A
68 * negative voltage makes the direction of the motor go backwards.
71 * The voltage that you set the motor at. The range of the voltage of
72 * the arm motor is from [-1,1]. A
73 * negative voltage makes the direction of the motor go backwards.
76 public void setArmSpeed(double speed
) {
82 defenseArm
.set(speed
);
86 * This method sets the voltage of the hand motor. The range is from [-1,1]. A
87 * negative voltage makes the direction of the motor go backwards.
90 * The voltage that you set the motor at. The range of the voltage of
91 * the hand motor is from [-1,1]. A
92 * negative voltage makes the direction of the motor go backwards.
95 public void setHandSpeed(double speed
) {
101 defenseHand
.set(speed
);
105 protected void initDefaultCommand() {