Commit | Line | Data |
---|---|---|
f11ce98e KZ |
1 | package org.usfirst.frc3501.RiceCatRobot.subsystems; |
2 | ||
3 | import org.usfirst.frc3501.RiceCatRobot.RobotMap; | |
4 | ||
5 | import edu.wpi.first.wpilibj.CANJaguar; | |
baf4f2ba | 6 | import edu.wpi.first.wpilibj.DigitalInput; |
f11ce98e KZ |
7 | import edu.wpi.first.wpilibj.command.Subsystem; |
8 | ||
9 | public class Arm extends Subsystem { | |
e3bfff96 | 10 | private CANJaguar left, right; |
c27e4d97 LM |
11 | private DigitalInput[] limits; |
12 | private int currentLevel; | |
e3bfff96 KZ |
13 | |
14 | public Arm() { | |
15 | left = new CANJaguar(RobotMap.ARM_LEFT); | |
16 | right = new CANJaguar(RobotMap.ARM_RIGHT); | |
c27e4d97 LM |
17 | limits = new DigitalInput[RobotMap.NUM_LIMITS]; |
18 | currentLevel = 0; | |
e3bfff96 KZ |
19 | } |
20 | ||
21 | public void initDefaultCommand() { | |
22 | } | |
c27e4d97 LM |
23 | |
24 | public void initializeArrayValues() { | |
25 | for (int i = 0; i < RobotMap.NUM_LIMITS; i++) { | |
26 | limits[i] = new DigitalInput(i); | |
27 | } | |
28 | } | |
e3bfff96 KZ |
29 | |
30 | public void fineTuneControl(double d) { | |
31 | if (Math.abs(d) < 0.05) { | |
32 | d = 0; | |
33 | } else if (d > 0) { | |
34 | d *= d; | |
35 | } else { | |
36 | d *= -d; | |
f11ce98e | 37 | } |
e3bfff96 KZ |
38 | setArmSpeeds(d); |
39 | } | |
40 | ||
41 | public void setLeft(double speed) { | |
42 | left.set(-speed); | |
43 | } | |
44 | ||
45 | public void setRight(double speed) { | |
46 | right.set(-speed); | |
47 | } | |
48 | ||
49 | public void setArmSpeeds(double speed) { | |
50 | setLeft(speed); | |
51 | setRight(speed); | |
52 | } | |
53 | ||
54 | public void stop() { | |
55 | left.set(0); | |
56 | right.set(0); | |
57 | } | |
c27e4d97 LM |
58 | |
59 | public void updateLimitStates() { | |
60 | for (int i = 0; i < RobotMap.NUM_LIMITS; i++) { | |
61 | if (limits[i].get() && i > currentLevel) currentLevel++; | |
62 | if (limits[i].get() && i <= currentLevel) currentLevel--; | |
63 | } | |
64 | } | |
65 | ||
66 | public int getCurrentLevel() { | |
67 | return currentLevel; | |
68 | } | |
b72e169c | 69 | } |