24.09., 9:00 - 11:00: Due to updates GitLab will be unavailable for some minutes between 09:00 and 11:00.

vehicleDynamics_KS.m 1.27 KB
Newer Older
Markus Koschi's avatar
Markus Koschi committed
1 2 3 4 5 6 7 8 9
function f = vehicleDynamics_KS(x,u,p)
% vehicleDynamics_KS - kinematic single-track vehicle dynamics 
%
% Syntax:  
%    f = vehicleDynamics_KS(x,u,p)
%
% Inputs:
%    x - vehicle state vector
%    u - vehicle input vector
Markus Koschi's avatar
Markus Koschi committed
10
%    p - vehicle parameter structure
Markus Koschi's avatar
Markus Koschi committed
11 12 13 14 15 16 17 18 19 20 21 22 23 24
%
% Outputs:
%    f - right-hand side of differential equations
%
% Example: 
%
% Other m-files required: none
% Subfunctions: none
% MAT-files required: none
%
% See also: ---

% Author:       Matthias Althoff
% Written:      12-January-2017
Markus Koschi's avatar
Markus Koschi committed
25
% Last update:  15-December-2017
Markus Koschi's avatar
Markus Koschi committed
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
% Last revision:---

%------------- BEGIN CODE --------------

%create equivalent kinematic single-track parameters
l = p.a + p.b;

%states
%x1 = s_x x-position in a global coordinate system
%x2 = s_y y-position in a global coordinate system
%x3 = δ steering angle of front wheels
%x4 = u velocity in x-direction
%x5 = Ψ yaw angle

%u1 = v_delta steering angle velocity of front wheels
%u2 = ax longitudinal acceleration

Markus Koschi's avatar
Markus Koschi committed
43 44 45 46 47 48
%consider steering constraints
u(1) = steeringConstraints(x(3),u(1),p.steering);

%consider acceleration constraints
u(2) = accelerationConstraints(x(4),u(2),p.longitudinal);

Markus Koschi's avatar
Markus Koschi committed
49 50 51 52 53 54 55 56
%system dynamics
f(1,1) = x(4)*cos(x(5));
f(2,1) = x(4)*sin(x(5));
f(3,1) = u(1);
f(4,1) = u(2);
f(5,1) = x(4)/l*tan(x(3));

%------------- END OF CODE --------------