This repository has been archived by the owner on Sep 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
LiftLevel.java
83 lines (75 loc) · 2.32 KB
/
LiftLevel.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package org.firstinspires.ftc.teamcode;
import com.qualcomm.robotcore.hardware.Gamepad;
import java.util.concurrent.RunnableFuture;
public enum LiftLevel {
PICKUP, CARRY, DROP_1, DROP_3;
public static double level2Servo(LiftLevel level) {
switch (level) {
case PICKUP:
return 0.82; //0.81
case CARRY:
return 0.55;
case DROP_1: case DROP_3:
return 0.3; //we dont want this to drop until the player
//gives the drop command
default:
return 0.3;
}
}
public static double level2Motor(LiftLevel level) {
switch (level) {
case PICKUP:
return 0;
case CARRY:
return 403.275; //0.75*537.7
case DROP_1:
return 470.49;//940.975; //1.75*537.7
case DROP_3:
return 2688.5;
default: // this will never run, but exists because Javac is garbage at pattern matching
return 403.275;
}
}
public static LiftLevel downLevel(LiftLevel level) {
switch (level) {
case PICKUP: case CARRY:
return PICKUP;
case DROP_1: case DROP_3:
return CARRY;
}
// throw IllegalArgumentException;
return level;
}
public static LiftLevel upLevel(LiftLevel level, Gamepad gamepad) {
switch (level) {
case PICKUP:
return CARRY;
case CARRY:
if (gamepad.dpad_up) {return DROP_3;}
else if(gamepad.dpad_down) {return DROP_1;}
else {return level;}
// return DROP_1;
case DROP_1:
if (gamepad.dpad_down) {return DROP_1;}
else {return DROP_3;}
case DROP_3:
return DROP_3;
}
// throw IllegalArgumentException;
return level;
}
public String toString() {
switch (this) {
case PICKUP:
return "PICKUP";
case CARRY:
return "CARRY";
case DROP_1:
return "DROP_1";
case DROP_3:
return "DROP_3";
default:
return "bad value";
}
}
}