1 <<<<<<< 41a8c498b73f7772d992078cea69ee5673d70668
2 package org
.usfirst
.frc
.team3501
.robot
.subsystems
;
4 import org
.usfirst
.frc
.team3501
.robot
.Constants
;
6 import edu
.wpi
.first
.wpilibj
.AnalogPotentiometer
;
7 import edu
.wpi
.first
.wpilibj
.CANTalon
;
8 import edu
.wpi
.first
.wpilibj
.command
.Subsystem
;
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
;
21 defenseArmPotentiometer
= new AnalogPotentiometer(
22 Constants
.DefenseArm
.ARM_CHANNEL
,
23 Constants
.DefenseArm
.FULL_RANGE
,
24 Constants
.DefenseArm
.OFFSET
);
26 defenseArm
= new CANTalon(Constants
.DefenseArm
.ARM_PORT
);
27 defenseHand
= new CANTalon(Constants
.DefenseArm
.HAND_PORT
);
30 public double getArmPotAngle() {
31 return defenseArmPotentiometer
.get();
34 public double getHandPotAngle() {
35 return defenseHandPotentiometer
.get();
38 public double getDistance(int desiredArmLocation
) {
39 return potAngles
[desiredArmLocation
];
42 public Double
[] putInValues() {
43 for (int i
= 0; i
< 3; i
++) {
44 potAngles
[i
] = (double) (45 * i
);
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.
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.
59 public void setArmSpeed(double speed
) {
65 defenseArm
.set(speed
);
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.
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.
78 public void setHandSpeed(double speed
) {
84 defenseHand
.set(speed
);
87 public void moveArmDown(int levelsToDegrees
) {
88 // to move arm down levels
89 if (levelsToDegrees
> 0 & levelsToDegrees
< 45) {
91 if (levelsToDegrees
> 45 & levelsToDegrees
< 90) {
98 public void moveArmTo(int levelsToDegrees
) {
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;
115 protected void initDefaultCommand() {
119 package org
.usfirst
.frc
.team3501
.robot
.subsystems
;
121 import org
.usfirst
.frc
.team3501
.robot
.Constants
;
123 import edu
.wpi
.first
.wpilibj
.AnalogPotentiometer
;
124 import edu
.wpi
.first
.wpilibj
.CANTalon
;
125 import edu
.wpi
.first
.wpilibj
.command
.Subsystem
;
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
;
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
144 // do we want to use a hashmap??
145 // angles at 0,45,90 (Potentiometer value readings)
148 public DefenseArm() {
149 defenseArmPotentiometer
= new AnalogPotentiometer(
150 Constants
.DefenseArm
.ARM_CHANNEL
, FULL_RANGE
, OFFSET
);
152 defenseArmMotor
= new CANTalon(Constants
.DefenseArm
.ARM_PORT
);
153 defenseHandMotor
= new CANTalon(Constants
.DefenseArm
.HAND_PORT
);
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
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
167 public double getHookHeight() {
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.
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
182 public double getFootHeight() {
189 protected void initDefaultCommand() {
192 >>>>>>> write methods getArmAngle and getHandAngle