Commit | Line | Data |
---|---|---|
d6c9c0f4 KZ |
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; | |
82581dd6 | 17 | private Double[] potAngles; |
d6c9c0f4 KZ |
18 | |
19 | public DefenseArm() { | |
20 | defenseArmPotentiometer = new AnalogPotentiometer( | |
21 | Constants.DefenseArm.ARM_CHANNEL, | |
22 | Constants.DefenseArm.FULL_RANGE, | |
23 | Constants.DefenseArm.OFFSET); | |
24 | ||
25 | defenseArm = new CANTalon(Constants.DefenseArm.ARM_PORT); | |
26 | defenseHand = new CANTalon(Constants.DefenseArm.HAND_PORT); | |
27 | } | |
28 | ||
29 | public double getArmPotAngle() { | |
30 | return defenseArmPotentiometer.get(); | |
31 | } | |
32 | ||
33 | public double getHandPotAngle() { | |
34 | return defenseHandPotentiometer.get(); | |
35 | } | |
36 | ||
90784ff2 YN |
37 | public double getDistance(int desiredArmLocation) { |
38 | return potAngles[desiredArmLocation]; | |
39 | } | |
40 | ||
41 | public Double[] putInValues() { | |
42 | for (int i = 0; i < 3; i++) { | |
43 | potAngles[i] = (double) (45 * i); | |
44 | } | |
45 | return potAngles; | |
46 | } | |
47 | ||
d6c9c0f4 KZ |
48 | /*** |
49 | * This method sets the voltage of the arm motor. The range is from [-1,1]. A | |
50 | * negative voltage makes the direction of the motor go backwards. | |
51 | * | |
52 | * @param speed | |
53 | * The voltage that you set the motor at. The range of the voltage of | |
54 | * the arm motor is from [-1,1]. A | |
55 | * negative voltage makes the direction of the motor go backwards. | |
56 | */ | |
57 | ||
58 | public void setArmSpeed(double speed) { | |
59 | if (speed > 1) | |
60 | speed = 1; | |
61 | else if (speed < -1) | |
62 | speed = -1; | |
63 | ||
64 | defenseArm.set(speed); | |
65 | } | |
66 | ||
67 | /*** | |
68 | * This method sets the voltage of the hand motor. The range is from [-1,1]. A | |
69 | * negative voltage makes the direction of the motor go backwards. | |
70 | * | |
71 | * @param speed | |
72 | * The voltage that you set the motor at. The range of the voltage of | |
73 | * the hand motor is from [-1,1]. A | |
74 | * negative voltage makes the direction of the motor go backwards. | |
75 | */ | |
76 | ||
77 | public void setHandSpeed(double speed) { | |
78 | if (speed > 1) | |
79 | speed = 1; | |
80 | else if (speed < -1) | |
81 | speed = -1; | |
82 | ||
83 | defenseHand.set(speed); | |
84 | } | |
85 | ||
86 | @Override | |
87 | protected void initDefaultCommand() { | |
88 | } | |
89 | } |