-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJewelArm.java
65 lines (49 loc) · 1.5 KB
/
JewelArm.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
package org.firstinspires.ftc.teamcode.Subsystems;
import com.qualcomm.robotcore.hardware.ColorSensor;
import com.qualcomm.robotcore.hardware.HardwareMap;
import com.qualcomm.robotcore.hardware.Servo;
public class JewelArm {
public Servo armServo;
public ColorSensor jewelColor;
public boolean isUp = false;
double servoPosition;
private enum armServoStateEnum {Up, Down};
armServoStateEnum armServoState;
public JewelArm(String armServo, String jewelColor, HardwareMap hardwareMap) {
this.armServo = hardwareMap.servo.get(armServo);
this.jewelColor = hardwareMap.colorSensor.get(jewelColor);
this.up();
}
public void autoInit(){
armServo.setPosition(0.24);
}
public void up() {
armServo.setPosition(0.43);
armServoState = armServoStateEnum.Up;
isUp = true;
}
public void adjustUp(){
servoPosition = servoPosition + 0.01;
armServo.setPosition(servoPosition);
}
public void down() {
armServo.setPosition(0.84);
armServoState = armServoStateEnum.Down;
isUp = false;
}
public void adjustDown(){
servoPosition = servoPosition - 0.01;
armServo.setPosition(servoPosition);
}
@Override
public String toString() {
switch (armServoState) {
case Up:
return "Arm Up";
case Down:
return "Arm Down";
default:
return "unknown";
}
}
}