-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRelicClaw.java
94 lines (74 loc) · 2.36 KB
/
RelicClaw.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
84
85
86
87
88
89
90
91
92
93
94
package org.firstinspires.ftc.teamcode.Subsystems;
import com.qualcomm.robotcore.hardware.HardwareMap;
import com.qualcomm.robotcore.hardware.Servo;
/**
* Created by John Paul Ashour on 11/15/2016.
*/
public class RelicClaw {
public Servo ClawServo1;
public Servo ClawServo2;
public Servo Pivot;
public boolean isOpen = false;
double claw1position;
double claw2position;
double pivotPosition;
private enum clawServoEnum {Open, Close}
clawServoEnum clawServoState = clawServoEnum.Close;
public RelicClaw(String clawServo1, String clawServo2, String pivotServo, HardwareMap hardwareMap) {
this.ClawServo1 = hardwareMap.servo.get(clawServo1);
this.ClawServo2 = hardwareMap.servo.get(clawServo2);
this.Pivot = hardwareMap.servo.get(pivotServo);
//this.grabRelic();
}
public void closeClaw(){
claw1position = claw1position + 0.01;
ClawServo1.setPosition(claw1position);
claw2position = claw2position + 0.01;
ClawServo2.setPosition(claw2position);
}
public void openClaw(){
claw1position = claw1position - 0.01;
ClawServo1.setPosition(claw1position);
claw2position = claw2position - 0.01;
ClawServo2.setPosition(claw2position);
}
public void grabRelic() {
ClawServo1.setPosition(0.9);
ClawServo2.setPosition(0.7);
clawServoState = clawServoEnum.Close;
isOpen = false;
}
public void releaseRelic() {
ClawServo1.setPosition(0.2);
ClawServo2.setPosition(0.2);
clawServoState = clawServoEnum.Open;
isOpen = true;
}
public void pivotClockwise(){
pivotPosition = pivotPosition +0.01;
Pivot.setPosition(pivotPosition);
}
public void pivotPosition1(){
pivotPosition = 0.17;
Pivot.setPosition(pivotPosition);
}
public void pivotPosition2(){
pivotPosition = 0.05;
Pivot.setPosition(pivotPosition);
}
public void pivotCounterclockwise(){
pivotPosition = pivotPosition -0.01;
Pivot.setPosition(pivotPosition);
}
@Override
public String toString() {
switch (clawServoState) {
case Open:
return "Claw Open";
case Close:
return "Claw Closed";
default:
return "unknown";
}
}
}