forked from FormulaRacingatUCDavis/Tire-Modeling
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TireModelFittingMain.m
139 lines (105 loc) · 4.67 KB
/
TireModelFittingMain.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
clc; clear; close all;
%% TireModelFittingMain - FRUCD Tire Modeling Main Script
% This script fits a Pacejka contact patch tire model, radial deflection
% models, and estimates thermal parameters from Calspan TTC data sets and
% creates an instance of the FRUCDTire class for use in vehicle models.
%
% Inputs:
% - SI Unit Calspan TTC Data Sets [via uigetfile()]
%
% Outputs:
% Directory - (struct) Data, Model, and Figure Path Locations
% Data - (struct) Parsed FSAE TTC Data
% Bin - (struct) Logical Binnings for Separating Operating Conditions
% Tire - (struct) Tire Model
% Figure - (struct) Stores Model Figures
%
% Author(s):
% Blake Christierson (bechristierson@ucdavis.edu) [Sep 2018 - Jun 2021]
% Carlos Lopez (calopez@ucdavis.edu ) [Jan 2019 - ]
% Leonardo Howard (leohoward@ucdavis.edu ) [Jan 2021 - ]
% Tristan Pham (atlpham@ucdavis.edu ) [Jan 2021 - ]
% Last Updated: 23-Oct-2021
%% Initialization
% Sets up the model structure and adds relevant directories for saving and
% storing results.
%%% Figure Interpreter
set(groot,'defaulttextinterpreter','latex');
set(groot,'defaultAxesTickLabelInterpreter','latex');
set(groot,'defaultLegendInterpreter','latex');
%%% Default Directories
Directory.Tool = fileparts( matlab.desktop.editor.getActiveFilename );
Directory.Data = [Directory.Tool(1:max(strfind( Directory.Tool,'\' ))), 'Tire-Data'];
Directory.Resources = [Directory.Tool(1:max(strfind( Directory.Tool,'\' ))), 'MATLAB-Resources'];
Directory.Model = [Directory.Data, '\Models'];
Directory.Media = [Directory.Tool, '\Media'];
addpath( genpath( Directory.Tool ) );
addpath( genpath( Directory.Data ) );
addpath( genpath( Directory.Resources ) );
%%% Figure Structure
Figure.Mode = 'Debug';
Figure.State = 'minimized';
%% Data Import
% Imports and bins the FSAE TTC test data into Data and Bin structures which
% are utilized throughout the rest of the fitting process to select data from
% desired operating conditions.
TestName = {'Transient' , ...
'Cornering 1' , ...
'Cornering 2' , ...
'Warmup' , ...
'Drive, Brake, & Combined 1', ...
'Drive, Brake, & Combined 2'};
%%% Change Current Directory to Default Data Directory
cd( Directory.Data )
%%% Import Run Files
for i = 1 : 6
[FileName, PathName] = uigetfile( { '*.mat;*.dat' }, ...
['Please select the ', TestName{i}, ' Run Data File'] );
if ~ischar( FileName )
continue
else
Data(i) = DataImport( fullfile( PathName, FileName ), TestName{i} ); %#ok<SAGROW>
end
end
%%% Empty Check
if exist( 'Data', 'var' ) == 0
error( 'No Run Data Files Selected' );
end
clear TestName FileName PathName
%%% Binning Run Data
for i = find( ~cellfun( @isempty, { Data(:).Source } ) )
Bin(i) = DataBinning( Data(i) ); %#ok<SAGROW>
end
%% Initialize Tire Model
ModelName = inputdlg( sprintf('%s\n%s','Enter Tire Model Name in Following Format: ', ...
'{Manufacturer} {Compound} {Diameter}x{Width}-{Rim Diameter}x{Rim Width}'), ...
'', 1, {'Tire'} );
Tire = TireParameters( ModelName{1}, [Data.Source], []);
clear ModelName
%% Radial Deflection Modeling
Tire = RadialDeflectionFitting( Tire, Data ); % Radial Deflection (Re, Rl)
%% Contact Patch Load Modeling
%%% Steady State, Pure Slip Force & Aligning Moment Fitting
Tire = PureLongitudinalFitting( Tire, Data, Bin, Figure ); % Longitudinal Force ( Fxo )
Tire = PureLateralFitting( Tire, Data, Bin, Figure ); % Lateral Force ( Fyo )
Tire = PureAligningFitting( Tire, Data, Bin, Figure ); % Aligning Moment ( Mzo )
%%% Steady State, Combined Slip Force Modeling
% This is currently undeveloped due to data limitations. Instead, combined tire forces
% can be evaluated using the Modified-Nicolas-Comstock (MNC) Model on the pure slip
% models. It is implemented within the FRUCDTire Class Definition.
%%% Steady State, Combined Slip Moment Fitting
% Tire = CombinedAligningFitting( Tire, Data, Bin, Figure ); % Aligning Moment (Mz)
Tire = OverturningFitting( Tire, Data, Bin, Figure ); % Overturning Moment (Mx)
% Tire = ResistanceModeling( Tire, Data, Bin, Figure ); % Rolling Resistance (My)
%%% Transient Response
Tire = RelaxationLengthFitting( Tire, Data, Bin, Figure );
%% Thermal Modeling
%%% Heat Generation Modeling
%% Exporting Model
SaveModel = questdlg( 'Save Model?', '', 'Yes', 'No', 'No' );
if strcmpi( SaveModel, 'Yes' )
save( [Directory.Model, '\', ...
strrep(strrep(Tire.Name, '.', ''),' ', '_')], 'Tire' )
ExportTireFigures( Tire, Data, Bin, Figure, Directory );
end
clear SaveModel