069ea45fd34734dda4d53bf5c2c37fe42825d105
[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 // Defense arm specific constants that relate to the degrees per pulse value
19 // for the potentiometers
20 // private final static double PULSES_PER_ROTATION = 1; // in pulses
21
22 // array;
23
24 public DefenseArm() {
25 defenseArmPotentiometer = new AnalogPotentiometer(
26 Constants.DefenseArm.ARM_CHANNEL,
27 Constants.DefenseArm.FULL_RANGE,
28 Constants.DefenseArm.OFFSET);
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
42 /***
43 * This method sets the voltage of the arm motor. The range is from [-1,1]. A
44 * negative voltage makes the direction of the motor go backwards.
45 *
46 * @param speed
47 * The voltage that you set the motor at. The range of the voltage of
48 * the arm motor is from [-1,1]. A
49 * negative voltage makes the direction of the motor go backwards.
50 */
51
52 public void setArmSpeed(double speed) {
53 if (speed > 1)
54 speed = 1;
55 else if (speed < -1)
56 speed = -1;
57
58 defenseArm.set(speed);
59 }
60
61 /***
62 * This method sets the voltage of the hand motor. The range is from [-1,1]. A
63 * negative voltage makes the direction of the motor go backwards.
64 *
65 * @param speed
66 * The voltage that you set the motor at. The range of the voltage of
67 * the hand motor is from [-1,1]. A
68 * negative voltage makes the direction of the motor go backwards.
69 */
70
71 public void setHandSpeed(double speed) {
72 if (speed > 1)
73 speed = 1;
74 else if (speed < -1)
75 speed = -1;
76
77 defenseHand.set(speed);
78 }
79
80 @Override
81 protected void initDefaultCommand() {
82 }
83 }