Vehicle Dynamics - Pacejka Magic Formula
AIM: To perform curve fitting on Pacejka Magic formula.
OBJECTIVES: 1. To obtain fit coefficients so that the curve describes the tire test data accurately.
2. To obtain fit coefficients so that your curve describes the tire test data accurately (it should be less than 2.0Nm)
GIVEN DATA: data file consisting the results (slip angle & aligning moment) of a tire test
( https://drive.google.com/file/d/0B2S2ZJKcURAmd0Vrdm1pSDhUY1k/view?usp=sharing )
GOVERNING EQUATION:
Pacejka Magic Formula:
`Y(X) = D*sin[C*arctan{Bx-E(Bx-arctan(Bx))}]`
`Y(X) = y(x) + S_v`
`x = X + S_h`
where,
`Y(X) ->`Cornering force, breaking force, aligning moment
`X->`Slip angle, skid ratio
`B->`Stiffness factor
`C->`Shape factor
`D->`Peak value
`E->`Curvature factor
`S_v, S_h ->`Offsets due to camber thrust, rolling resistance etc.
SOLUTION:
MATLAB Code:
clear all
close all
clc
%load given data file
data = load('tire_test_data');
alpha_data = data(:, 1);
Mz_data = data(:, 2);
%plot the given data
figure(1)
hold on
plot(alpha_data, Mz_data,'o')
xlabel('Slip angle')
ylabel('Aligning moment')
grid on
%pacejka magic formula
%coefficients
Bz = 0.2077;
Cz = 2.165;
Dz = 59.1;
Ez = -2.32;
Shz = 0;
Svz = 0;
for i = 1:101
alpha(i) = (i-1)*0.17;
Alpha(i) = alpha(i) + Shz;
mz(i) = Dz*sin(Cz*atan(Bz*Alpha(i)-Ez*(Bz*Alpha(i)-atan(Bz*Alpha(i)))));
Mz(i) = mz(i) + Svz;
end
%plotting pacejka curve
plot(Alpha,Mz,'linewidth',2)
legend('Test data','Pacejka')
saveas(1,'pacejka_curve_fitting','jpeg')
%rms error
e = 0;
for j = 1:length(alpha_data)
a(j) = alpha_data(j)+Shz;
mz_e(j) = Dz*sin(Cz*atan(Bz*a(j)-Ez*(Bz*a(j)-atan(Bz*a(j)))));
Mz_e(j) = mz_e(j) +Svz;
%error
e = e + (Mz_e(j)-Mz_data(j))^2;
end
%rms
RMSE = (e/length(alpha_data))^0.5
OUTPUT:

PLOT:

CONCLUSION: Curve fitting have been performed on the Pacejka Magic formula for brush tire model using an errorless MATLAB script.