BackStepping反步控制的一个二阶实例推导附带Simulink模型验证

Backstepping基础

这一部分强烈建议自己拿出一张草稿纸推一推这篇博客的内容:backstepping

backstepping的思想正如其名字,反推,将一个高阶系统分解成无数个一阶系统,对每一个一阶系统利用Lyapunov函数找到一个参考输入,而这个输入则是下一个一阶系统的状态变量,下一个一阶系统有了其状态变量的参考值,再利用Lyapunov函数又可以找到一个参考输入,而这个输入则又是下一个一阶系统的状态变量…如此迭代下去,直至推到输入u(最后一个一阶系统)。结合下面这个SISO系统理解我上面说的话:
在这里插入图片描述
刚开始接触的时候可能会问:上面这个系统微分方程组太特殊了,假如x1的一阶导数有输入u呢,或者x2的导数有x4呢?回答是:以LTI系统为例,如果这个系统是可控的,则可以变化为能控标准型,那么就有上面描述的式子了,并且很多非线性系统也能转化为上面这种形式。

上面这个式子我们还可以这样分析:输入u作用在xn上让xn变化,而xn又是xn-1的输入,则改变了xn-1,迭代下去最后推到x1,这么一个思路分析是正向的,与backstepping的思路恰好相反。这也印证了一个道理“求解问题是正向思维,设计问题(这里是设计控制器)是逆向思维

一个二阶系统实例入门Backstepping(手工推导)

这一部分我用ipad书写,跟着这个tutorial推一遍你应该学会了基本思路。

在这里插入图片描述

Simulink仿真

搭建模型

使用S函数搭建这个非线性系统,代码在后面,想要模型的:
backstepping非线性控制demo(模型有注释)
在这里插入图片描述

结果

常数给定 x 1 d x_{1d} x1d

在这里插入图片描述
上面的是 x 1 x_1 x1和给定(蓝色线),下面的是 x 2 x_2 x2曲线。

跟踪正弦信号

在这里插入图片描述
上面的是 x 1 x_1 x1和给定(蓝色线),下面的是 x 2 x_2 x2曲线。

斜坡输入

在这里插入图片描述

综上可以看到,跟踪效果相当好!

Backstepping存在的问题

一旦阶数过高,将引起“复杂度爆炸”问题,这是backstepping的重大缺陷,无论是Lyapunov函数计算还是其它,每一步back必将带来更大的计算量!

附录

S函数源码

function [sys,x0,str,ts,simStateCompliance] = mysystem(t,x,u,flag)
%   FLAG   RESULT             DESCRIPTION
%   -----  ------             --------------------------------------------
%   0      [SIZES,X0,STR,TS]  Initialization, return system sizes in SYS,
%                             initial state in X0, state ordering strings
%                             in STR, and sample times in TS.
%   1      DX                 Return continuous state derivatives in SYS.
%   2      DS                 Update discrete states SYS = X(n+1)
%   3      Y                  Return outputs in SYS.
%   4      TNEXT              Return next time hit for variable step sample
%                             time in SYS.
%   5                         Reserved for future (root finding).
%   9      []                 Termination, perform any cleanup SYS=[].
switch flag

  %%%%%%%%%%%%%%%%%%
  % Initialization %
  %%%%%%%%%%%%%%%%%%
  case 0
    [sys,x0,str,ts,simStateCompliance]=mdlInitializeSizes;
 
  %%%%%%%%%%%%%%%
  % Derivatives %
  %%%%%%%%%%%%%%%
  case 1
    sys=mdlDerivatives(t,x,u);

  %%%%%%%%%%
  % Update %
  %%%%%%%%%%
  case 2
    sys=mdlUpdate(t,x,u);

  %%%%%%%%%%%
  % Outputs %
  %%%%%%%%%%%
  case 3
    sys=mdlOutputs(t,x,u);

  %%%%%%%%%%%%%%%%%%%%%%%
  % GetTimeOfNextVarHit %
  %%%%%%%%%%%%%%%%%%%%%%%
  case 4
    sys=mdlGetTimeOfNextVarHit(t,x,u);

  %%%%%%%%%%%%%
  % Terminate %
  %%%%%%%%%%%%%
  case 9
    sys=mdlTerminate(t,x,u);

  %%%%%%%%%%%%%%%%%%%%
  % Unexpected flags %
  %%%%%%%%%%%%%%%%%%%%
  otherwise
    DAStudio.error('Simulink:blocks:unhandledFlag', num2str(flag));

end


function [sys,x0,str,ts,simStateCompliance]=mdlInitializeSizes
sizes = simsizes;
sizes.NumContStates  = 2;
sizes.NumDiscStates  = 0;
sizes.NumOutputs     = 2;
sizes.NumInputs      = 1;
sizes.DirFeedthrough = 1;         %输出如果用到了u这里一定写1!虽然我这里输出没用到输入但是建议还是写1.
sizes.NumSampleTimes = 1;   % at least one sample time is needed
sys = simsizes(sizes);
%
% initialize the initial conditions
%
x0  = zeros(2,1);
%
% str is always an empty matrix
%
str = [];
%
% initialize the array of sample times
%
ts  = [0 0];
% Specify the block simStateCompliance. The allowed values are:
%    'UnknownSimState', < The default setting; warn and assume DefaultSimState
%    'DefaultSimState', < Same sim state as a built-in block
%    'HasNoSimState',   < No sim state
%    'DisallowSimState' < Error out when saving or restoring the model sim state
simStateCompliance = 'UnknownSimState';
% end mdlInitializeSizes

%
%=============================================================================
% mdlDerivatives
% Return the derivatives for the continuous states.
%=============================================================================
%
function sys=mdlDerivatives(t,x,u)

sys = [x(1)^2-x(1)^3+x(2);u];

% end mdlDerivatives

%
%=============================================================================
% mdlUpdate
% Handle discrete state updates, sample time hits, and major time step
% requirements.
%=============================================================================
%
function sys=mdlUpdate(t,x,u)
sys = [];

% end mdlUpdate

%
%=============================================================================
% mdlOutputs
% Return the block outputs.
%=============================================================================
%
function sys=mdlOutputs(t,x,u)         %这个flag编写输出

sys = x;


% end mdlOutputs

%
%=============================================================================
% mdlGetTimeOfNextVarHit
% Return the time of the next hit for this block.  Note that the result is
% absolute time.  Note that this function is only used when you specify a
% variable discrete-time sample time [-2 0] in the sample time array in
% mdlInitializeSizes.
%=============================================================================
%
function sys=mdlGetTimeOfNextVarHit(t,x,u)

sys = [];

% end mdlGetTimeOfNextVarHit

%
%=============================================================================
% mdlTerminate
% Perform any end of simulation tasks.
%=============================================================================
%
function sys=mdlTerminate(t,x,u)

sys = [];

% end mdlTerminate

猜你喜欢

转载自blog.csdn.net/weixin_43145941/article/details/109705863
今日推荐