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