-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
more refactoring changelog/readme update class documentation; convenience fitting unit test fitting improved; simulink example; function signatures progress; syntax of MagicFormulaTyre class changed help added unit tests; examples merged FSAE TTC parsers (fool proof?) syntax changes for lower-level functions example updated readme update GettingStarted updated toolbox packager updated readme update readme update unit test updated first draft of Mz0 integrated tydex Measurements now can have model parameters stored fix handling of model parameters remove slprj from source control fix tydex reader README update; new `unpack()` method for measurements moved a few unit tests to examples removed ZETAs; added VX as input; MZ implemented (but untested) added 5.2 parameter set and removed some 6.1.2 parameters from class v52 stuff bugfix Fy0; Mz now seems to work as intended custom display for Parameters class fix? trying to get MZ0 fitting to work init syntax changed for MagicFormulaTyre unit tests fixed; fsae example now with MZ fit; generic plots; refactoring removed function signatures for now directory change (+tir; +exceptions); min/max/fixed settings can be saved cosmetics classes to (Hidden) classes to (Hidden) gitignore Mx, My; lots of QoL-improvements; magicformula syntax changed; version handling publish release v2.0.0
- Loading branch information
Showing
238 changed files
with
4,456 additions
and
2,056 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
classdef FitterTest < matlab.unittest.TestCase | ||
properties | ||
Fitter magicformula.v61.Fitter | ||
Tyre MagicFormulaTyre | ||
Measurements tydex.Measurement | ||
MeasurementFileCornering char {mustBeFile} = 'doc/examples/fsae-ttc-data/fsaettc_obscured_testbench_cornering.mat' | ||
MeasurementFileDriveBrake char {mustBeFile} = 'doc/examples/fsae-ttc-data/fsaettc_obscured_testbench_drivebrake.mat' | ||
%Average RMSE of model versus data across fitted measurements must | ||
%be lower than this value or test will fail. | ||
ThresholdAverageRMSE = 0.3; | ||
end | ||
methods (TestClassSetup) | ||
function setupMeasurements(testCase) | ||
parser = tydex.parsers.FSAETTC_SI_ISO_Mat(); | ||
measurements1 = parser.run(testCase.MeasurementFileCornering); | ||
measurements2 = parser.run(testCase.MeasurementFileDriveBrake); | ||
measurements = [measurements1 measurements2]; | ||
measurements = measurements.downsample(10, 0); | ||
testCase.Measurements = measurements; | ||
end | ||
function setupTyreModel(testCase) | ||
tyre = MagicFormulaTyre(); | ||
tyre.Parameters.UNLOADED_RADIUS.Value = 0.20574; | ||
testCase.Tyre = tyre; | ||
end | ||
function setupFitter(testCase) | ||
tyre = testCase.Tyre; | ||
params = tyre.Parameters; | ||
measurements = testCase.Measurements; | ||
fitter = magicformula.v61.Fitter(measurements, params); | ||
fitter.Options.MaxFunctionEvaluations = 300; % TODO: temporary | ||
testCase.Fitter = fitter; | ||
end | ||
end | ||
methods (Test) | ||
function fitFx0(testCase) | ||
fitmode = magicformula.FitMode.Fx0; | ||
|
||
fitter = testCase.Fitter; | ||
fitter.FitModes = fitmode; | ||
fitter.run() | ||
|
||
tyre = testCase.Tyre; | ||
tyre.Parameters = fitter.ParametersFitted; | ||
|
||
I = fitter.FitModeFlags(char(fitmode)); | ||
measurements = testCase.Measurements(I); | ||
rmse = zeros(numel(measurements), 1); | ||
for i = 1:numel(measurements) | ||
measurement = measurements(i); | ||
[SX,SA,FZ,IP,IA,VX,FX] = unpack(measurement); | ||
FX_mdl = magicformula(tyre,SX,SA,FZ,IP,IA,VX); | ||
FX_max = max(abs([FX FX_mdl]), [], 'all'); | ||
FX_nrm = [FX FX_mdl]/FX_max; | ||
rmse(i) = sqrt(mean((FX_nrm(:,1)-FX_nrm(:,2)).^2)); | ||
end | ||
rmseMean = mean(rmse); | ||
rmseThrd = testCase.ThresholdAverageRMSE; | ||
testCase.verifyLessThanOrEqual(rmseMean, rmseThrd, ... | ||
sprintf('Average RMSE is larger than %.2f%%', rmseThrd)) | ||
end | ||
function fitFy0(testCase) | ||
fitmode = magicformula.FitMode.Fy0; | ||
|
||
fitter = testCase.Fitter; | ||
fitter.FitModes = fitmode; | ||
fitter.run() | ||
|
||
tyre = testCase.Tyre; | ||
tyre.Parameters = fitter.ParametersFitted; | ||
|
||
I = fitter.FitModeFlags(char(fitmode)); | ||
measurements = testCase.Measurements(I); | ||
rmse = zeros(numel(measurements), 1); | ||
for i = 1:numel(measurements) | ||
measurement = measurements(i); | ||
[SX,SA,FZ,IP,IA,VX,~,FY] = unpack(measurement); | ||
[~, FY_mdl] = magicformula(tyre,SX,SA,FZ,IP,IA,VX); | ||
FY_max = max(abs([FY FY_mdl]), [], 'all'); | ||
FY_nrm = [FY FY_mdl]/FY_max; | ||
rmse(i) = sqrt(mean((FY_nrm(:,1)-FY_nrm(:,2)).^2)); | ||
end | ||
rmseMean = mean(rmse); | ||
rmseThrd = testCase.ThresholdAverageRMSE; | ||
testCase.verifyLessThanOrEqual(rmseMean, rmseThrd, ... | ||
sprintf('Average RMSE is larger than %.2f%%', rmseThrd)) | ||
end | ||
function fitMz0(testCase) | ||
fitmode = magicformula.FitMode.Mz0; | ||
|
||
fitter = testCase.Fitter; | ||
fitter.FitModes = fitmode; | ||
fitter.run() | ||
|
||
tyre = testCase.Tyre; | ||
tyre.Parameters = fitter.ParametersFitted; | ||
|
||
I = fitter.FitModeFlags(char(fitmode)); | ||
measurements = testCase.Measurements(I); | ||
rmse = zeros(numel(measurements), 1); | ||
for i = 1:numel(measurements) | ||
measurement = measurements(i); | ||
[SX,SA,FZ,IP,IA,VX,~,~,MZ] = unpack(measurement); | ||
[~,~,MZ_mdl] = magicformula(tyre,SX,SA,FZ,IP,IA,VX); | ||
MZ_max = max(abs([MZ MZ_mdl]), [], 'all'); | ||
MZ_nrm = [MZ MZ_mdl]/MZ_max; | ||
rmse(i) = sqrt(mean((MZ_nrm(:,1)-MZ_nrm(:,2)).^2)); | ||
end | ||
rmseMean = mean(rmse); | ||
rmseThrd = testCase.ThresholdAverageRMSE; | ||
testCase.verifyLessThanOrEqual(rmseMean, rmseThrd, ... | ||
sprintf('Average RMSE is larger than %.2f%%', rmseThrd)) | ||
end | ||
function fitFx(testCase) | ||
fitmode = magicformula.FitMode.Fx; | ||
|
||
fitter = testCase.Fitter; | ||
fitter.FitModes = fitmode; | ||
fitter.run() | ||
|
||
tyre = testCase.Tyre; | ||
tyre.Parameters = fitter.ParametersFitted; | ||
|
||
I = fitter.FitModeFlags(char(fitmode)); | ||
measurements = testCase.Measurements(I); | ||
rmse = zeros(numel(measurements), 1); | ||
for i = 1:numel(measurements) | ||
measurement = measurements(i); | ||
[SX,SA,FZ,IP,IA,VX,FX] = unpack(measurement); | ||
FX_mdl = magicformula(tyre,SX,SA,FZ,IP,IA,VX); | ||
FX_max = max(abs([FX FX_mdl]), [], 'all'); | ||
FX_nrm = [FX FX_mdl]/FX_max; | ||
rmse(i) = sqrt(mean((FX_nrm(:,1)-FX_nrm(:,2)).^2)); | ||
end | ||
rmseMean = mean(rmse); | ||
rmseThrd = testCase.ThresholdAverageRMSE; | ||
testCase.verifyLessThanOrEqual(rmseMean, rmseThrd, ... | ||
sprintf('Average RMSE is larger than %.2f%%', rmseThrd)) | ||
end | ||
function fitFy(testCase) | ||
fitmode = magicformula.FitMode.Fy; | ||
|
||
fitter = testCase.Fitter; | ||
fitter.FitModes = fitmode; | ||
fitter.run() | ||
|
||
tyre = testCase.Tyre; | ||
tyre.Parameters = fitter.ParametersFitted; | ||
|
||
I = fitter.FitModeFlags(char(fitmode)); | ||
measurements = testCase.Measurements(I); | ||
rmse = zeros(numel(measurements), 1); | ||
for i = 1:numel(measurements) | ||
measurement = measurements(i); | ||
[SX,SA,FZ,IP,IA,VX,~,FY] = unpack(measurement); | ||
[~, FY_mdl] = magicformula(tyre,SX,SA,FZ,IP,IA,VX); | ||
FY_max = max(abs([FY FY_mdl]), [], 'all'); | ||
FY_nrm = [FY FY_mdl]/FY_max; | ||
rmse(i) = sqrt(mean((FY_nrm(:,1)-FY_nrm(:,2)).^2)); | ||
end | ||
rmseMean = mean(rmse); | ||
rmseThrd = testCase.ThresholdAverageRMSE; | ||
testCase.verifyLessThanOrEqual(rmseMean, rmseThrd, ... | ||
sprintf('Average RMSE is larger than %.2f%%', rmseThrd)) | ||
end | ||
end | ||
end |
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
*.asv | ||
*.mltbx | ||
*.mltbx | ||
slprj/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,33 @@ | ||
# Changelog | ||
|
||
- Can now read TYDEX files instead of only exporting. See [this example](./doc/examples/Example_TYDEX_FSAETTC.mlx) for examples | ||
In this big update I tried to refactor the library in a way that eases the | ||
use of the functions at the command-line. The most notatble change is the | ||
`magicformula()` function that acts as a version-independent convenience | ||
function to evaluate parameter sets. To make the function-call easier, a few | ||
input arguments have been declared optional. For this change, the order of | ||
arguments has been changed as noted below. | ||
|
||
- FIX: Within calculation of Fy0, the pacejka equation (4.E30) used a wrong | ||
paramter (PKY5 instead of PPY5). This is now fixed! | ||
- NEW: Convenience function `magicformula()`. | ||
Intended to replace calling `magicformula.v61.eval()` directly. | ||
In the future, this function is supposed to be able to evaluate | ||
different versions of parameter sets (e.g. both v52 and v61). | ||
- NEW: Convenience class `MagicFormulaTyre`. See examples. | ||
- NEW: Plot package. Use `magicformula.plots` to access them. | ||
- NEW: Added calculation of MZ, MY, MX. Can also be fitted. See examples. | ||
- BREAKING: Moved `+tir` package into `+magicformula`. | ||
- BREAKING: order of arguments changed for evaluation functions: | ||
OLD `(params,SA,SX,IA,IP,FZ,side)` --> NEW `(params,SX,SA,FZ,IP,IA,side)` | ||
Rationale was to put arguments that can more easily be ommited last | ||
and make them optional. Slip ratio (SX) and slip angle (SA) are usually | ||
known or assumed zero, so they are the only mandatory arguments. | ||
All other inputs can be set to nominal values from parameter set or | ||
set to zero. | ||
- BREAKING: position of multiple functions and classes within the package | ||
`+magicformula` has changed; subpackage `+v62` has been corrected to | ||
`+v61`. If you have been using some functions or classes within the | ||
`magicformula` package, make sure you update their path. | ||
(e.g. `magicformula.v62.equations.Fx0` --> `magicformula.v61.Fx0`) | ||
- BREAKING: order of outputs of `magicformula()` function changed: | ||
[FX,FY,mux,muy] --> [FX,FY,MZ,MY,MX] (mue have been removed) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.