Skip to content

Commit 0eff0a7

Browse files
committed
Merge branch 'test_ex_singletrack'
2 parents 47d7316 + 0d47232 commit 0eff0a7

16 files changed

+1202
-487
lines changed

GP.m

Lines changed: 241 additions & 85 deletions
Large diffs are not rendered by default.

InvertedPendulumModel.m

Lines changed: 0 additions & 174 deletions
This file was deleted.

MotionModelGP.m

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@
3838
var_w % measurement noise covariance matrix. w ~ N(0,var_w)
3939
end
4040

41+
properties (SetAccess=public)
42+
% is_d_active = false
43+
end
44+
4145
methods (Abstract)
4246
xdot = f (obj, x, u)
4347
%------------------------------------------------------------------
@@ -196,7 +200,7 @@
196200

197201
% evaluate disturbance
198202
[mu_d, var_d] = obj.d(z);
199-
203+
200204
% A) Mean Equivalent Approximation:
201205
var_x_d_w = blkdiag(var_xk, var_d, obj.var_w);
202206

MotionModelGP_InvPendulum_deffect.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444

4545
% add deffect
4646
xdot(3) = xdot(3) + (0.1 * x(3) - 0.01*x(4) + deg2rad(3)) *10;
47+
48+
% xdot(2) = xdot(2) + ( -0.1 * x(1) + deg2rad(3));
4749
end
4850

4951
% function [xkp1, gradx_xkp1] = fd (obj, xk, uk, dt)

MotionModelGP_SingleTrack_nominal.m

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
%--------------------------------------------------------------------------
3232

3333
properties
34-
M = 500*1.5 % vehicle mass
35-
I_z = 600*1.5 % vehicle moment of inertia (yaw axis)
34+
M = 500 *1.5 % vehicle mass
35+
I_z = 600 *1.5 % vehicle moment of inertia (yaw axis)
3636
g = 9.81 % gravitation
3737
l_f = 0.9 % distance of the front wheel to the center of mass
3838
l_r = 1.5 % distance of the rear wheel to the center of mass
@@ -45,21 +45,19 @@
4545

4646

4747
% Pacejka lateral dynamics parameters
48-
c_f = 14000 * 1.3 % = 1*g*M/deltamax % front coornering stiffness (C*delta=Fy~M*a)
49-
c_r = 14000 * 1.3 % = 2*g*M/deltamax % rear coornering stiffness
48+
c_f = 14000 * 2.5 % = 1*g*M/deltamax % front coornering stiffness (C*delta=Fy~M*a)
49+
c_r = 14000 * 2.5 % = 2*g*M/deltamax % rear coornering stiffness
5050
end
5151

5252
properties(Constant)
5353
% keep in mind the dimensions: xk+1 = fd(xk,uk) + Bd*(d(z)+w)),
5454
% where z = [Bz_x*x;Bz_u*u]
55-
Bz_x = [0 0 0 1 0 0 0;
56-
0 0 0 0 1 0 0;
57-
0 0 0 0 0 1 0]
55+
Bz_x = [zeros(3), eye(3), zeros(3,1)]
5856
Bz_u = [1 0 0;
5957
0 1 0]
6058
Bd = [zeros(3);
6159
eye(3);
62-
0 0 0];
60+
zeros(1,3)]
6361
n = 7 % number of outputs x(t)
6462
m = 3 % number of inputs u(t)
6563
nz = 5 % dimension of z(t)
@@ -75,7 +73,7 @@
7573
% call superclass constructor
7674
obj = obj@MotionModelGP(d,sigmaw);
7775
% report single track dynamics analysis
78-
obj.analyseSingleTrack();
76+
% obj.analyseSingleTrack();
7977

8078
% add folder CODEGEN to path. Here there will be some functions
8179
% generated with the method generate_grad_functions()

MotionModelGP_SingleTrack_true.m

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,12 @@
6868
properties(Constant)
6969
% keep in mind the dimensions: xk+1 = fd(xk,uk) + Bd*(d(z)+w)),
7070
% where z = [Bz_x*x;Bz_u*u]
71-
Bz_x = [0 0 0 1 0 0 0;
72-
0 0 0 0 1 0 0;
73-
0 0 0 0 0 1 0]
71+
Bz_x = [zeros(3), eye(3), zeros(3,1)]
7472
Bz_u = [1 0 0;
75-
0 1 0]
73+
0 1 0]
7674
Bd = [zeros(3);
7775
eye(3);
78-
0 0 0];
76+
zeros(1,3)]
7977
n = 7 % number of outputs x(t)
8078
m = 3 % number of inputs u(t)
8179
nz = 5 % dimension of z(t)
@@ -224,7 +222,6 @@
224222
end
225223

226224
function testTyres(obj)
227-
%%
228225
c_f = 14000; % = 1*g*M/deltamax % front coornering stiffness (C*delta=Fy~M*a)
229226
c_r = 14000; % = 2*g*M/deltamax % rear coornering stiffness
230227

@@ -239,6 +236,16 @@ function testTyres(obj)
239236
D_r = 4000; % peak value (Pacejka) (rear wheel)
240237
E_r = -0.5; % curvature factor (Pacejka) (rear wheel)
241238

239+
B_f = 10.96; % stiffnes factor (Pacejka) (front wheel)
240+
C_f = 1.3; % shape factor (Pacejka) (front wheel)
241+
D_f = 4560.4; % peak value (Pacejka) (front wheel)
242+
E_f = -0.5; % curvature factor (Pacejka) (front wheel)
243+
244+
B_r = 12.67; % stiffnes factor (Pacejka) (rear wheel)
245+
C_r = 1.3; % shape factor (Pacejka) (rear wheel)
246+
D_r = 3947.81; % peak value (Pacejka) (rear wheel)
247+
E_r = -0.5; % curvature factor (Pacejka) (rear wheel)
248+
242249
a_r = deg2rad(-25:0.1:25);
243250
a_f = deg2rad(-25:0.1:25);
244251
W_Fy_r = D_r*sin(C_r*atan(B_r*a_r-E_r*(B_r*a_r -atan(B_r*a_r)))); % rear lateral force

NMPC.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@
120120
end
121121

122122

123-
function [u_opt, e_opt] = optimize(obj, x0, t0, r)
123+
function [u_opt, e_opt] = optimize(obj, x0, t0, r, UseParallel)
124124
%------------------------------------------------------------------
125125
% Calculate first uptimal control input
126126
%------------------------------------------------------------------
@@ -144,7 +144,7 @@
144144
'Display','iter',...
145145
'Algorithm', 'interior-point',... % 'interior-point',... % 'sqp','interior-point'
146146
'SpecifyConstraintGradient',false,...
147-
'UseParallel',false,... %'ConstraintTolerance',obj.tol,...
147+
'UseParallel',UseParallel,... %'ConstraintTolerance',obj.tol,...
148148
'MaxIterations',obj.maxiter);
149149

150150
% solve optimization problem

0 commit comments

Comments
 (0)