-
Notifications
You must be signed in to change notification settings - Fork 1
/
SkillsCompetitionProgramming.c
271 lines (225 loc) · 5.37 KB
/
SkillsCompetitionProgramming.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
#pragma config(Sensor, in7, lineFollower, sensorLineFollower)
#pragma config(Sensor, in8, gyro, sensorGyro)
#pragma config(Sensor, dgtl1, rightEncoder, sensorQuadEncoder)
#pragma config(Motor, port2, rightBack, tmotorVex393HighSpeed_MC29, openLoop, reversed)
#pragma config(Motor, port3, rightFront, tmotorVex393HighSpeed_MC29, openLoop, reversed)
#pragma config(Motor, port4, leftBack, tmotorVex393HighSpeed_MC29, openLoop)
#pragma config(Motor, port5, leftFront, tmotorVex393HighSpeed_MC29, openLoop)
#pragma config(Motor, port6, mobileGoal, tmotorVex393HighSpeed_MC29, openLoop)
#pragma config(Motor, port7, mobileGoal2, tmotorVex393HighSpeed_MC29, openLoop, reversed)
#pragma config(Motor, port8, rightMid, tmotorVex393HighSpeed_MC29, openLoop, reversed)
#pragma config(Motor, port9, leftMid, tmotorVex393HighSpeed_MC29, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
void moveStraight(int speed) {
motor[rightBack] = speed;
motor[rightFront] = speed;
motor[rightMid] = speed;
motor[leftBack] = speed;
motor[leftFront] = speed;
motor[leftMid] = speed;
}
void turnRight(int speed) {
motor[leftBack] = speed;
motor[leftFront] = speed;
motor[leftMid] = speed;
motor[rightBack] = -speed;
motor[rightFront] = -speed;
motor[rightMid] = -speed;
}
void turnLeft(int speed) {
motor[rightBack] = speed;
motor[rightFront] = speed;
motor[rightMid] = speed;
motor[leftBack] = -speed;
motor[leftFront] = -speed;
motor[leftMid] = -speed;
}
void moveLift(int speed) {
motor[mobileGoal] = speed;
motor[mobileGoal2] = speed;
}
//Code for VEX 11040B
task main()
{
/* INFORMATION
* Time Needed to Move Mobile Goal Lift:
*/
//Pre-autonomous
SensorValue[rightEncoder] = 0;
SensorType[in1] = sensorNone;
wait1Msec(1000);
SensorType[in1] = sensorGyro;
SensorValue[gyro] = 0;
//Autonomous
/* FIRST MOBILE GOAL */
// Mobile Goal Lift Down
moveLift(127);
wait1Msec(950);
moveLift(0);
//Move Forward a bit
moveStraight(127);
wait1Msec(1500);
moveStraight(0);
//Move Towards First Mobile Goal
while (SensorValue(lineFollower) < 450) {
moveStraight(127);
}
//Move a bit after it hits line
wait1Msec(600);
moveStraight(0);
//Pick Up First Mobile Goal
moveLift(-127);
wait1Msec(1450);
moveLift(0);
//Move back over white line
moveStraight(-127);
wait1Msec(1500);
moveStraight(0);
//Move back until it hits line
while (SensorValue(lineFollower) < 450) {
moveStraight(-127);
}
moveStraight(-80);
wait1Msec(300);
moveStraight(0);
//Turn Right
SensorValue[gyro] = 0;
while (abs(SensorValue[gyro]) < 1200) {
motor[leftBack] = 127;
motor[leftFront] = 127;
motor[leftMid] = 127;
motor[rightBack] = -40;
motor[rightFront] = -40;
motor[rightMid] = -40;
}
moveStraight(0);
//Move Forward
moveStraight(127);
wait1Msec(670);
moveStraight(0);
//Turn Right
SensorValue[gyro] = 0;
while (abs(SensorValue[gyro]) < 330) {
turnRight(100);
}
turnRight(0);
//Move Forward into 20 point zone
moveStraight(127);
wait1Msec(690);
moveStraight(0);
//Lower Lift a little
moveLift(127);
wait1Msec(330);
moveLift(0);
//ram into 20 pt zone
moveStraight(127);
wait1Msec(400);
moveStraight(0);
//Move backward a bit
moveStraight(-127);
wait1Msec(1200);
moveStraight(0);
//Move backward until white line
while (SensorValue(lineFollower) < 450) {
moveStraight(-127);
}
moveStraight(0);
//Move forward a bit
moveStraight(127);
wait1Msec(300);
moveStraight(0);
//Turn Right
SensorValue[gyro] = 0;
while(abs(SensorValue[gyro]) < 450) {
turnRight(127);
}
turnRight(0);
//Move Forward
moveStraight(127);
wait1Msec(900);
moveStraight(0);
//Turn Right
SensorValue[gyro] = 0;
while (abs(SensorValue[gyro]) < 275) {
turnRight(127);
}
turnRight(0);
//Lower Mobile Goal Lift
moveLift(127);
wait1Msec(570);
moveLift(0);
//Grab second mobile goal
moveStraight(127);
wait1Msec(1000);
moveStraight(0);
//Raise mobile goal
moveLift(-127);
wait1Msec(1300);
moveLift(0);
//Turn around
SensorValue[gyro] = 0;
while (abs(SensorValue[gyro]) < 1600) {
turnLeft(127);
}
turnLeft(0);
//Lower lift a little
moveLift(127);
wait1Msec(400);
moveLift(0);
//Move into 10 point zone
moveStraight(127);
wait1Msec(1400);
moveStraight(0);
//Move back into white line
while(SensorValue(lineFollower) < 450) {
moveStraight(-127);
}
moveStraight(0);
//Turn Left to head towards third goal
SensorValue[gyro] = 0;
while (abs(SensorValue[gyro]) < 390) {
turnLeft(127);
}
turnLeft(0);
//Move forward
moveStraight(127);
wait1Msec(700);
moveStraight(0);
//Turn Left
SensorValue[gyro] = 0;
while(abs(SensorValue[gyro]) < 450) {
turnLeft(127);
}
turnLeft(0);
//Lower Mobile Goal Lift
moveLift(127);
wait1Msec(700);
moveLift(0);
//Move toward 3rd Mobile Goal
moveStraight(127);
wait1Msec(1200);
moveStraight(0);
//Raise Mobile Goal Lift
moveLift(-127);
wait1Msec(1000);
moveLift(0);
//Turn Around
SensorValue[gyro] = 0;
while(abs(SensorValue[gyro]) < 1450) {
turnRight(127);
}
turnRight(0);
//Lower lift a little
moveLift(127);
wait1Msec(350);
moveLift(0);
//Move into 10 point zone
moveStraight(127);
wait1Msec(1500);
moveStraight(0);
//Move back into white line
while(SensorValue(lineFollower) < 450) {
moveStraight(-127);
}
moveStraight(0);
}