adf9b5f87e1c31e5ec717ce66d48820af7780c8c
[3501/stronghold-2016] / src / org / usfirst / frc / team3501 / robot / subsystems / DefenseArm.java
1 <<<<<<< 41a8c498b73f7772d992078cea69ee5673d70668
2 package org.usfirst.frc.team3501.robot.subsystems;
3
4 import org.usfirst.frc.team3501.robot.Constants;
5
6 import edu.wpi.first.wpilibj.AnalogPotentiometer;
7 import edu.wpi.first.wpilibj.CANTalon;
8 import edu.wpi.first.wpilibj.command.Subsystem;
9
10 public class DefenseArm extends Subsystem {
11 // Defense arm related objects
12 private AnalogPotentiometer defenseArmPotentiometer;
13 private AnalogPotentiometer defenseHandPotentiometer;
14 private CANTalon defenseArm;
15 private CANTalon defenseHand;
16 private double hookHeight;
17 private double footHeight;
18 private Double[] potAngles;
19
20 public DefenseArm() {
21 defenseArmPotentiometer = new AnalogPotentiometer(
22 Constants.DefenseArm.ARM_CHANNEL,
23 Constants.DefenseArm.FULL_RANGE,
24 Constants.DefenseArm.OFFSET);
25
26 defenseArm = new CANTalon(Constants.DefenseArm.ARM_PORT);
27 defenseHand = new CANTalon(Constants.DefenseArm.HAND_PORT);
28 }
29
30 public double getArmPotAngle() {
31 return defenseArmPotentiometer.get();
32 }
33
34 public double getHandPotAngle() {
35 return defenseHandPotentiometer.get();
36 }
37
38 public double getDistance(int desiredArmLocation) {
39 return potAngles[desiredArmLocation];
40 }
41
42 public Double[] putInValues() {
43 for (int i = 0; i < 3; i++) {
44 potAngles[i] = (double) (45 * i);
45 }
46 return potAngles;
47 }
48
49 /***
50 * This method sets the voltage of the arm motor. The range is from [-1,1]. A
51 * negative voltage makes the direction of the motor go backwards.
52 *
53 * @param speed
54 * The voltage that you set the motor at. The range of the voltage of
55 * the arm motor is from [-1,1]. A
56 * negative voltage makes the direction of the motor go backwards.
57 */
58
59 public void setArmSpeed(double speed) {
60 if (speed > 1)
61 speed = 1;
62 else if (speed < -1)
63 speed = -1;
64
65 defenseArm.set(speed);
66 }
67
68 /***
69 * This method sets the voltage of the hand motor. The range is from [-1,1]. A
70 * negative voltage makes the direction of the motor go backwards.
71 *
72 * @param speed
73 * The voltage that you set the motor at. The range of the voltage of
74 * the hand motor is from [-1,1]. A
75 * negative voltage makes the direction of the motor go backwards.
76 */
77
78 public void setHandSpeed(double speed) {
79 if (speed > 1)
80 speed = 1;
81 else if (speed < -1)
82 speed = -1;
83
84 defenseHand.set(speed);
85 }
86
87 public void moveArmDown(int levelsToDegrees) {
88 // to move arm down levels
89 if (levelsToDegrees > 0 & levelsToDegrees < 45) {
90 levelsToDegrees = 0;
91 if (levelsToDegrees > 45 & levelsToDegrees < 90) {
92 levelsToDegrees = 45;
93
94 }
95 }
96 }
97
98 public void moveArmTo(int levelsToDegrees) {
99
100 }
101
102 public void moveArmUp(int levelsToDegrees) {
103 // to move arm up levels
104 if (levelsToDegrees < 45 & levelsToDegrees > 0) {
105 levelsToDegrees = 45;
106 if (levelsToDegrees < 90 & levelsToDegrees > 45) {
107 levelsToDegrees = 90;
108
109 }
110
111 }
112 }
113
114 @Override
115 protected void initDefaultCommand() {
116 }
117 }
118 =======
119 package org.usfirst.frc.team3501.robot.subsystems;
120
121 import org.usfirst.frc.team3501.robot.Constants;
122
123 import edu.wpi.first.wpilibj.AnalogPotentiometer;
124 import edu.wpi.first.wpilibj.CANTalon;
125 import edu.wpi.first.wpilibj.command.Subsystem;
126
127 public class DefenseArm extends Subsystem {
128 // Defense arm related objects
129 public AnalogPotentiometer defenseArmPotentiometer;
130 public CANTalon defenseArmMotor;
131 public CANTalon defenseHandMotor;
132 public double hookHeight;
133 public double footHeight;
134
135 // Defense arm specific constants that relate to the degrees per pulse value
136 // for the potentiometers
137 // private final static double PULSES_PER_ROTATION = 1; // in pulses
138 public final static double FULL_RANGE = 270.0; // in degrees
139 public final static double OFFSET = -135.0; // in degrees
140 public final static double[] armPotValue = { 0.0, 45.0, 90.0 }; // 3 level
141
142 // array;
143
144 // do we want to use a hashmap??
145 // angles at 0,45,90 (Potentiometer value readings)
146 // degrees
147
148 public DefenseArm() {
149 defenseArmPotentiometer = new AnalogPotentiometer(
150 Constants.DefenseArm.ARM_CHANNEL, FULL_RANGE, OFFSET);
151
152 defenseArmMotor = new CANTalon(Constants.DefenseArm.ARM_PORT);
153 defenseHandMotor = new CANTalon(Constants.DefenseArm.HAND_PORT);
154 }
155
156 /***
157 * <<<<<<< Updated upstream This method gets the height of the hook from the
158 * ground. The hook is attached to the end of the hand, which is attached to
159 * the arm.
160 *
161 * @return hookHeight gets height of hook from ground. The hook is attached to
162 * the end of the hand, which is attached the arm. The height is in
163 * inches.
164 *
165 */
166
167 public double getHookHeight() {
168
169 return hookHeight;
170 }
171
172 /***
173 * This method gets the height of the foot from the ground. The foot is
174 * attached to the end of the hand, which is attached to the arm.
175 *
176 * @return footHeight gets height of foot from ground. The foot is attached to
177 * the end of the hand, which is attached the arm. The height is in
178 * inches.
179 *
180 */
181
182 public double getFootHeight() {
183
184 return footHeight;
185
186 }
187
188 @Override
189 protected void initDefaultCommand() {
190 }
191 }
192 >>>>>>> write methods getArmAngle and getHandAngle