资源简介
通过建立整车七自由度的数学模型(垂向四自由度+俯仰+侧倾+横摆),并在matlab/simulink搭建相应的模型进行仿真,通过设定一定的路面条件从而观察整车参数的相应变化。
代码片段和文件信息
function [sysx0strts] =suspension_7dof(txuflag)
% Dispatch the flag. The switch function controls the calls to
% S-function routines at each simulation stage.
switch flag
case 0
[sysx0strts] = mdlInitializeSizes; % Initialization
case 1
sys=mdlDerivatives(txu);
case 3
sys = mdlOutputs(txu); % Calculate outputs
case {2 4 9 }
sys = []; % Unused flags
otherwise
error([‘Unhandled flag = ‘num2str(flag)]); % Error handling
end % End of function
%==============================================================
% Function mdlInitializeSizes initializes the states sample
% times state ordering strings (str) and sizes structure.
%==============================================================
function [sysx0strts] = mdlInitializeSizes
% Call function simsizes to cleate the sizes structure.
sizes = simsizes;
% Load the sizes structure with the initialization information.
sizes.NumContStates= 14;
sizes.NumDiscStates= 0;
sizes.NumOutputs= 5;
sizes.NumInputs= 4; %----4个路面输入
sizes.DirFeedthrough=1;
sizes.NumSampleTimes=0;
% Load the sys vector with the sizes information.
sys = simsizes(sizes);
x0 = [0 0 0 0 0 0 0 0 0 0 0 0 0 0 ]; % No continuous states
%
str = []; % No state ordering
%
ts = []; % Inherited sample time
% End of mdlInitializeSizes.
%==============================================================
% Function mdlOutputs performs the calculations.
%==============================================================
function sys=mdlDerivatives(txu)
%1:左前轮 2:右前轮 3:左后轮 4:右后轮
%x1:xc x2:dxc x3:theat x4:dtheat x5:fai x6:dfai
%x7:xu1 x8:dxu1 x9:xu2 x10:dxu2 x11:xu3 x12:dxu3 x13:xu4 x14:dxu4
If = 1920;Is = 386;ms = 1390;mr = 28.5;mf = 27;ktf = 192000;ktr = 192000;
a = 1.13;b = 1.47; bs = 1.47;kf = 30000;kr = 25000;cf = 1550;cr = 1650;
xsfl = x(1)-bs*x(3)/2-a*x(5);
xsfr = x(1)+bs*x(3)/2-a*x(5);
xsrl = x(1)-bs*x(3)/2+a*x(5);
xsrr = x(1)+bs*x(3)/2+a*x(5);
dxsfl = x(2)-bs*x(4)/2-a*x(6);
dxsfr = x(2)+bs*x(4)/2-a*x(6);
dxsrl = x(2)-bs*x(4)/2+a*x(6);
dxsrr = x(2)+bs*x(4)/2+a*x(6);
xufl=x(7);dxufl=x(8);xufr=x(9);dxufr=x(10);xurl=x(11);dxurl=x(12);xurr=x(13);dxurr=x(14);
Ffl = kf*(xsfl - xufl) + cf*(dxsfl-dxufl);
Ffr = kf*(xsfr - xufr) + cf*(dxsfr-dxufr);
Frl = kr*(xsrl - xurl) + cr*(dxsrl-dxurl);
Frr = kr*(xsrr - xurr) + cr*(dxsrr-dxurr);
sys(1) = x(2);
sys(2) = (-Ffl-Ffr-Frl-Frr)/ms;
sys(3) = x(4);
sys(4) = ((Ffl+Frl-Ffr-Frr)*bs/2)/Is;
sys(5) = x(6);
sys(6) = ((Ffl+Ffr)*a-(Frl+Frr)*b)/If;
sys(7) = x(8);
sys(8) = (Ffl-ktf*(xufl-u(1)))/mf;
sys(9) = x(10);
sys(10) = (Ffr-ktf*(xufr-u(2)))/mf;
sys(11) = x(12);
sys(12) = (Frl-ktr*(xurl-u(3)))/mr;
sys(13) = x(14);
sys(14) = (Frr-ktr*(xurr-u(4)))/mr;
function sys = mdlOutputs(txu)
If = 1920;Is = 386;ms = 1390;mr = 28.5;mf = 27;ktf = 192000;ktr = 192000;
a = 1.13;b = 1.47; bs = 1.47;kf = 30000;kr = 25000;cf = 1550;cr = 1650;
xsfl = x(1)-bs*x(3)/2-a*x(5);
xsfr = x(1)+bs*x(3
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 47475 2020-04-24 13:20 suspension7dof.mdl
文件 3830 2020-04-24 13:20 suspension_7dof.m
- 上一篇:基于肤色的RGB多人脸检测
- 下一篇:太阳能最大功率的跟踪matlab仿真实验
评论
共有 条评论