Skip to content

Commit

Permalink
Refactoring of FSAE TTC parser
Browse files Browse the repository at this point in the history
- more readable code
- dependency on Signal Processing Toolbox removed
- kamm circle plot added
  • Loading branch information
teasit committed Jan 14, 2024
1 parent ba9fb64 commit 7b7e526
Show file tree
Hide file tree
Showing 58 changed files with 350 additions and 323 deletions.
4 changes: 2 additions & 2 deletions +tests/FitterTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
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'
MeasurementFileCornering char {mustBeFile} = 'doc/examples/ttc/cornering.mat'
MeasurementFileDriveBrake char {mustBeFile} = 'doc/examples/ttc/drivebrake.mat'
%Average RMSE of model versus data across fitted measurements must
%be lower than this value or test will fail.
ThresholdAverageRMSE = 0.3;
Expand Down
Binary file modified +tests/FunctionSignatures.mlx
Binary file not shown.
Binary file modified +tests/ParameterFittingSettings.mlx
Binary file not shown.
Binary file modified +tests/TirePropertiesFile.mlx
Binary file not shown.
7 changes: 2 additions & 5 deletions +tests/TydexImportExport.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@
end
methods (TestClassSetup)
function parseMeasurements(testCase)
folder = 'doc/examples/fsae-ttc-data';
files = fullfile(folder, {
'fsaettc_obscured_testbench_drivebrake.mat'
'fsaettc_obscured_testbench_cornering.mat'
});
folder = 'doc/examples/ttc';
files = fullfile(folder, {'drivebrake.mat';'cornering.mat'});
parser = tydex.parsers.FSAETTC_SI_ISO_Mat();
for i = 1:numel(files)
file = files{i};
Expand Down
Binary file modified +tests/VerityCodeGenerationCompatible.mlx
Binary file not shown.
35 changes: 18 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![GitHub release (latest by date)](https://img.shields.io/github/v/release/teasit/magic-formula-tyre-library)](https://github.com/teasit/magic-formula-tyre-library/releases/latest)
[![MATLAB Latest Tests Status](https://github.com/teasit/magic-formula-tyre-library/actions/workflows/test-matlab-r2023b.yml/badge.svg?branch=main)](https://github.com/teasit/magic-formula-tyre-library/actions/workflows/test-matlab-r2023b.yml)

![Fitting Example](doc/images/magic_formula_library_socialpreview.png)
![Social-Preview](doc/images/magic_formula_library_socialpreview.png)

```matlab
[FX,FY,MZ,MY,MX] = magicformula(params,__)
Expand All @@ -20,7 +20,7 @@

- MATLAB Base
- (Optional) Optimization Toolbox (fitting)
- (Optional) Signal Processing Toolbox (measurement import)
- (Optional) Parallel Computing Toolbox (parallel fitting)

### Release Compatibility

Expand Down Expand Up @@ -50,26 +50,27 @@ The data has been de-identified to conform with the FSAE TTC's
[license agreement](https://www.millikenresearch.com/FSAE_TTC_agreement.pdf).

```matlab
folder = 'doc/examples/fsae-ttc-data';
file = fullfile(folder, 'fsaettc_obfuscated.tir');
tyre = MagicFormulaTyre(file);
file = fullfile(folder, 'fsaettc_obscured_testbench_drivebrake.mat');
parser = tydex.parsers.FSAETTC_SI_ISO_Mat();
measurements = parser.run(file);
measurements = measurements([30 40 55 60 70 75]);
measurements = parser.run('doc/examples/ttc/drivebrake.mat');
tyre = MagicFormulaTyre('doc/examples/ttc/obfuscated.tir');
figure(); grid on; hold on
magicformula.plots.compareFxSX(tyre, measurements(2:5))
```

![Model vs. Data Plot](doc/images/magic_formula_library_socialpreview.png)

### Example: Friction Ellipse

Also known as the Kamm-Circle when approximating the tire friction limit as a circle when it actually is an ellipse.

```matlab
tyre = MagicFormulaTyre('doc/examples/ttc/obfuscated.tir');
figure(); grid on; hold on
c = colororder();
for i = 1:numel(measurements)
[SX,SA,FZ,IP,IA,VX,FX] = unpack(measurements(i));
FX_mdl = magicformula(tyre,SX,SA,FZ,IP,IA,VX);
plot(SX, FX_mdl, 'Color', c(i,:), 'LineWidth', 2)
plot(SX, FX, '.', 'Color', c(i,:), 'MarkerSize', 4)
end
xlabel('SX / 1'); ylabel('FX / N')
magicformula.plots.kamm(tyre)
```

![Kamm Plot](doc/images/kamm.png)

Further examples can be found in the [`doc/examples`](./doc/examples) folder.

## Motivation
Expand Down
Binary file modified doc/GettingStarted.mlx
Binary file not shown.
Binary file modified doc/examples/Example_CompareToMFEVAL.mlx
Binary file not shown.
Binary file modified doc/examples/Example_Fitter_FSAETTC.mlx
Binary file not shown.
Binary file added doc/examples/Example_PlotKamm.mlx
Binary file not shown.
Binary file modified doc/examples/Example_PlotWithData.mlx
Binary file not shown.
Binary file modified doc/examples/Example_TYDEX_FSAETTC.mlx
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file added doc/images/kamm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/images/magic_formula_library_socialpreview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version='1.0' encoding='UTF-8'?>
<Info Ref="doc/examples/ttc" Type="Relative"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version='1.0' encoding='UTF-8'?>
<Info location="b73d1b47-e2bb-466e-94d4-09f39be17669" type="Reference"/>

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?>
<Info>
<Category UUID="FileClassCategory">
<Label UUID="design"/>
</Category>
</Info>
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<?xml version='1.0' encoding='UTF-8'?>
<Info />
<Info location="kamm.m" type="File"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version='1.0' encoding='UTF-8'?>
<Info location="drivebrake.mat" type="File"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version='1.0' encoding='UTF-8'?>
<Info location="1" type="DIR_SIGNIFIER"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version='1.0' encoding='UTF-8'?>
<Info location="obfuscated_v52.tir" type="File"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version='1.0' encoding='UTF-8'?>
<Info location="cornering.mat" type="File"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version='1.0' encoding='UTF-8'?>
<Info location="obfuscated.tir" type="File"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?>
<Info>
<Category UUID="FileClassCategory">
<Label UUID="design"/>
</Category>
</Info>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version='1.0' encoding='UTF-8'?>
<Info location="version.m" type="File"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?>
<Info>
<Category UUID="FileClassCategory">
<Label UUID="design"/>
</Category>
</Info>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version='1.0' encoding='UTF-8'?>
<Info location="Example_PlotKamm.mlx" type="File"/>
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<?xml version='1.0' encoding='UTF-8'?>
<Info />
<Info location="ttc" type="File"/>

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<?xml version='1.0' encoding='UTF-8'?>
<Info />
<Info/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version='1.0' encoding='UTF-8'?>
<Info location="test-matlab-r2023b.yml" type="File"/>

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Binary file modified sandbox/Fitting.mlx
Binary file not shown.
30 changes: 30 additions & 0 deletions src/+magicformula/+plots/kamm.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
function kamm(tyre, options)
arguments
tyre MagicFormulaTyre
options.LimitsSX (1,2) = [-0.1 0.1]
options.LimitsSA (1,2) = [-pi/8 pi/8]
options.SweepLength {mustBeInteger} = 100
options.NumConstant {mustBeInteger} = 25
end

limits = options.LimitsSX;
stepsz = diff(limits)/options.NumConstant;
SX_sweep = linspace(limits(1), limits(2));
SX_const = limits(1):stepsz:limits(2);

limits = options.LimitsSA;
stepsz = diff(limits)/options.NumConstant;
SA_sweep = linspace(limits(1), limits(2));
SA_const = limits(1):stepsz:limits(2);

for i = 1:numel(SA_const)
[FX,FY] = magicformula(tyre,SX_sweep,SA_const(i));
plot(FY, FX, 'k-')
end
for i = 1:numel(SX_const)
[FX,FY] = magicformula(tyre,SX_const(i),SA_sweep);
plot(FY, FX, 'k-')
end
axis equal
xlabel('FY / N'); ylabel('FX / N')
end
Loading

0 comments on commit 7b7e526

Please sign in to comment.