This repository has been archived by the owner on Feb 18, 2019. It is now read-only.
forked from aerhoespace/lemonade
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauton.c
351 lines (337 loc) · 5.68 KB
/
auton.c
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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
#pragma platform(VEX)
#pragma competitionControl(Competition)
#pragma autonomousDuration(15)
#pragma userControlDuration(105)
/*-----------------------------------------------------------------------------*/
/*
/* Auton functions
/*
/*-----------------------------------------------------------------------------*/
// Drive
void autoDrive(int speed1, int speed2){
SetMotor(left1,speed1);
SetMotor(right1,speed2);
SetMotor(left2,speed1);
SetMotor(right2,speed2);
}
void driveStop(int time){
SetMotor(left1,0);
SetMotor(right1,0);
SetMotor(left2,0);
SetMotor(right2,0);
wait1Msec(time);
}
// Puncher
void autoShoot(int time){
SetMotor(puncher1,100);
SetMotor(puncher2,100);
SetMotor(puncher3,100);
wait1Msec(time);
}
void puncherStop(int time){
SetMotor(puncher1,0);
SetMotor(puncher2,0);
SetMotor(puncher3,0);
wait1Msec(time);
}
// Intake
void autoTake(int time){
SetMotor(intake1,127);
SetMotor(intake2,127);
wait1Msec(time);
}
void autoGive(int time){
SetMotor(intake1,-127);
SetMotor(intake2,-127);
wait1Msec(time);
}
void intakeStop(int time){
SetMotor(intake1,0);
SetMotor(intake2,0);
wait1Msec(time);
}
/*-----------------------------------------------------------------------------*/
/*
*/
/* Auton modes
/*
*/
/*-----------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------------*/
/* Red alliance
/*-----------------------------------------------------------------------------*/
// Blue flag side (+3)
void autonR1(){
// Start facing flags
// Forward slightly
autoDrive(127,127);{
}
wait1Msec(150);
driveStop(50);{
}
wait1Msec(50);
// Shoot top flag
autoShoot(1800);{
}
puncherStop(50);{
}
// Turn left slightly
autoDrive(0,127);{
}
wait1Msec(100);
driveStop(50);{
}
wait1Msec(50);
// Drive forward to hit bottom flag
autoDrive(127,127);{
}
wait1Msec(1300);
driveStop(50);{
}
wait1Msec(50);
// Intake ball
autoTake(1000);{
}
intakeStop(50);{
}
}
// Red flag side (+6)
void autonR2(){
// Start facing cap
// Drive forward to hit cap (+1)
autoDrive(127,127);{
}
wait1Msec(950);
driveStop(50);
// Intake ball halfway
autoTake(500);{
}
intakeStop(50);{
}
// Drive back to alliance tile
autoDrive(-127,-127);{
}
wait1Msec(900);
driveStop(300);
// Turn left to face flags
autoDrive(-80,80);{
}
wait1Msec(195);
driveStop(50);
// Forward slightly
autoDrive(127,127);{
}
wait1Msec(200);
driveStop(50);{
}
wait1Msec(50);
// Shoot top flag (+2)
autoShoot(1800);{
}
puncherStop(50);{
}
// Drive forward
autoDrive(127,127);{
}
wait1Msec(215);
driveStop(50);
// Intake ball fully
autoTake(1000);{
}
intakeStop(50);{
}
// Bring intake down
autoGive(200);{
}
intakeStop(50);{
}
// Intake ball fully
autoTake(500);{
}
intakeStop(50);{
}
// Shoot middle flag (+2)
autoShoot(1800);{
}
puncherStop(50);{
}
// Turn left slightly
autoDrive(0,127);{
}
wait1Msec(120);
driveStop(50);{
}
// Drive forward to hit bottom flag (+1)
autoDrive(127,127);{
}
wait1Msec(800);
driveStop(50);
}
// Red cap side (+4)
void autonR3(){
// Start facing cap
// Drive forward to hit cap (+1)
autoDrive(127,127);{
}
wait1Msec(1150);
driveStop(50);
// Intake ball halfway
autoTake(400);{
}
intakeStop(50);{
}
// Drive back
autoDrive(-127,-127);{
}
wait1Msec(155);
driveStop(50);
// Turn left to face platform
autoDrive(-127,127);{
}
wait1Msec(260);
driveStop(50);
// Drive onto platform (+3)
autoDrive(127,127);{
}
wait1Msec(970);
driveStop(50);
}
/*-----------------------------------------------------------------------------*/
/* Blue alliance
/*-----------------------------------------------------------------------------*/
// Blue flag side (+3)
void autonB1(){
// Start facing flags
// Forward slightly
autoDrive(127,127);{
}
wait1Msec(170);
driveStop(50);{
}
wait1Msec(50);
// Shoot top flag
autoShoot(1800);{
}
puncherStop(50);{
}
// Turn right slightly
autoDrive(127,0);{
}
wait1Msec(100);
driveStop(50);{
}
wait1Msec(50);
// Drive forward to hit bottom flag
autoDrive(127,127);{
}
wait1Msec(1300);
driveStop(50);{
}
wait1Msec(50);
// Intake ball
autoTake(1000);{
}
intakeStop(50);{
}
}
// Blue flag side (+6)
void autonB2(){
// Start facing cap
// Drive forward to hit cap (+1)
autoDrive(127,127);{
}
wait1Msec(950);
driveStop(50);
// Intake ball halfway
autoTake(500);{
}
intakeStop(50);{
}
// Drive back to alliance tile
autoDrive(-127,-127);{
}
wait1Msec(895);
driveStop(300);
// Turn right to face flags
autoDrive(80,-80);{
}
wait1Msec(185);
driveStop(50);
// Forward slightly
autoDrive(127,127);{
}
wait1Msec(200);
driveStop(50);{
}
wait1Msec(50);
// Shoot top flag (+2)
autoShoot(1800);{
}
puncherStop(50);{
}
// Drive forward
autoDrive(127,127);{
}
wait1Msec(215);
driveStop(50);
// Intake ball fully
autoTake(1500);{
}
intakeStop(50);{
}
// Bring intake down
autoGive(200);{
}
intakeStop(50);{
}
// Intake ball fully
autoTake(500);{
}
intakeStop(50);{
}
// Shoot middle flag (+2)
autoShoot(1800);{
}
puncherStop(50);{
}
// Turn right slightly
autoDrive(127,0);{
}
wait1Msec(120);
driveStop(50);{
}
// Drive forward to hit bottom flag (+1)
autoDrive(127,127);{
}
wait1Msec(800);
driveStop(50);
}
// Blue cap side (+4)
void autonB3(){
// Start facing cap
// Drive forward to hit cap (+1)
autoDrive(127,127);{
}
wait1Msec(1100);
driveStop(50);
// Intake ball halfway
autoTake(400);{
}
intakeStop(50);{
}
// Drive back
autoDrive(-127,-127);{
}
wait1Msec(250);
driveStop(50);
// Turn right to face platform
autoDrive(127,-127);{
}
wait1Msec(260);
driveStop(50);
// Drive onto platform (+3)
autoDrive(127,127);{
}
wait1Msec(1100);
driveStop(50);
}