add constructor and potentiometer related constants in defense arm class
[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 private double[] potAngles = { 0, 45, 90 };
18
19 // array;
20
21 public DefenseArm() {
22 defenseArmPotentiometer = new AnalogPotentiometer(
23 Constants.DefenseArm.ARM_CHANNEL,
24 Constants.DefenseArm.FULL_RANGE,
25 Constants.DefenseArm.OFFSET);
26
27 defenseArm = new CANTalon(Constants.DefenseArm.ARM_PORT);
28 defenseHand = new CANTalon(Constants.DefenseArm.HAND_PORT);
29 }
30
31 public double getArmPotAngle() {
32 return defenseArmPotentiometer.get();
33 }
34
35 public double getHandPotAngle() {
36 return defenseHandPotentiometer.get();
37 }
38
39 /***
40 * This method sets the voltage of the arm motor. The range is from [-1,1]. A
41 * negative voltage makes the direction of the motor go backwards.
42 *
43 * @param speed
44 * The voltage that you set the motor at. The range of the voltage of
45 * the arm motor is from [-1,1]. A
46 * negative voltage makes the direction of the motor go backwards.
47 */
48
49 public void setArmSpeed(double speed) {
50 if (speed > 1)
51 speed = 1;
52 else if (speed < -1)
53 speed = -1;
54
55 defenseArm.set(speed);
56 }
57
58 /***
59 * This method sets the voltage of the hand motor. The range is from [-1,1]. A
60 * negative voltage makes the direction of the motor go backwards.
61 *
62 * @param speed
63 * The voltage that you set the motor at. The range of the voltage of
64 * the hand motor is from [-1,1]. A
65 * negative voltage makes the direction of the motor go backwards.
66 */
67
68 public void setHandSpeed(double speed) {
69 if (speed > 1)
70 speed = 1;
71 else if (speed < -1)
72 speed = -1;
73
74 defenseHand.set(speed);
75 }
76
77 @Override
78 protected void initDefaultCommand() {
79 }
80 }