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; | |
7a25a687 E |
6 | import edu.wpi.first.wpilibj.Counter; |
7 | import edu.wpi.first.wpilibj.DigitalInput; | |
f11ce98e KZ |
8 | import edu.wpi.first.wpilibj.command.Subsystem; |
9 | ||
10 | public class Arm extends Subsystem { | |
7a25a687 E |
11 | private CANJaguar left, right; |
12 | double speedOfArm = 0.0; | |
e3bfff96 | 13 | |
7a25a687 E |
14 | DigitalInput[] limitSwitches = new DigitalInput[3]; |
15 | Counter[] counters = new Counter[3]; | |
e3bfff96 | 16 | |
7a25a687 E |
17 | public Arm() { |
18 | left = new CANJaguar(RobotMap.ARM_LEFT); | |
19 | right = new CANJaguar(RobotMap.ARM_RIGHT); | |
17f99e2c E |
20 | |
21 | setDigitalInputValues(); | |
22 | setCountersCorrespondingToSwitches(); | |
7a25a687 | 23 | } |
e3bfff96 | 24 | |
7a25a687 E |
25 | public void setDigitalInputValues() { |
26 | limitSwitches[0] = new DigitalInput(0); | |
27 | limitSwitches[1] = new DigitalInput(1); | |
28 | limitSwitches[2] = new DigitalInput(2); | |
29 | } | |
e3bfff96 | 30 | |
7a25a687 E |
31 | public void setCountersCorrespondingToSwitches() { |
32 | counters[0] = new Counter(0); | |
33 | counters[1] = new Counter(1); | |
34 | counters[3] = new Counter(2); | |
35 | } | |
e3bfff96 | 36 | |
7a25a687 E |
37 | public double getArmSpeed() { |
38 | return this.speedOfArm; | |
e3bfff96 KZ |
39 | } |
40 | ||
7a25a687 E |
41 | public boolean isSwitch1Hit() { |
42 | return counters[0].get() > 0; | |
43 | } | |
e3bfff96 | 44 | |
7a25a687 E |
45 | public boolean isSwitch2Hit() { |
46 | return counters[1].get() > 0; | |
47 | } | |
48 | ||
49 | public boolean isSwitch3Hit() { | |
50 | return counters[2].get() > 0; | |
51 | } | |
52 | ||
53 | public void initializeCounters() { | |
54 | for (int i = 0; i < counters.length; i++) { | |
55 | counters[i].reset(); | |
56 | } | |
57 | } | |
58 | ||
59 | public void initDefaultCommand() { | |
60 | } | |
61 | ||
62 | public void fineTuneControl(double d) { | |
63 | if (Math.abs(d) < 0.05) { | |
64 | d = 0; | |
65 | } else if (d > 0) { | |
66 | d *= d; | |
67 | } else { | |
68 | d *= -d; | |
69 | } | |
70 | setArmSpeeds(d); | |
71 | } | |
72 | ||
73 | public void setLeft(double speed) { | |
74 | left.set(-speed); | |
75 | } | |
76 | ||
77 | public void setRight(double speed) { | |
78 | right.set(-speed); | |
79 | } | |
80 | ||
81 | public void setArmSpeeds(double speed) { | |
82 | this.speedOfArm = speed; | |
83 | setLeft(speed); | |
84 | setRight(speed); | |
85 | } | |
86 | ||
87 | public void stop() { | |
88 | this.speedOfArm = 0.0; | |
89 | left.set(0); | |
90 | right.set(0); | |
91 | } | |
b72e169c | 92 | } |