大家好,这是我的简单钟摆模型和控制使用SimMechanics和控制工具箱,稍后我还将包括SolidWorks文件,以展示如何使用SolidWorks链接。
任何发现我应该用另一种方式做事情的人,请随意发表任何评论并帮助我:)
该示例使用SimMechanics建模,并使用lqr命令进行控制。
首先,我从solidworks中导入了钟摆
mech_import;
>> mgrPend = MECH_STATEVECTORMGR;
> > mgrPend。StateNames
ans =
“InvertedPendulumModel Pendulo_Invertido /转动:R1:位置的
“InvertedPendulumModel Pendulo_Invertido /移动:P1:位置的
“InvertedPendulumModel Pendulo_Invertido /转动:R1:速度的
“InvertedPendulumModel Pendulo_Invertido /移动:P1:速度的
>> [A,B,C,D] = linmod('InvertedPendulumModel');
> > eig (A)
ans =
0
0
2.3132
-2.3132
>> open_plant = ss(A,B,C,D);
> >脉冲(open_plant);
>> Q = diag([0 100 0 100]);
>> K = lqr(A,B,Q,R)
K =
284.3487 -10.0000 126.1560 -23.6582
>> Ac = [(A-B*K)];
>> Bc = [B];
>> Cc = [C];
[D];
> > sys_cl = ss (Ac,公元前,Cc特区);
> > T = 0:0.01:50;
> > U = 0.2 * 1(大小(T));
> > (Y, T, X) = lsim (sys_cl, U, T);
> >的情节(T, Y)
引用作为
莱昂纳多Araujo(2021)。简单的倒立摆与LQR,PID SimMechanics(//www.tatmou.com/matlabcentral/fileexchange/25139-simple-inverted-pendulum-with-lqr-pid-simmechanics), MATLAB中央文件交换。检索.