Fix some errors
[3501/stronghold-2016] / src / org / usfirst / frc / team3501 / robot / subsystems / DefenseArm.java
CommitLineData
d6c9c0f4
KZ
1package org.usfirst.frc.team3501.robot.subsystems;
2
3import org.usfirst.frc.team3501.robot.Constants;
4
5import edu.wpi.first.wpilibj.AnalogPotentiometer;
6import edu.wpi.first.wpilibj.CANTalon;
7import edu.wpi.first.wpilibj.command.Subsystem;
8
9public class DefenseArm extends Subsystem {
d6c9c0f4
KZ
10 private AnalogPotentiometer defenseArmPotentiometer;
11 private AnalogPotentiometer defenseHandPotentiometer;
12 private CANTalon defenseArm;
13 private CANTalon defenseHand;
14 private double hookHeight;
15 private double footHeight;
28ad5f35
KZ
16 private double[] potAngles = { 0, 45, 90 };
17
1d110d2f 18 // angles corresponding to pre-determined heights we will need
d6c9c0f4
KZ
19
20 public DefenseArm() {
21 defenseArmPotentiometer = new AnalogPotentiometer(
22 Constants.DefenseArm.ARM_CHANNEL,
23 Constants.DefenseArm.FULL_RANGE,
24 Constants.DefenseArm.OFFSET);
1d110d2f
SC
25 defenseHandPotentiometer = new AnalogPotentiometer(
26 Constants.DefenseArm.HAND_CHANNEL,
27 Constants.DefenseArm.FULL_RANGE,
28 Constants.DefenseArm.OFFSET);
d6c9c0f4
KZ
29
30 defenseArm = new CANTalon(Constants.DefenseArm.ARM_PORT);
31 defenseHand = new CANTalon(Constants.DefenseArm.HAND_PORT);
32 }
33
34 public double getArmPotAngle() {
35 return defenseArmPotentiometer.get();
36 }
37
38 public double getHandPotAngle() {
39 return defenseHandPotentiometer.get();
40 }
41
64f47e4f
SC
42 /***
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
45 *
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
50 * @return
51 * the angle of the arm corresponding to that arm location
52 */
28ad5f35
KZ
53 public double getLevelValue(int level) {
54 if (level >= potAngles.length)
55 return potAngles[level];
56 else
57 return 0;
90784ff2
YN
58 }
59
d6c9c0f4
KZ
60 /***
61 * This method sets the voltage of the arm motor. The range is from [-1,1]. A
62 * negative voltage makes the direction of the motor go backwards.
63 *
64 * @param speed
65 * The voltage that you set the motor at. The range of the voltage of
66 * the arm motor is from [-1,1]. A
67 * negative voltage makes the direction of the motor go backwards.
68 */
69
70 public void setArmSpeed(double speed) {
71 if (speed > 1)
72 speed = 1;
73 else if (speed < -1)
74 speed = -1;
75
76 defenseArm.set(speed);
77 }
78
79 /***
80 * This method sets the voltage of the hand motor. The range is from [-1,1]. A
81 * negative voltage makes the direction of the motor go backwards.
82 *
83 * @param speed
84 * The voltage that you set the motor at. The range of the voltage of
85 * the hand motor is from [-1,1]. A
86 * negative voltage makes the direction of the motor go backwards.
87 */
88
89 public void setHandSpeed(double speed) {
90 if (speed > 1)
91 speed = 1;
92 else if (speed < -1)
93 speed = -1;
94
95 defenseHand.set(speed);
96 }
97
98 @Override
99 protected void initDefaultCommand() {
100 }
101}