This repository has been archived by the owner on Jun 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AutoRedCV.java
237 lines (170 loc) · 9.28 KB
/
AutoRedCV.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
package org.firstinspires.ftc.teamcode;
import org.firstinspires.ftc.teamcode.libs.*;
import org.firstinspires.ftc.teamcode.libs.opmode.*;
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
import java.util.concurrent.Callable;
import org.firstinspires.ftc.robotcore.external.tfod.Recognition;
import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
import java.util.List;
@Autonomous
public class AutoRedCV extends AutoBase {
@Override
public void ringntAuto() {
// rotate to face the right side of the field
autoNav.goForTime(850, 0, 0, -1, 1f);
// give the robot a moment to come to a halt
(new TimedAutoTask(new Runnable() { public void run() {
}}, opModeActiveCallable, "Wait >:(", telemetry, 250)).run();
autoNav.goForTime(850, -1, -0.4f, 0, 0.5f);
// open the wobble goal claw
(new TimedAutoTask(new Runnable() { public void run() {
hardwareInterface.setWobbleGoalArm(RobotConfig.wobbleGoalDownEncoder, true);
}}, opModeActiveCallable, "Drop Wobble Goal", telemetry, 1000)).run();
hardwareInterface.setWobbleGoalArm(RobotConfig.wobbleGoalDownEncoder, false);
autoNav.goForTime(1500, 1, -0.5f, 0, 0.5f);
// raise the wobble goal arm
hardwareInterface.setWobbleGoalArm(RobotConfig.wobbleGoalUpEncoder, true);
}
@Override
public void singleAuto() {
// keep holding on to the wobble goal
hardwareInterface.setWobbleGoalArm(RobotConfig.wobbleGoalUpEncoder, true);
// drive sideways to be in front of the rings
autoNav.goForTime(850/*1000*/, 0, -1, 0, 0.7f);
// let the robot come to a halt
(new TimedAutoTask(new Runnable() { public void run() {
}}, opModeActiveCallable, "Wait >:(", telemetry, 100)).run();
// get the intake going and drive backwards to pick up 3 rings
hardwareInterface.fullIntake();
autoNav.goForTime(2250/*2000*/, -1, 0, 0, 0.4f/*0.5f*/);
// let the robot come to a halt
(new TimedAutoTask(new Runnable() { public void run() {
}}, opModeActiveCallable, "Wait >:(", telemetry, 100)).run();
// don't hold on to stuck rings -- run the intake roller backwards
hardwareInterface.reverseIntake();
// spin the shooter back up
//hardwareInterface.runShooter(shooterPower);
//hardwareInterface.setShooterRPM(RobotConfig.RPMInts[0]);
hardwareInterface.runShooter(0);
// drive diagonally to shooting spot
autoNav.goForTime(2000/*2250*/, 1, 0.5f, 0, 0.5f);
// open the shooter gate
(new TimedAutoTask(new Runnable() { public void run() {
hardwareInterface.setPusherPosition(0.2f);
}}, opModeActiveCallable, "Gate down", telemetry, 250)).run();
// push rings into the shooter -- shoot!
(new TimedAutoTask(new Runnable() { public void run() {
hardwareInterface.fullIntake();
}}, opModeActiveCallable, "Shoot", telemetry, 1250/*750*/)).run();
// stop shooting
hardwareInterface.stopIntake();
hardwareInterface.setPusherPosition(-1);
//hardwareInterface.runShooter(0f);
//hardwareInterface.setShooterRPM(0);
hardwareInterface.stopShooter();
// rotate to face the right side of the field
autoNav.goForTime(850, 0, 0, -1, 1f);
// give the robot a moment to come to a halt
(new TimedAutoTask(new Runnable() { public void run() {
}}, opModeActiveCallable, "Wait >:(", telemetry, 250)).run();
// partially lower the wobble goal arm while moving
(new TimedAutoTask(new Runnable() { public void run() {
hardwareInterface.setWobbleGoalArm(RobotConfig.wobbleGoalDownEncoder, true);
}}, opModeActiveCallable, "Drop Wobble Goal", telemetry, 1000)).run();
// drive left, towards the goal, to get to where the wobble goal goes
autoNav.goForTime(2150, 0.25f, -1, 0, 0.5f);
// raise the wobble goal arm
hardwareInterface.setWobbleGoalArm(RobotConfig.wobbleGoalDownEncoder, false);
autoNav.goForTime(900, 0.05f, 1, 0, 1);
hardwareInterface.setWobbleGoalArm(RobotConfig.wobbleGoalUpEncoder, true);
}
@Override
public void quadAuto() {
// keep holding on to the wobble goal
hardwareInterface.setWobbleGoalArm(RobotConfig.wobbleGoalUpEncoder, true);
// drive sideways to be in front of the rings
autoNav.goForTime(850/*1000*/, 0, -1, 0, 0.7f);
// let the robot come to a halt
(new TimedAutoTask(new Runnable() { public void run() {
}}, opModeActiveCallable, "Wait >:(", telemetry, 100)).run();
// get the intake going and drive backwards to pick up 3 rings
hardwareInterface.fullIntake();
autoNav.goForTime(2250/*2000*/, -1, 0, 0, 0.4f/*0.5f*/);
// let the robot come to a halt
(new TimedAutoTask(new Runnable() { public void run() {
}}, opModeActiveCallable, "Wait >:(", telemetry, 100)).run();
// don't hold on to stuck rings -- run the intake roller backwards
hardwareInterface.reverseIntake();
// spin the shooter back up
//hardwareInterface.runShooter(shooterPower);
//hardwareInterface.setShooterRPM(RobotConfig.RPMInts[0]);
hardwareInterface.runShooter(0);
// drive diagonally to shooting spot
autoNav.goForTime(2000/*2250*/, 1, 0.5f, 0, 0.5f);
// open the shooter gate
(new TimedAutoTask(new Runnable() { public void run() {
hardwareInterface.setPusherPosition(0.2f);
}}, opModeActiveCallable, "Gate down", telemetry, 250)).run();
// push rings into the shooter -- shoot!
(new TimedAutoTask(new Runnable() { public void run() {
hardwareInterface.fullIntake();
}}, opModeActiveCallable, "Shoot", telemetry, 1250/*750*/)).run();
// stop shooting
hardwareInterface.stopIntake();
hardwareInterface.setPusherPosition(-1);
//hardwareInterface.runShooter(0f);
//hardwareInterface.setShooterRPM(0);
hardwareInterface.stopShooter();
// rotate to face the right side of the field
autoNav.goForTime(800, 0, 0, -1, 1f);
// give the robot a moment to come to a halt
(new TimedAutoTask(new Runnable() { public void run() {
}}, opModeActiveCallable, "Wait >:(", telemetry, 250)).run();
// partially lower the wobble goal arm while moving
hardwareInterface.setWobbleGoalArm(RobotConfig.wobbleGoalMiddleEncoder, true);
// drive left, towards the goal, to get to where the wobble goal goes
autoNav.goForTime(2150, 0, -1, 0, 1);
// start lowering the wobble goal arm
hardwareInterface.setWobbleGoalArm(RobotConfig.wobbleGoalMiddleDownEncoder, true);
// drive forward away from the right wall slightly
autoNav.goForTime(750, -1, 0, 0, 0.5f);
// open the wobble goal claw
(new TimedAutoTask(new Runnable() { public void run() {
hardwareInterface.setWobbleGoalArm(RobotConfig.wobbleGoalMiddleDownEncoder, false);
}}, opModeActiveCallable, "Drop Wobble Goal", telemetry, 500)).run();
// raise the wobble goal arm
hardwareInterface.setWobbleGoalArm(RobotConfig.wobbleGoalUpEncoder, true);
autoNav.goForTime(2500, 0.5f, 1, 0, 0.75f);
}
@Override
public void globalAutoBegin() {
hardwareInterface.setWobbleGoalArm(RobotConfig.wobbleGoalUpEncoder, true);
// take out the backlash in the drivetrain
autoNav.goForTime(500, 1, 0, 0, 0.02f);
// start the shooter, so it is ready when we get to the line
hardwareInterface.runShooter(0);
// Drive forward to shooting position
autoNav.goForTime(1900, 1, 0, 0, 1f);
// let the robot come to a halt and the shooter settle on its speed
(new TimedAutoTask(new Runnable() { public void run() {
}}, opModeActiveCallable, "Wait >:(", telemetry, 250/*500*/)).run();
// open the shooter gate
(new TimedAutoTask(new Runnable() { public void run() {
hardwareInterface.setPusherPosition(0.2f);
}}, opModeActiveCallable, "Gate down", telemetry, 250)).run();
// push rings into the shooter -- shoot!
(new TimedAutoTask(new Runnable() { public void run() {
hardwareInterface.fullIntake();
}}, opModeActiveCallable, "Shoot", telemetry, 1350/*750*/)).run();
// stop shooting
hardwareInterface.stopIntake();
hardwareInterface.setPusherPosition(-1);
hardwareInterface.stopShooter();
}
@Override
public void globalAutoEnd() {
(new TimedAutoTask(new Runnable() { public void run() {
}}, opModeActiveCallable, "Wait >:(", telemetry, 750)).run();
hardwareInterface.stopShooter();
}
}