Skip to content

Commit 26916e8

Browse files
authored
Create Rerun_Example.c
1 parent d6a0971 commit 26916e8

File tree

1 file changed

+254
-0
lines changed

1 file changed

+254
-0
lines changed

Lib/Example/Rerun_Example.c

Lines changed: 254 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,254 @@
1+
#pragma config(I2C_Usage, I2C1, i2cSensors)
2+
#pragma config(Sensor, dgtl11, sonar, sensorSONAR_mm)
3+
#pragma config(Sensor, I2C_1, , sensorQuadEncoderOnI2CPort, , AutoAssign )
4+
#pragma config(Sensor, I2C_2, , sensorQuadEncoderOnI2CPort, , AutoAssign )
5+
#pragma config(Motor, port1, , tmotorVex393_HBridge, openLoop, encoderPort, I2C_2)
6+
#pragma config(Motor, port10, , tmotorVex393_HBridge, openLoop, encoderPort, I2C_1)
7+
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
8+
9+
#pragma competitionControl(Competition)
10+
#pragma autonomousDuration(20)
11+
#pragma userControlDuration(120)
12+
#include "Mod_Vex_Comp_Control.c"
13+
14+
#define armPID(fInput) (fInput - ((SensorValue[I2C_1] + SensorValue[I2C_2]) / 2)) * 0.7
15+
16+
int autonomous1[150][3] = {
17+
{0, 0, 0},
18+
{0, 0, 0},
19+
{0, 0, 0},
20+
{0, 0, 0},
21+
{0, 0, 0},
22+
{0, 0, 0},
23+
{0, 0, 0},
24+
{0, 0, 0},
25+
{0, 0, 0},
26+
{0, 0, 0},
27+
{0, 0, 0},
28+
{0, 0, 0},
29+
{0, 0, 0},
30+
{0, 0, 0},
31+
{0, 0, 0},
32+
{0, 0, 0},
33+
{0, 0, 0},
34+
{0, 0, 0},
35+
{0, 0, 0},
36+
{0, 0, 0},
37+
{0, 0, 0},
38+
{0, 0, 0},
39+
{0, 0, 0},
40+
{0, 0, 0},
41+
{0, 0, 0},
42+
{0, 0, 0},
43+
{0, 0, 0},
44+
{0, 0, 0},
45+
{0, 0, 0},
46+
{0, 0, 0},
47+
{0, 0, 0},
48+
{0, 0, 0},
49+
{0, 0, 0},
50+
{0, 0, 0},
51+
{0, 0, 0},
52+
{0, 0, 0},
53+
{0, 0, 0},
54+
{0, 0, 0},
55+
{0, 0, 0},
56+
{0, 0, 0},
57+
{0, 0, 0},
58+
{0, 0, 0},
59+
{0, 0, 0},
60+
{0, 0, 0},
61+
{0, 0, 0},
62+
{0, 0, 0},
63+
{0, 0, 0},
64+
{0, 0, 0},
65+
{0, 0, 0},
66+
{0, 0, 0},
67+
{0, 0, 0},
68+
{0, 0, 0},
69+
{0, 0, 0},
70+
{0, 0, 0},
71+
{0, 0, 0},
72+
{0, 0, 0},
73+
{0, 0, 0},
74+
{0, 0, 0},
75+
{0, 0, 0},
76+
{0, 0, 0},
77+
{0, 0, 0},
78+
{0, 0, 0},
79+
{0, 0, 0},
80+
{0, 0, 0},
81+
{0, 0, 0},
82+
{0, 0, 0},
83+
{0, 0, 0},
84+
{0, 0, 0},
85+
{0, 0, 0},
86+
{0, 0, 0},
87+
{0, 0, 0},
88+
{0, 0, 0},
89+
{0, 0, 0},
90+
{0, 0, 0},
91+
{0, 0, 0},
92+
{0, 0, 0},
93+
{0, 0, 0},
94+
{0, 0, 0},
95+
{0, 0, 0},
96+
{0, 0, 0},
97+
{0, 0, 0},
98+
{0, 0, 0},
99+
{0, 0, 0},
100+
{0, 0, 0},
101+
{0, 0, 0},
102+
{0, 0, 0},
103+
{0, 0, 0},
104+
{0, 0, 0},
105+
{0, 0, 0},
106+
{0, 0, 0},
107+
{0, 0, 0},
108+
{0, 0, 0},
109+
{0, 0, 0},
110+
{0, 0, 0},
111+
{0, 0, 0},
112+
{0, 0, 0},
113+
{0, 0, 0},
114+
{0, 0, 0},
115+
{0, 0, 0},
116+
{0, 0, 0},
117+
{0, 0, 0},
118+
{0, 0, 0},
119+
{0, 0, 0},
120+
{0, 0, 0},
121+
{0, 0, 0},
122+
{0, 0, 0},
123+
{0, 0, 0},
124+
{0, 0, 0},
125+
{0, 0, 0},
126+
{0, 0, 0},
127+
{0, 0, 0},
128+
{0, 0, 0},
129+
{0, 0, 0},
130+
{0, 0, 0},
131+
{0, 0, 0},
132+
{0, 0, 0},
133+
{0, 0, 0},
134+
{0, 0, 0},
135+
{0, 0, 0},
136+
{0, 0, 0},
137+
{0, 0, 0},
138+
{0, 0, 0},
139+
{0, 0, 0},
140+
{0, 0, 0},
141+
{0, 0, 0},
142+
{0, 0, 0},
143+
{0, 0, 0},
144+
{0, 0, 0},
145+
{0, 0, 0},
146+
{0, 0, 0},
147+
{0, 0, 0},
148+
{0, 0, 0},
149+
{0, 0, 0},
150+
{0, 0, 0},
151+
{0, 0, 0},
152+
{0, 0, 0},
153+
{0, 0, 0},
154+
{0, 0, 0},
155+
{0, 0, 0},
156+
{0, 0, 0},
157+
{0, 0, 0},
158+
{0, 0, 0},
159+
{0, 0, 0},
160+
{0, 0, 0},
161+
{0, 0, 0},
162+
{0, 0, 0},
163+
{0, 0, 0},
164+
{0, 0, 0},
165+
{0, 0, 0},
166+
{0, 0, 0}};
167+
168+
void
169+
tank (int iSpeedL, int iSpeedR) {
170+
motorSet(port3, iSpeedR);
171+
motorSet(port4, iSpeedR);
172+
motorSet(port5, iSpeedR);
173+
motorSet(port6, iSpeedL);
174+
motorSet(port7, iSpeedL);
175+
motorSet(port8, iSpeedL);
176+
}
177+
178+
void
179+
arm (int iSpeed) {
180+
motorSet(port1, iSpeed);
181+
motorSet(port2, iSpeed);
182+
motorSet(port9, iSpeed);
183+
motorSet(port10, iSpeed);
184+
}
185+
186+
int iDes;
187+
void
188+
armControl (bool bBtnReset, bool bSpeedBoost, bool bPreset, bool bBtnUp, bool bBtnDown) {
189+
int iOutput;
190+
if (bBtnUp || bBtnDown) {
191+
iOutput = bSpeedBoost ? (bBtnUp - bBtnDown) * 127 : (bBtnUp - bBtnDown) * 70;
192+
iDes = (SensorValue[I2C_1] + -SensorValue[I2C_2]) / 2;
193+
} else if (bPreset) {
194+
iOutput = armPID(250);
195+
iDes = (SensorValue[I2C_1] + -SensorValue[I2C_2]) / 2;
196+
} else {
197+
iOutput = armPID(iDes);
198+
}
199+
arm (iOutput);
200+
201+
if (bBtnReset) clearAllIME();
202+
}
203+
204+
void
205+
initIO () {
206+
setAllMotor393();
207+
208+
motorSetup(port1, true);
209+
motorSetup(port2, false);
210+
motorSetup(port3, true, LINESPEED);
211+
motorSetup(port4, false, LINESPEED);
212+
motorSetup(port5, false, LINESPEED);
213+
motorSetup(port6, true, LINESPEED);
214+
motorSetup(port7, true, LINESPEED);
215+
motorSetup(port8, true, LINESPEED);
216+
motorSetup(port9, true);
217+
motorSetup(port10, false);
218+
219+
sTeam = "HORNET ~ 21S";
220+
bLCDAuton =
221+
bLCDUserControl = true;
222+
}
223+
224+
void
225+
pre_auton () {
226+
clearAllIME();
227+
}
228+
229+
void
230+
replay1 () {
231+
for (int i = 0; i < 150; i++) {
232+
arm (armPID(autonomous1[i][0]));
233+
tank (autonomous1[i][2], autonomous1[i][1]);
234+
delay(100);
235+
}
236+
}
237+
238+
task
239+
autonomous () {
240+
replay1();
241+
}
242+
243+
task
244+
usercontrol () {
245+
while (true) {
246+
tank ((vexRT[Ch3]), (vexRT[Ch2]));
247+
armControl (vexRT[Btn8D], vexRT[Btn6D], vexRT[Btn5D], vexRT[Btn6U], vexRT[Btn5U]);
248+
249+
if (vexRT[Btn7D]) {
250+
waitForReleased7D();
251+
startTask(record);
252+
}
253+
}
254+
}

0 commit comments

Comments
 (0)