f9c91d9b60007d07eb9cbed8c3e3f1d2af4cf155
[3501/stronghold-2016] / src / org / usfirst / frc / team3501 / robot / subsystems / DefenseArm.java
1 package org.usfirst.frc.team3501.robot.subsystems;
2
3 import org.usfirst.frc.team3501.robot.Constants;
4
5 import edu.wpi.first.wpilibj.AnalogPotentiometer;
6 import edu.wpi.first.wpilibj.CANTalon;
7 import edu.wpi.first.wpilibj.command.Subsystem;
8
9 public class DefenseArm extends Subsystem {
10 // Defense arm related objects
11 private AnalogPotentiometer defenseArmPotentiometer;
12 private AnalogPotentiometer defenseHandPotentiometer;
13 private CANTalon defenseArm;
14 private CANTalon defenseHand;
15 private double hookHeight;
16 private double footHeight;
17
18 private double[] potAngles = { 0, 45, 90 };
19
20 // array;
21
22 public DefenseArm() {
23 defenseArmPotentiometer = new AnalogPotentiometer(
24 Constants.DefenseArm.ARM_CHANNEL,
25 Constants.DefenseArm.FULL_RANGE,
26 Constants.DefenseArm.OFFSET);
27
28 defenseArm = new CANTalon(Constants.DefenseArm.ARM_PORT);
29 defenseHand = new CANTalon(Constants.DefenseArm.HAND_PORT);
30 }
31
32 public double getArmPotAngle() {
33 return defenseArmPotentiometer.get();
34 }
35
36 public double getHandPotAngle() {
37 return defenseHandPotentiometer.get();
38 }
39
40 /***
41 * This method sets the voltage of the arm motor. The range is from [-1,1]. A
42 * negative voltage makes the direction of the motor go backwards.
43 *
44 * @param speed
45 * The voltage that you set the motor at. The range of the voltage of
46 * the arm motor is from [-1,1]. A
47 * negative voltage makes the direction of the motor go backwards.
48 */
49
50 public void setArmSpeed(double speed) {
51 if (speed > 1)
52 speed = 1;
53 else if (speed < -1)
54 speed = -1;
55
56 defenseArm.set(speed);
57 }
58
59 /***
60 * This method sets the voltage of the hand motor. The range is from [-1,1]. A
61 * negative voltage makes the direction of the motor go backwards.
62 *
63 * @param speed
64 * The voltage that you set the motor at. The range of the voltage of
65 * the hand motor is from [-1,1]. A
66 * negative voltage makes the direction of the motor go backwards.
67 */
68
69 public void setHandSpeed(double speed) {
70 if (speed > 1)
71 speed = 1;
72 else if (speed < -1)
73 speed = -1;
74
75 defenseHand.set(speed);
76 }
77
78 @Override
79 protected void initDefaultCommand() {
80 }
81 }