AERO 401: UAV Modeling and Control Course AERO 401:无人机建模与控制课程
Tutorial Exercise 教程练习
Dr. Yahya H Zweiri 耶哈亚·H·兹韦里博士Department of Aerospace Engineering-Khalifa University, Center for Autonomous Robotic Systems (KUCARS), Khalifa 航空航天工程系-哈利法大学,自动化机器人系统中心(KUCARS),哈利法University of Science and Technology 科学技术大学2024
This exercise composes of three tutorial sessions, and should be run in MATLAB 2019 or later versions. The exercise makes use of the MATLAB Control Toolbox. The exercise must be written-up and uploaded to the Blackboard by designated dates written below. Late reports will not be marked and will receive zero marks. Remember to include your name and the date on your front page. Do not describe method or procedure. Do not reproduce or explain any MATLAB code in your answers, but use theory to support comments and explain results where appropriate. Keep your answers reasonably brief and succinct. 本练习由三个教程环节组成,需在 MATLAB 2019 或更高版本中运行。该练习使用 MATLAB 控制工具箱。练习必须在下面指定的日期之前撰写并上传到 Blackboard。迟交的报告将不予评分,得分为零。请记得在首页上写上你的名字和日期。请勿描述方法或程序。请勿在答案中复制或解释任何 MATLAB 代码,但应使用理论支持评论,并在适当的地方解释结果。请保持答案简洁明了。
Introduction 介绍
The procedure of designing controllers for unmanned aerial systems can be broken down into the following stages: 设计无人机系统控制器的过程可以分为以下几个阶段:
i) Study system to be controlled - choose sensors and actuators i) 研究要控制的系统 - 选择传感器和执行器
ii) Model resulting system to be controlled ii) 建模要控制的系统
iii) Linearize model. Simplify model if necessary iii) 线性化模型。如有必要,简化模型。
iv) Analyze the resulting model, determine its properties iv) 分析生成的模型,确定其属性
v) Decide on performance specifications, decide on type of controller to be used v) 决定性能规格,决定使用的控制器类型
vi) Design controller to meet specifications 设计控制器以满足规格要求
vii) Test controllers by simulation with full non-linear model of the plant 通过全非线性模型对测试控制器进行仿真
viii) Design hardware and software and implement controller 设计硬件和软件并实现控制器
ix) Tune controller on-line 在线调节控制器
The objective of the exercise is to use various techniques to analyse and design feedback controllers for a simple system, that is to perform stages (iv) and (vi) of the above procedure. 本次练习的目标是使用各种技术分析和设计简单系统的反馈控制器,即执行上述程序的第(iv)和第(vi)阶段。
You will design controllers for a quadrotor attitude dynamics which is modelled as a 3rd order system, G(s)G(s), of the form 您将为四旋翼姿态动力学设计控制器,该动力学被建模为一个三阶系统, G(s)G(s) ,形式为
where T_(1)T_{1} is the time constant of the propulsion system and T_(2)T_{2} is the time constant of the attitude channel caused by body dynamics and aerodynamics effects. The objective of the design is to obtain a feedback controller which achieves the performance specifications on the step response of percent overshoot M_(p) <= 10%M_{p} \leq 10 \% and peak time t_(p) <= 0.5t_{p} \leq 0.5 sec, with zero steady state error. 其中 T_(1)T_{1} 是推进系统的时间常数, T_(2)T_{2} 是由于机体动力学和空气动力学效应引起的姿态通道的时间常数。设计的目标是获得一个反馈控制器,使其在超调百分比 M_(p) <= 10%M_{p} \leq 10 \% 和峰值时间 t_(p) <= 0.5t_{p} \leq 0.5 秒的阶跃响应上达到性能规格,并且稳态误差为零。
After system modelling and linearization, the next stage in the control system design procedure is to perform some analysis of the system. In this exercise, the analysis consists of looking at the open loop poles and zeros, the open loop step response and the system Bode plot. By means of the root locus technique, and the Bode plot, some stability analysis on the system is also be performed to find out limiting values of controller gain. 在系统建模和线性化之后,控制系统设计过程的下一阶段是对系统进行一些分析。在这个过程中,分析包括查看开环极点和零点、开环阶跃响应以及系统的波德图。通过根轨迹技术和波德图,还将对系统进行一些稳定性分析,以找出控制器增益的限制值。
For the controller design stage of this exercise, proportional controllers are designed using the root-locus and Bode plots. In addition, both a P+D controller and a pole placement state feedback controller are designed. 在本练习的控制器设计阶段,使用根轨迹和波德图设计比例控制器。此外,还设计了一个 P+D 控制器和一个极点配置状态反馈控制器。
The next stage of the design procedure would be to test the controllers in simulation with the non-linear model of the plant (using, for example SIMULINK). This stage is not covered in this exercise. Additional elements could be incorporated at this stage, such as plant disturbances and sensor noise. Finally, the controller hardware/software would be designed and tested on the real plant. 设计过程的下一阶段是使用植物的非线性模型(例如使用 SIMULINK)在仿真中测试控制器。此阶段在本练习中未涵盖。此阶段还可以加入其他元素,例如植物干扰和传感器噪声。最后,将设计并测试控制器的硬件/软件在真实植物上。
Figure 1: Closed loop system with proportional controller 图 1:带比例控制器的闭环系统
1 Analysis of the plant (Tutorial 2, due date is 4th November) 植物分析(教程 2,截止日期为 11 月 4 日)
NOTE - ALL THE OTHER SECTIONS OF THIS LABORATORY DEPEND UPON THE COMPLETION AND RESULTS OF THIS SECTION. 注意 - 本实验室的所有其他部分都依赖于本部分的完成和结果。
Question 1.1 Using the second order system formulae, calculate the minimum damping ratio of the dominant poles for an overshoot of M_(p) <= 10%M_{p} \leq 10 \%. 问题 1.1 使用二阶系统公式,计算超调为 M_(p) <= 10%M_{p} \leq 10 \% 时主极点的最小阻尼比。
Question 1.2 Using the second order system formulae, calculate the minimum damped frequency, omega_(d)=omega_(n)sqrt(1-zeta^(2))\omega_{d}=\omega_{n} \sqrt{1-\zeta^{2}}, of the dominant poles for a peak time t_(p) <= 0.5sect_{p} \leq 0.5 \mathrm{sec}. 问题 1.2 使用二阶系统公式,计算主极点的最小阻尼频率 omega_(d)=omega_(n)sqrt(1-zeta^(2))\omega_{d}=\omega_{n} \sqrt{1-\zeta^{2}} ,以达到峰值时间 t_(p) <= 0.5sect_{p} \leq 0.5 \mathrm{sec} 。
Question 1.3 Sketch the area in the s-plane where the dominant poles must lie in order to meet both the specifications. 问题 1.3 在 s 平面中勾画出主极点必须位于的区域,以满足两个规格。
To obtain the plant you will use in this exercise, type 要获取您在本练习中使用的植物,请输入
Question 1.4 Record the values of k,T_(1)k, T_{1} and T_(2)T_{2}. 问题 1.4 记录 k,T_(1)k, T_{1} 和 T_(2)T_{2} 的值。
Define the plant, G(s)G(s), in transfer function form by 定义植物 G(s)G(s) 的传递函数形式为
Obtain the open-loop poles of the plant by pole (G) 通过极点 (G) 获取系统的开环极点
Plot the plant poles on the ss-plane by pzmap(G); 在 ss 平面上通过 pzmap(G)绘制植物极点;
Question 1.5 Record the transfer function and comment on it. Record and comment on the plant poles. 问题 1.5 记录传递函数并对此进行评论。记录并评论植物极点。
Question 1.6 What will happen if you try to obtain the plant open loop step response? Explain why. 问题 1.6 如果你尝试获取植物的开环阶跃响应,会发生什么?请解释原因。
Obtain the open loop impulse response by 获取开环脉冲响应通过
impulse(G); 冲动(G);
Question 1.7 Explain this response characteristics. 问题 1.7 解释这个响应特性。
2 Proportional controller design by root-locus 2 根轨迹法的比例控制器设计
The root locus displays the locii of the closed loop system poles for a controller 根轨迹显示了控制器闭环系统极点的位置
K(s)=k_(p)K(s)=k_{p}
as the value of k_(p)k_{p} increases from zero for the system shown in Figure 1. 随着图 1 所示系统中 k_(p)k_{p} 的值从零增加。
Plot the root locus of the plant by 绘制植物的根轨迹图
rlocus (G)
The command 命令
sgrid
draws in lines of constant damping ratio zeta\zeta and natural frequency omega_(n)\omega_{n}. The damping ratio lines are drawn from zeta=0\zeta=0 to 1 in steps of 0.1 . 绘制了恒定阻尼比 zeta\zeta 和自然频率 omega_(n)\omega_{n} 的线。阻尼比线从 zeta=0\zeta=0 绘制到 1,步长为 0.1。
Question 2.1 Explain the root locus characteristics. 问题 2.1 解释根轨迹特性。
Question 2.2 From the root locus plot, determine whether both design specifications a re simultaneously possible using proportional feedback alone. Record any calculations and show your workings on the root locus plot (by hand). Determine omega_(d)\omega_{d} and hence t_(p)t_{p} at the required value of zeta\zeta. Record your calculations. 问题 2.2 从根轨迹图中,确定是否可以仅使用比例反馈同时满足两个设计规范。记录任何计算,并在根轨迹图上展示你的工作(手动)。确定 omega_(d)\omega_{d} ,并因此在所需的 zeta\zeta 值下确定 t_(p)t_{p} 。记录你的计算。
The plot above shows all possible closed-loop pole locations for a pure proportional controller. Obviously not all of those closed-loop poles will satisfy our design criteria. We can use the function sgrid to plot lines of constant damping ratios and natural frequencies. For the peak time condition, you may need to manually add one more constraint to the plot. 上面的图显示了纯比例控制器所有可能的闭环极点位置。显然,并不是所有这些闭环极点都能满足我们的设计标准。我们可以使用函数 sgrid 来绘制恒定阻尼比和自然频率的线。对于峰值时间条件,您可能需要手动向图中添加一个额外的约束。
MATLAB provides an interactive root locus facility. Type MATLAB 提供了一个交互式根轨迹功能。输入
[kp,poles_kp]=rlocfind(G)
and use the mouse to determine the required value of k_(p)k_{p} for an overshoot of 10%10 \%. The eigenvalues at this point are also returned by the function rlocfind. Note that this is not a very accurate method. 并使用鼠标确定超调量为 10%10 \% 时所需的 k_(p)k_{p} 值。此时的特征值也由函数 rlocfind 返回。请注意,这不是一种非常准确的方法。
Question 2.3 Record the value of k_(p)k_{p} and the poles at this point. 问题 2.3 记录 k_(p)k_{p} 的值以及该点的极点。
The required value of k_(p)k_{p} is now in the MATLAB workspace as the variable kp . Calculate the closed loop transfer function 所需的 k_(p)k_{p} 值现在在 MATLAB 工作区中作为变量 kp。计算闭环传递函数。
T=" feedback "(kp**G,1)T=\text { feedback }(k p * G, 1)
Obtain the closed loop damping ratio, natural frequency and poles by damp (T) 获取闭环阻尼比、自然频率和极点通过 damp (T)
Now display the closed loop system step response by 现在通过显示闭环系统的阶跃响应
step(T); 步(T);
From the plot, measure M_(p)M_{p} and t_(p)t_{p}. 从图中测量 M_(p)M_{p} 和 t_(p)t_{p} 。
Question 2.4 Record and comment on the closed loop transfer function. Record the closed loop damping ratio, natural frequency and poles and compare these to the values predicted from the root locus. Record M_(p)M_{p} and t_(p)t_{p}. Comment on the response. Does your design meet the specifications? Compare the overshoot and peak time to the values predicted from the root locus. 问题 2.4 记录并评论闭环传递函数。记录闭环阻尼比、自然频率和极点,并将这些与根轨迹预测的值进行比较。记录 M_(p)M_{p} 和 t_(p)t_{p} 。对响应进行评论。您的设计是否符合规格?将超调量和峰值时间与根轨迹预测的值进行比较。
Question 2.5 Using the interactive root-locus facility, use the mouse to determine the limiting value of k_(p)k_{p} for system stability. Calculate the value by hand. 问题 2.5 使用交互式根轨迹工具,使用鼠标确定系统稳定性的极限值 k_(p)k_{p} 。手动计算该值。
3 Proportional controller design by Bode plot (Tutorial 3, due date is 18th November) 通过波德图设计的比例控制器 (教程 3,截止日期为 11 月 18 日)
In this section, a proportional controller 在本节中,比例控制器
K(s)=k_(p)K(s)=k_{p}
for the system shown in Figure 1 will be designed and the stability analysed using frequency domain techniques. 将设计图 1 所示的系统,并使用频域技术分析其稳定性。
Obtain the plant Bode plot by bode (G); 通过 bode (G) 获取植物 Bode 图;
Question 3.1 Explain the Bode plot characteristics. 问题 3.1 解释波德图的特性。
Question 3.2 Find the limiting value of k_(p)k_{p} for system stability. Show the workings on the Bode plot. 问题 3.2 找到系统稳定性的极限值 k_(p)k_{p} 。在波德图上展示计算过程。
Question 3.3 From the Bode plot, determine the value of k_(p)k_{p} required for M_(p)=10%M_{p}=10 \% assuming 问题 3.3 从波德图中确定所需的 k_(p)k_{p} 值,以便 M_(p)=10%M_{p}=10 \% 假设
PM~~100 zetaquad" for "quad PM < 70degP M \approx 100 \zeta \quad \text { for } \quad P M<70 \mathrm{deg}
where PM is the phase margin. Show the workings on the Bode plot. 其中 PM 是相位裕度。请在波特图上展示计算过程。
Input the calculated value of k_(p)k_{p} into the MATLAB workspace as the variable kp. Now calculate the closed loop transfer function 将计算得出的 k_(p)k_{p} 的值输入到 MATLAB 工作区,作为变量 kp。现在计算闭环传递函数。
T=" feedback "(kp**G,1)\mathrm{T}=\text { feedback }(k p * G, 1)
Now display the closed loop system step response by 现在通过显示闭环系统的阶跃响应
step(T); 步(T);
From the plot, measure M_(p)M_{p} and t_(p)t_{p}. 从图中测量 M_(p)M_{p} 和 t_(p)t_{p} 。
Question 3.4 Record and comment on the closed loop transfer function. Comment on the response. Record M_(p)M_{p} and t_(p)t_{p}. Compare M_(p)M_{p} to the value predicted from the Bode plot. Does your design meet the specifications? 问题 3.4 记录并评论闭环传递函数。评论响应。记录 M_(p)M_{p} 和 t_(p)t_{p} 。将 M_(p)M_{p} 与从波德图预测的值进行比较。您的设计是否符合规格?
Now obtain the Bode plot of the open loop compensated system L(s)=G(s)K(s)=k_(p)G(s)L(s)=G(s) K(s)=k_{p} G(s) by bode (kpG); 现在通过 bode (kpG) 获取开环补偿系统 L(s)=G(s)K(s)=k_(p)G(s)L(s)=G(s) K(s)=k_{p} G(s) 的波德图;
Obtain the gain margin GMG M, phase margin PMP M, and associated frequencies omega_(cg)\omega_{c g} and omega_(cp)\omega_{c p} by [GM,PM,Wcg,Wcp] = margin(kpG) 获得增益裕度 G)
You can convert GM to decibels by 您可以通过以下方式将 GM 转换为分贝:
20**log 10(GM)20 * \log 10(\mathrm{GM})
Question 3.5 Record the gain margin, phase margin, and associated frequencies. 问题 3.5 记录增益裕度、相位裕度及相关频率。
Comment on the Bode plot of the open loop compensated system. Show the gain and phase margins on the plot. 对开环补偿系统的波德图进行评论。图中显示增益和相位裕度。
4 PID/P+D controller design 4 PID/P+D 控制器设计
PID controllers are the most commonly used type of industrial control. They are usually designed by trial and error using a few simple rules. PID 控制器是最常用的工业控制类型。它们通常通过试错法和一些简单规则进行设计。
Question 4.1 What will be the system type if a PID controller is used on this plant? For zero steady state error (to unity step references) for this plant, is an integrator required in the controller? 问题 4.1 如果在这个植物上使用 PID 控制器,系统类型将是什么?为了使该植物在单位阶跃参考下达到零稳态误差,控制器中是否需要一个积分器?
Question 4.2 What are the advantages and disadvantages of not using integral action (i.e., using P+DP+D control)? 问题 4.2 不使用积分作用(即使用 P+DP+D 控制)的优缺点是什么?
Figure 2: Closed loop system with P+D controller 图 2:带有 P+D 控制器的闭环系统
For many mechanical control applications, the derivative of the output is available for measurement using tachometers and other devices. However, for many applications, such a signal is simply not available (e.g. process engineering applications), or prohibitively expensive to obtain. In such cases, the derivative signal y^(˙)(t)\dot{y}(t) should be approximated by (high pass filter) 对于许多机械控制应用,输出的导数可以通过转速计和其他设备进行测量。然而,对于许多应用,这样的信号根本不可用(例如过程工程应用),或者获取成本过高。在这种情况下,导数信号 y^(˙)(t)\dot{y}(t) 应通过(高通滤波器)进行近似。
where 1//alpha1 / \alpha is greater than the system bandwidth. Making 1//alpha1 / \alpha too large means that high frequency noise in the measurement signal of y(t)y(t) is amplified. 当 1//alpha1 / \alpha 大于系统带宽时。将 1//alpha1 / \alpha 设置得过大意味着 y(t)y(t) 的测量信号中的高频噪声被放大。
The closed loop system is shown in Figure 2. The controller K(s)K(s) for this exercise is a P+D\mathrm{P}+\mathrm{D} controller 闭环系统如图 2 所示。本次练习的控制器 K(s)K(s) 是一个 P+D\mathrm{P}+\mathrm{D} 控制器。
Now design the controller. Firstly, define alpha\alpha. A suggested value is alpha=0.02\alpha=0.02 现在设计控制器。首先,定义 alpha\alpha 。建议的值是 alpha=0.02\alpha=0.02 。
" alpha=0. "02\text { alpha=0. } 02
Define a proportional gain term, k_(p)k_{p}, in the MATLAB workspace in a variable kp. Similarly, define a derivative gain term, k_(d)k_{d}, in a variable kd . Now define the transfer function, K(s)K(s), of the controller by 在 MATLAB 工作区中定义一个比例增益项 k_(p)k_{p} ,存储在变量 kp 中。同样,在变量 kd 中定义一个微分增益项 k_(d)k_{d} 。现在通过以下方式定义控制器的传递函数 K(s)K(s) :
K=tf([kd+alpha**kp,kp],[alpha,1])K=t f([k d+a l p h a * k p, k p],[a l p h a, 1])
Obtain the system open loop transfer function L(s)=G(s)K(s)L(s)=G(s) K(s) by 获得系统的开环传递函数 L(s)=G(s)K(s)L(s)=G(s) K(s) 通过
L=K**G\mathrm{L}=\mathrm{K} * \mathrm{G}
Now obtain the system closed loop transfer function 现在获得系统闭环传递函数
Now display the closed loop system step response by 现在通过显示闭环系统的阶跃响应
step(T); 步(T);
If the response does not meet the specifications, change kp and kd and repeat the procedure until a satisfactory design is obtained. 如果响应不符合规格,请更改 kp 和 kd,并重复该过程,直到获得满意的设计。
Question 4.3 From the plot, measure M_(p)M_{p} and t_(p)t_{p}. Does your design meet the specifications? Record the final values of k_(p)k_{p} and k_(d)k_{d}. Record the transfer function K(s)K(s), the system open loop transfer function L(s)L(s) and the closed loop transfer function T(s)T(s). 问题 4.3 从图中测量 M_(p)M_{p} 和 t_(p)t_{p} 。您的设计符合规格吗?记录 k_(p)k_{p} 和 k_(d)k_{d} 的最终值。记录传递函数 K(s)K(s) 、系统开环传递函数 L(s)L(s) 和闭环传递函数 T(s)T(s) 。
Obtain the Bode plot of the controller transfer function K(s)K(s) by 获取控制器传递函数 K(s)K(s) 的波德图
bode (K) 博德 (K)
Question 4.4 Explain the Bode plot characteristics. 问题 4.4 解释波德图特性。
Obtain the Bode plot of the system open loop transfer function L(s)L(s) by 获取系统开环传递函数 L(s)L(s) 的波德图
bode (L) 波德 (L)
Obtain the gain margin GMG M, phase margin Pm, and associated frequencies omega_(cg)\omega_{c g} and omega_(cp)\omega_{c p} by [GM, PM, Wcg,Wcp] = margin(L) 获取增益裕度 GMG M 、相位裕度 Pm 和相关频率 omega_(cg)\omega_{c g} 和 omega_(cp)\omega_{c p} ,通过 [GM, PM, Wcg, Wcp] = margin(L)
You can convert GM to decibels by 您可以通过以下方式将 GM 转换为分贝:
20**log 10(GM)20 * \log 10(\mathrm{GM})
Question 4.5 Record the gain margin, phase margin, and associated frequencies. Show the gain margin and phase margin on the Bode plot. 问题 4.5 记录增益裕度、相位裕度及相关频率。在波特图上显示增益裕度和相位裕度。
Obtain the closed loop poles and zeros by 获得闭环极点和零点的方法是
pole(T) 杆(T)
zero(T) 零(T)
Plot the closed loop system poles and zeros on the ss-plane by 在 ss 平面上绘制闭环系统的极点和零点
pzmap(T);
Question 4.6 Record and comment on the closed loop poles and zeros. 问题 4.6 记录并评论闭环极点和零点。
5 Pole placement using state feedback (Tutorial 4, due date is 2nd December) 使用状态反馈的五极点配置(教程 4,截止日期为 12 月 2 日)
In this section, a state feedback controller is designed which will place the closed loop eigenvalues at desired locations (background about state feedback controller is given in Appendix A). The assumption is made here that the system states are directly measurable using sensing devices. This, however, is frequently not a practical or cost-effective proposition. In such cases, it is possible to construct state estimators (or observers) which estimate the values of the states. 在本节中,设计了一种状态反馈控制器,该控制器将闭环特征值放置在期望位置(关于状态反馈控制器的背景信息见附录 A)。这里假设系统状态可以通过传感设备直接测量。然而,这在实际操作中往往不是一个可行或具有成本效益的方案。在这种情况下,可以构建状态估计器(或观察器)来估计状态的值。
A state space equivalent representation of the plant is given by 植物的状态空间等效表示为
G(s)=C(sI-A)^(-1)B+DG(s)=C(s I-A)^{-1} B+D
and this can be obtained by 这可以通过获得
Gss=ss(G)
Question 5.1 Record the state space representation produced by MATLAB. 问题 5.1 记录 MATLAB 生成的状态空间表示。
There are an infinite number of equivalent state space representations. If SS is any square invertible matrix with dimension equal to the number of states, then equivalent representations of (A,B,C,D)(A, B, C, D) are given by (SAS^(-1),SB,CS^(-1),D)\left(S A S^{-1}, S B, C S^{-1}, D\right). 有无限数量的等效状态空间表示。如果 SS 是任何维度等于状态数量的可逆方阵,则 (A,B,C,D)(A, B, C, D) 的等效表示由 (SAS^(-1),SB,CS^(-1),D)\left(S A S^{-1}, S B, C S^{-1}, D\right) 给出。
We can convert the MATLAB state space representation to a simplified representation, by setting S=OS=\mathcal{O}, where O\mathcal{O} is a matrix known as the observability matrix (this can be proved by means of the Cayley-Hamilton Theorem, see Appendix B for details). The observability matrix can also provide a test for the observability of the plant. The observability matrix is defined (for a 3rd order system ) as 我们可以通过设置 S=OS=\mathcal{O} 将 MATLAB 状态空间表示转换为简化表示,其中 O\mathcal{O} 是一个称为可观测性矩阵的矩阵(这可以通过凯莱-汉密尔顿定理证明,详细信息见附录 B)。可观测性矩阵还可以提供对系统可观测性的测试。可观测性矩阵的定义(对于三阶系统)为
O=[[C],[CA],[CA^(2)]]\mathcal{O}=\left[\begin{array}{c}
C \\
C A \\
C A^{2}
\end{array}\right]
and can be obtained by 并可以通过获得
S=obsv (Gss.a, Gss.c)
The state space system is transformed into the simplified representation by 状态空间系统通过以下方式转化为简化表示:
Gss=ss2ss (Gss, S)
You can check that this state space representation is equivalent to the original plant by 您可以通过检查该状态空间表示是否等同于原始系统来验证
tf(Gss)
Question 5.2 Record the transformed state space representation and the transformation/observability matrix S. Calculate the state space representation by hand, and compare the results to those given by MATLAB. 问题 5.2 记录变换后的状态空间表示和变换/可观测性矩阵 S。手动计算状态空间表示,并将结果与 MATLAB 给出的结果进行比较。
Figure 3: Closed loop system with state feedback controller 图 3:带状态反馈控制器的闭环系统
Define a MATLAB vector P which contains the desired closed loop pole positions of the closed loop system. Place the two dominant poles at the positions required to meet the design objective (from Section 1), and place the third pole at least a factor of 5 away from the complex pole pair. For example, if the desired pole positions are {-3+-2j,-16}\{-3 \pm 2 j,-16\}, define 定义一个 MATLAB 向量 P,其中包含闭环系统所需的闭环极点位置。将两个主导极点放置在满足设计目标所需的位置(来自第 1 节),并将第三个极点放置在与复极点对至少相距 5 的位置。例如,如果所需的极点位置为 {-3+-2j,-16}\{-3 \pm 2 j,-16\} ,则定义
Question 5.3 Record and explain how you calculated the desired pole positions 问题 5.3 记录并解释您是如何计算所需的极点位置的
Now obtain the state feedback gain matrix K=[K_(1),K_(2),K_(3)]K=\left[K_{1}, K_{2}, K_{3}\right] such that the control input u(t)u(t) is 现在获得状态反馈增益矩阵 K=[K_(1),K_(2),K_(3)]K=\left[K_{1}, K_{2}, K_{3}\right] ,使得控制输入 u(t)u(t) 为
and the closed loop eigenvalues, i.e. the eigenvalues of A-B**KA-B * K are those specified in vector P . This can be done in MATLAB by the command 闭环特征值,即 A-B**KA-B * K 的特征值,是向量 P 中指定的特征值。这可以通过 MATLAB 中的命令完成。
Question 5.4 Record the values of K. Calculate the state feedback matrix by hand and verify the MATLAB result. 问题 5.4 记录 K 的值。手动计算状态反馈矩阵并验证 MATLAB 结果。
Check the closed loop eigenvalues by 检查闭环特征值通过
eig(Gss.a-Gss.b*K)
Question 5.5 Record and comment on the closed loop eigenvalues. 问题 5.5 记录并评论闭环特征值。
Obtain the closed loop state space system for state feedback by 通过状态反馈获得闭环状态空间系统
Tss=ss(Gss.a-Gss.bK, Gss.bK(1),Gss.c,Gss.d)
Obtain the closed loop transfer function by 获得闭环传递函数的方法是
T=tf(Tss)\mathrm{T}=\mathrm{tf}(\mathrm{Tss})
Obtain step response of the closed loop system shown in Figure 3 by 获取图 3 所示闭环系统的阶跃响应
step(Tss) 步骤(Tss)
Question 5.6 Record and comment on the closed loop state space system and transfer function. 问题 5.6 记录并评论闭环状态空间系统和传递函数。
From the closed loop step response plot, measure M_(p)M_{p} and t_(p)t_{p}. Does your design meet the specifications? If not, explain why. What is the main disadvantage of state feedback? 从闭环阶跃响应图中,测量 M_(p)M_{p} 和 t_(p)t_{p} 。您的设计符合规格吗?如果不符合,请解释原因。状态反馈的主要缺点是什么?
Appendix A - State Space Controllers Design 附录 A - 状态空间控制器设计
The state variable representation provides a complete (internal) description of a system. This may exhibit oscillations, which are masked if we maintain the transfer function input/output formulation. We can use the states to give better control than obtained by simple output feedback. 状态变量表示提供了系统的完整(内部)描述。这可能会表现出振荡,如果我们保持传递函数的输入/输出形式,这些振荡会被掩盖。我们可以利用状态来提供比简单输出反馈获得的更好的控制。
Pole Placement 极点配置
The poles of a system are also the eigenvalues of the system matrix A\mathbf{A}, thus we speak of pole assignment or eigenvalue assignment as having the same meaning. The characteristic equation of matrix A\mathbf{A} is given by the determinant of 系统的极点也是系统矩阵 A\mathbf{A} 的特征值,因此我们将极点配置或特征值配置视为具有相同的含义。矩阵 A\mathbf{A} 的特征方程由以下行列式给出:
The expansion of equation (1) produces an nnth order polynomial, where roots lambda_(1),lambda_(2),cdotslambda_(n)\lambda_{1}, \lambda_{2}, \cdots \lambda_{n} are eigenvalues of A\mathbf{A}. The object of state variable feedback is to move these eigenvalues to desired locations. 方程(1)的展开产生一个 nn 阶多项式,其中根 lambda_(1),lambda_(2),cdotslambda_(n)\lambda_{1}, \lambda_{2}, \cdots \lambda_{n} 是 A\mathbf{A} 的特征值。状态变量反馈的目的是将这些特征值移动到期望的位置。
Example 1 A system is described in the state space form 示例 1 一个系统以状态空间形式描述
Hence we need a method to determine K=[[k_(1),k_(2),k_(3)]]\mathbf{K}=\left[\begin{array}{lll}k_{1} & k_{2} & k_{3}\end{array}\right] to shift three open loop poles at s=-1s=-1. 因此,我们需要一种方法来确定 K=[[k_(1),k_(2),k_(3)]]\mathbf{K}=\left[\begin{array}{lll}k_{1} & k_{2} & k_{3}\end{array}\right] 以在 s=-1s=-1 处移动三个开环极点。
Consider the closed loop system with state variable feedback in Fig. 4. The block diagram represents the internal structure of the system. 考虑图 4 中的状态变量反馈闭环系统。该框图表示系统的内部结构。
The state representation of the state variable feedback closed loop system is 状态变量反馈闭环系统的状态表示为
Thus given mu_(1),mu_(2)cdots\mu_{1}, \mu_{2} \cdots we can find the values of b_(1),b_(2),b_(3),cdotsb_{1}, b_{2}, b_{3}, \cdots. 因此,给定 mu_(1),mu_(2)cdots\mu_{1}, \mu_{2} \cdots ,我们可以找到 b_(1),b_(2),b_(3),cdotsb_{1}, b_{2}, b_{3}, \cdots 的值。
In general the open loop characteristic polynomial is 一般来说,开环特征多项式是
Figure 4: State variable feedback block diagram 图 4:状态变量反馈框图
Comparing (2) and (3), A has been replaced by A-BK\mathbf{A}-\mathbf{B K} and we can write in comparison form 比较 (2) 和 (3),A 已被 A-BK\mathbf{A}-\mathbf{B K} 替换,我们可以以比较形式写出
Thus knowing a_(n),a_(n-1),cdots,a_(1),b_(n),b_(n-1),cdots,b_(1)a_{n}, a_{n-1}, \cdots, a_{1}, b_{n}, b_{n-1}, \cdots, b_{1} we can calculate k_(1),k_(2),cdots,k_(n)k_{1}, k_{2}, \cdots, k_{n}. 因此知道 a_(n),a_(n-1),cdots,a_(1),b_(n),b_(n-1),cdots,b_(1)a_{n}, a_{n-1}, \cdots, a_{1}, b_{n}, b_{n-1}, \cdots, b_{1} ,我们可以计算 k_(1),k_(2),cdots,k_(n)k_{1}, k_{2}, \cdots, k_{n} 。
In the present example, from equation (2) and the required pole positions, i.e. poles at -2,-1+j,-1-j-2,-1+j,-1-j we have 在本例中,从方程(2)和所需的极点位置,即极点在 -2,-1+j,-1-j-2,-1+j,-1-j ,我们得到了
Hence b_(1)=4,b_(2)=6,b_(3)=4b_{1}=4, b_{2}=6, b_{3}=4, Similarly for the existing pole positions 因此 b_(1)=4,b_(2)=6,b_(3)=4b_{1}=4, b_{2}=6, b_{3}=4 ,现有的杆位也类似
The MATLAB command for pole placement is K=place(A,B,p)K=p l a c e(A, B, p). Therefore, the MATLAB code to solve the present exercise is: MATLAB 中用于极点配置的命令是 K=place(A,B,p)K=p l a c e(A, B, p) 。因此,解决本练习的 MATLAB 代码是:
It can be shown that the pole allocation problem is solvable for all choices of closed loop poles if and only if, the open-loop system is completely controllable and measurements of all the state variables are available. 可以证明,极点配置问题在所有闭环极点的选择下是可解的,当且仅当开环系统是完全可控的,并且所有状态变量的测量值都是可用的。
Notes 笔记
(i) One problem which has not been addressed is how to select the required pole locations. 一个尚未解决的问题是如何选择所需的极点位置。
(ii) What happens if all the state variables are not available, this leads to the study of observers? (ii) 如果所有状态变量都不可用,会发生什么,这就引出了观测器的研究?
Controllability 可控性
A system is controllable if it can be driven to an arbitrary state by an applied input. Consider the example 一个系统是可控的,如果它可以通过施加输入驱动到任意状态。考虑以下例子
Now the state vector x(s)\mathbf{x}(s) does not contain the pole at s=-1s=-1. This has been cancelled by the zero generated by the vector b\mathbf{b}. Hence the system is uncontrollable from the input uu because the natural mode associated with the eigenvalue lambda=-1\lambda=-1 can never be excited. 现在状态向量 x(s)\mathbf{x}(s) 不包含位于 s=-1s=-1 的极点。这已被向量 b\mathbf{b} 生成的零所抵消。因此,系统从输入 uu 来看是不可控的,因为与特征值 lambda=-1\lambda=-1 相关的自然模式永远无法被激发。
Now modify this input from 现在将此输入修改为
[[1],[-2]]u(s)" to "[[1],[0]]u(s)\left[\begin{array}{c}
1 \\
-2
\end{array}\right] u(s) \text { to }\left[\begin{array}{l}
1 \\
0
\end{array}\right] u(s)
In this case the system is controllable since every mode can be excited by the input. 在这种情况下,系统是可控的,因为每种模式都可以通过输入激发。
In general, the controllability may be assessed from the matrix 一般来说,控制性可以通过矩阵来评估
For the system to be controllable, the controllability matrix P\mathbf{P} must be full rank (not shown). Matlab commands to check controllability: 为了使系统可控,可控性矩阵 P\mathbf{P} 必须是满秩的(未显示)。检查可控性的 Matlab 命令:
which is of full rank so that the system is controllable. 该系统的秩为满秩,因此该系统是可控的。
Note that the controllability depends upon the coefficient matrix A\mathbf{A} and the distribution or input matrix b\mathbf{b}. Thus by adding inputs we can change the control of a system without changing its structure. A system may be controllable in a mathematical sense but the control action may be weak. 请注意,可控性取决于系数矩阵 A\mathbf{A} 和分布或输入矩阵 b\mathbf{b} 。因此,通过添加输入,我们可以在不改变系统结构的情况下改变系统的控制。一个系统在数学意义上可能是可控的,但控制作用可能很弱。
Note: Rank of a matrix 注意:矩阵的秩
The rank of a matrix is the maximum number of independent columns (rows) in the matrix. Alternatively, the rank of a matrix is the largest square array in the matrix with a non-vanishing determinant. 矩阵的秩是矩阵中独立列(行)的最大数量。或者,矩阵的秩是矩阵中具有非零行列式的最大方阵。
The computation of determinants for the determination of rank can be very time consuming. Rank can also be assessed by row/column operations. 计算行列式以确定秩可能非常耗时。秩也可以通过行/列操作来评估。
A n xx nn \times n matrix has rank rr with r < nr<n only if the matrix is singular. 一个 n xx nn \times n 矩阵的秩为 rr 仅当该矩阵是奇异的。
Observability 可观察性
A system is observable if the state of x\mathbf{x} can be deduced from the available output y\mathbf{y}. Observability implies that any mode that is excited can be detected (observed) in the output y\mathbf{y}. 一个系统是可观测的,如果可以从可用的输出 y\mathbf{y} 中推导出状态 x\mathbf{x} 。可观测性意味着任何被激励的模式都可以在输出 y\mathbf{y} 中被检测到(观察到)。
Example 3 Consider the system in Fig. 5 例子 3 考虑图 5 中的系统
A zero is generated by the output connection. This system is controllable, but not observable. 零是通过输出连接生成的。该系统是可控的,但不可观察。
For a system to be observable the matrix Q\mathbf{Q}, must be full rank where 为了使系统可观测,矩阵 Q\mathbf{Q} 必须是满秩的
and y=cx\mathbf{y}=\mathbf{c x}. 和 y=cx\mathbf{y}=\mathbf{c x} 。
Note that Q\mathbf{Q} depends only on the coefficients in A\mathbf{A} and the output or measurement matrix c\mathbf{c}. 请注意, Q\mathbf{Q} 仅依赖于 A\mathbf{A} 中的系数和输出或测量矩阵 c\mathbf{c} 。
Figure 5: Block diagram 图 5:框图
The addition of more measurements may satisfy the observability requirement (i.e. modify matrix c\mathbf{c} ), and further controls or the inputs may satisfy the controllability matrix. 增加更多的测量可能满足可观测性要求(即修改矩阵 c\mathbf{c} ),进一步的控制或输入可能满足可控性矩阵。
This highlights the problem of transfer function testing. The inputs may cause oscillations, which are not observed. Therefore, the transfer function matrix determined by experiment will yield the correct plant model only if the system is observable and controllable. 这突出了传递函数测试的问题。输入可能会导致振荡,而这些振荡并未被观察到。因此,实验确定的传递函数矩阵只有在系统可观测和可控的情况下,才能产生正确的植物模型。
Matlab commands to test observability: 测试可观性的 Matlab 命令:
(i) If the system is observable and controllable then the response of the output reflects changes in the input. 如果系统是可观察和可控的,那么输出的响应会反映输入的变化。
(ii) If the system is controllable and not observable then changing the input has a controlling effect but it cannot be observed at the output. 如果系统是可控的但不可观测,那么改变输入会产生控制效果,但在输出中无法观察到。
(iii) If the system is observable and not controllable then you can observe the output response but you cannot control it by changing the input. (iii) 如果系统是可观测的但不可控的,那么你可以观察到输出响应,但无法通过改变输入来控制它。
(iv) If the system is not observable and not controllable then you cannot compare the output response with changes in the input. 如果系统不可观测且不可控,则无法将输出响应与输入的变化进行比较。
Appendix B - Transformation of state space system 附录 B - 状态空间系统的变换
The method to convert a transfer function into a representation given by (for a 3rd order SISO system) 将传递函数转换为表示的方法(对于一个三阶 SISO 系统)
where the characteristic equation s^(3)+a_(1)s^(2)+a_(2)s+a_(3)=0=det(sI-A)s^{3}+a_{1} s^{2}+a_{2} s+a_{3}=0=\operatorname{det}(s I-A). 特征方程 s^(3)+a_(1)s^(2)+a_(2)s+a_(3)=0=det(sI-A)s^{3}+a_{1} s^{2}+a_{2} s+a_{3}=0=\operatorname{det}(s I-A) 。
To transform any state space system represented by (A,B,C,D)(A, B, C, D) into the representation given by ( tilde(A), tilde(B), tilde(C), tilde(D))(\tilde{A}, \tilde{B}, \tilde{C}, \tilde{D}), we can use the transformation 要将任何由 (A,B,C,D)(A, B, C, D) 表示的状态空间系统转换为由 ( tilde(A), tilde(B), tilde(C), tilde(D))(\tilde{A}, \tilde{B}, \tilde{C}, \tilde{D}) 给出的表示,我们可以使用以下变换
where SS is the observability matrix given by 其中 SS 是由以下公式给出的可观测性矩阵
S=[[C],[CA],[CA^(2)]]S=\left[\begin{array}{c}
C \\
C A \\
C A^{2}
\end{array}\right]
Proof: It is clear that tilde(C)S=C\tilde{C} S=C hence tilde(C)=CS^(-1)\tilde{C}=C S^{-1}. 证明:显然 tilde(C)S=C\tilde{C} S=C ,因此 tilde(C)=CS^(-1)\tilde{C}=C S^{-1} 。
Now tilde(A)=SAS^(-1)\tilde{A}=S A S^{-1}, so tilde(A)S=SA\tilde{A} S=S A. Expanding tilde(A)S\tilde{A} S gives 现在 tilde(A)=SAS^(-1)\tilde{A}=S A S^{-1} ,所以 tilde(A)S=SA\tilde{A} S=S A 。扩展 tilde(A)S\tilde{A} S 得到
SA=C[[A],[A^(2)],[A^(3)]]S A=C\left[\begin{array}{c}
A \\
A^{2} \\
A^{3}
\end{array}\right]
Now from the Cayley-Hamilton theorem, A^(3)+a_(1)A^(2)+a_(2)A+a_(3)I=0A^{3}+a_{1} A^{2}+a_{2} A+a_{3} I=0, hence tilde(A)S=SA\tilde{A} S=S A. 现在根据凯莱-哈密顿定理, A^(3)+a_(1)A^(2)+a_(2)A+a_(3)I=0A^{3}+a_{1} A^{2}+a_{2} A+a_{3} I=0 ,因此 tilde(A)S=SA\tilde{A} S=S A 。