-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmockCOMP.m
149 lines (110 loc) · 4.01 KB
/
mockCOMP.m
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
% Austin Perez
% mockCOMP
clear
clc
close all force
diary('off')
fclose('all') ;
vehiclefile = uigetfile('*.mat', 'Select a Vehicle File', './OpenVEHICLEVehicles') ;
veh = load(vehiclefile);
driverWeight = 68;
lambda = 1.1;
veh.M = veh.M + driverWeight;
% Run Endurance
tr = load("./OpenTRACKTracks/OpenTRACK_Michigan Endurance_Closed_Forward.mat");
[sim] = simulate(veh,tr) ;
co2_produced = sim.co2_produced.data;
tMin = 1360.98; % 2023-University of Texas-Arlington
co2Min = 5.075; % 2023-South Dakota State University
tCo2Min = 1953.1; %time of 1st place
tMax = 1973.42;
co2Max = 13.213;
lapNum = 10;
laptime = sim.laptime.data*lambda;
if (laptime*10)<tMin
tMin = laptime*10;
end
if co2_produced < co2Min
co2Min = co2_produced;
tCo2Min = laptime * 10;
end
%.909 *
effFactor = (tMin/lapNum)/(laptime)*(co2Min/lapNum)/(co2_produced/lapNum);
effFactorMin = (tMin/lapNum)/(tMax/lapNum)*(co2Min/lapNum)/(co2Max/lapNum);
effFactorMax = (tMin/lapNum)/(tCo2Min/lapNum)*(co2Min/lapNum)/(co2Min/lapNum);
if effFactor > effFactorMax
effFactorMax = effFactor;
end
efficiencyScore = 100 * (effFactorMin/effFactor - 1)/(effFactorMin/effFactorMax - 1);
% Endurance Score Calculations
enduranceScore = 0;
% Calculate Corrected Time
DOO = 0;
OC = 0;
CorrectedTime = laptime + (DOO * 2) + (OC * 20);
% Calculate Tmax
Tmax = 1.45 * tMin;
% Calculate Endurance Score based on the provided rules
if CorrectedTime < Tmax
enduranceScore = 250 * ((Tmax / CorrectedTime) - 1) / ((Tmax / tMin) - 1) + 25;
else
enduranceScore = 25;
end
disp('========== ENDURANCE AND EFFICIENCY ==========');
disp(['Laptime: ',num2str(laptime,'%3.3f'),' [s]'])
disp(['Endurance Score: ',num2str(enduranceScore,'%3.3f'),' [pts]'])
disp(['Efficiency Score: ',num2str(efficiencyScore,'%3.3f'),' [pts]'])
% Run Acceleration
time = accelerationSimulation(vehiclefile, 1)*lambda;
DOO = 0; % Example number of cones knocked down
points = accelerationScore(time, DOO);
disp('========== ACCELERATION ==========');
disp(['Finished in: ', num2str(time),' [s]']);
disp(['Acceleration Score: ', num2str(points),' [pts]']);
% Run Autocross
tr = load("./OpenTRACKTracks/OpenTRACK_Autocross_Open_Forward.mat");
[sim] = simulate(veh,tr) ;
disp('========== AUTOCROSS ==========');
disp(['Laptime: ',num2str(sim.laptime.data/10*lambda,'%3.3f'),' [s]'])
Tmin = 45.886; % Minimum time from the data
Tmax = 1.45 * Tmin; % 145% of Tmin
runTime = sim.laptime.data/10*lambda; % Example run time
DOO = 0; % Example number of displaced cones
OC = 0; % Example number of off courses
score = autocrossScore(runTime, DOO, OC, Tmin, Tmax);
disp(['Autocross Score: ',num2str(score,'%3.3f'),' [pts]'])
% Run Skidpad
tr = load("./OpenTRACKTracks/OpenTRACK_Skidpad_Closed_Forward.mat");
[sim] = simulate(veh,tr) ;
disp('========== SKIDPAD ==========');
time = sim.laptime.data/40*lambda;
DOO = 0; % Number of DOO (including entry and exit gate cones)
Tmin = 4.908; % Lowest Corrected Time recorded for any team
if time < Tmin
Tmin = time;
end
score = skidpadScore(time, DOO, Tmin);
disp(['Skidpad Score: ', num2str(score)]);
disp(['Laptime: ',num2str(time,'%3.3f'),' [s]'])
function score = autocrossScore(runTime, DOO, OC, Tmin, Tmax)
% Calculate Corrected Time
correctedTime = runTime + (DOO * 2) + (OC * 20);
% Calculate Autocross Score based on Corrected Time and Tmin, Tmax
if correctedTime < Tmax
score = 118.5 * ((Tmax / correctedTime) - 1)/((Tmax / Tmin) - 1) + 6.5;
else
score = 6.5;
end
end
function score = skidpadScore(time, DOO, Tmin)
% Constants
Tmax = 1.25 * Tmin;
% Corrected Time Calculation
correctedTime = (time) + (DOO * 0.125);
% Score Calculation
if correctedTime < Tmax
score = 71.5 * ((Tmax / correctedTime)^2 - 1)/(((Tmax / Tmin)^2 - 1)) + 3.5 ;
else
score = 3.5;
end
end