This repository has been archived by the owner on Jun 12, 2019. It is now read-only.
forked from nebrelbug/lemonade
-
Notifications
You must be signed in to change notification settings - Fork 0
/
robot.c
272 lines (227 loc) · 8.62 KB
/
robot.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
#pragma config(Sensor, in1, posPotent, sensorPotentiometer)
#pragma config(Sensor, in2, progPotent, sensorPotentiometer)
#pragma config(Sensor, dgtl1, rightEncoder, sensorQuadEncoder)
#pragma config(Sensor, dgtl3, leftEncoder, sensorQuadEncoder)
#pragma config(Sensor, dgtl5, leftSonar, sensorSONAR_mm)
#pragma config(Motor, port1, intake1, tmotorVex393TurboSpeed_HBridge, openLoop)
#pragma config(Motor, port2, left1, tmotorVex393HighSpeed_MC29, openLoop)
#pragma config(Motor, port3, left2, tmotorVex393HighSpeed_MC29, openLoop)
#pragma config(Motor, port4, left3, tmotorVex393HighSpeed_MC29, openLoop)
#pragma config(Motor, port5, puncher, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port6, flipper, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port7, right3, tmotorVex393HighSpeed_MC29, openLoop)
#pragma config(Motor, port8, right2, tmotorVex393HighSpeed_MC29, openLoop)
#pragma config(Motor, port9, right1, tmotorVex393HighSpeed_MC29, openLoop)
#pragma config(Motor, port10, intake2, tmotorVex393TurboSpeed_HBridge, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
/*********************************************************************/
/*********************************************************************/
/*********************************************************************/
/** --------------------- 72832S competition ctrl -------------------*/
/*********************************************************************/
/*********************************************************************/
/*********************************************************************/
// Competition Control and Duration Settings
#pragma competitionControl(Competition)
#pragma autonomousDuration(15)
#pragma userControlDuration(105)
#pragma systemFile
/*---------------------------------------------------------------------------*/
/* */
/* Description: Competition template for VEX EDR */
/* */
/*---------------------------------------------------------------------------*/
// This code is for the VEX cortex platform
#pragma platform(VEX2)
// Select Download method as "competition"
#pragma competitionControl(Competition)
// Main competition background code...do not modify!
/*---------------------------------------------------------------------------*/
/* Pre-Autonomous Functions */
/* */
/* You may want to perform some actions before the competition starts. */
/* Do them in the following function. You must return from this function */
/* or the autonomous and usercontrol tasks will not be started. This */
/* function is only called once after the cortex has been powered on and */
/* not every time that the robot is disabled. */
/*---------------------------------------------------------------------------*/
/*********************************************************************/
/*********************************************************************/
/*********************************************************************/
/** ---------------------- 72832S include files ---------------------*/
/*********************************************************************/
/*********************************************************************/
/*********************************************************************/
#include "include/jpearman/SmartMotorLib.c"
#include "BNSLibrary/BNSLib.h"
#include "Vex_Competition_Includes.c" // Main competition background code...do not modify!
#include "include/API.h"
/*********************************************************************/
/*********************************************************************/
/*********************************************************************/
/** ------------------------ 72832S pre auton -----------------------*/
/*********************************************************************/
/*********************************************************************/
/********************************************\*************************/
void pre_auton() {
// Set bStopTasksBetweenModes to false if you want to keep user created tasks
// running between Autonomous and Driver controlled modes. You will need to
// manage all user created tasks if set to false.
init();
}
task autonomous(){
/*
pidReqVal=1050;
startTask(pidPos);
delayFunc(10000);
*/
resetEncoders();
clearLCD();
delay(4);
if(autonRun){
//auton menu
setLCDPosition(0,0);
displayNextLCDString("Match Auton Run");
setLCDPosition(1,0);
if (val1 >= cutoffs[0] && val1 < cutoffs[1]) {
displayNextLCDString("Red, Back");
delay();
startTask(intakeOnTask);
driveForward(1.75);
delay();
driveBackward(0.2);
delay();
driveTurn90(true);
delay();
driveForward(1.2);
delay();
intakeOff();
} else if (val1 >= cutoffs[1] && val1 < cutoffs[2]) {
displayNextLCDString("Red, Front");
punch();
delay();
driveBackward(0.1);
delay();
driveTurn90(false);
delay();
driveBackward(0.1);
delay();
driveForward(1.5);
delay();
startTask(intakeOnTask);
delay();
driveBackward(0.2);
delay();
driveTurn90(true);
delay();
driveForward(1.3);
delay();
intakeOff();
}else if(val1 >= cutoffs[2] && val1 < cutoffs[3]){
displayNextLCDString("Blue, Front");
startTask(intakeOnTask);
punch();
delay();
driveBackward(0.1);
delay();
driveTurn90(true);
delay();
driveBackward(0.1);
delay();
driveForward(1.5);
delay();
startTask(intakeOnTask);
delay();
driveBackward(0.2);
delay();
driveTurn90(true);
delay();
driveForward(1.3);
delay();
intakeOff();
}else if (val1 >= cutoffs[3] && val1 < cutoffs[4]) {
delay();
displayNextLCDString("Blue, Back");
startTask(intakeOnTask);
delay();
driveForward(1.75);
delay();
driveBackward(0.2);
delay();
driveTurn90(false);
delay();
driveForward(1.2);
delay();
intakeOff();
}
}else if(skillsRun){
setLCDPosition(0,0);
displayNextLCDString("Skills Auton Run");
setLCDPosition(1,0);
//SKILLS MVP(most valuable player) TEST #1
//SKILLS MVP(minimum viable product)
punch();
delay();
delay();
delay();
delay();
driveBackward(1.0);
delay();
delay();
delay();
delay();
delay();
driveTurn90(true);
delay();
delay();
delay();
delay();
delay();
driveBackward(0.2);
delay();
delay();
delay();
delay();
delay();
driveForward(3.2);
//intake Off
intakeOff();
}else if(skillsRun==false && autonRun==false){
setLCDPosition(0,0);
displayNextLCDString("Running Nothing");
setLCDPosition(1,0);
delay(6);
}
// */
}
/*********************************************************************/
/*********************************************************************/
/*********************************************************************/
/** ------------------- 72832S opcontrol functions ------------------*/
/*********************************************************************/
/*********************************************************************/
/*********************************************************************/
task usercontrol() {
stopTask(autonomous);
intakeOff();
// Initialize the Smart Motor Library
SmartMotorsInit();
// Define which motors are linked
// Declare that you want the Library to keep a lid on the
// motors by measuring the temperature of the PTC components
SmartMotorPtcMonitorEnable();
// Run smart motors
SmartMotorRun();
SmartMotorsInit();
SmartMotorRun();
string mainBattery, backupBattery;
//display battery voltage
lcdBattery();
bLCDBacklight = true; // Turn on LCD Backlight
pidRunning=false;
driveReverse=false;
while (true) {
opcontrol();
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////