在上一个视频中我展示了我们可以 in the last video I showed that we can
操纵a的四个电机 manipulate the four motors of a
四轴飞行器在3d空间中操纵它 quadcopter to maneuver it in 3d space by
让它滚动俯仰和改变 getting it to roll pitch yaw and change
它的推力我们也涵盖了四个 its thrust we also covered the four
我们有我们所掌握到的传感器 sensors that we have at our disposal to
估计现在的系统国家 estimate the system States now in this
视频我们将使用这些知识 video we're going to use that knowledge
设计控制系统架构 to design a control system architecture
悬停四轴飞行器意味着 for hovering a quadcopter that means
我们要弄清楚我们的状态 we're gonna figure out which states we
需要反馈 need to feedback
我们需要构建多少个控制器 how many controllers we need to build
以及这些控制器如何与之交互 and how those controllers interact with
彼此我是布赖恩，欢迎来到 each other I'm Brian and welcome to a
MATLAB Tech Talk 在控制系统中 MATLAB Tech Talk in the control system
我们正在开发的工厂是迷你型 we're developing the plant is the mini
无人机本身需要四个电机速度 drone itself it takes four motor speeds
作为输入然后旋转螺旋桨 as inputs which then spin the propellers
产生力和扭矩 generating forces and torques that
影响输出状态的输出 affect the output state the output that
我们想要的是让迷你无人机悬停 we want is to have the mini drone hover
在固定的高度所以这个问题 at a fixed altitude so the question
变成我们怎么命令这四个 becomes how do we command these four
电机自动发生这种情况 motors autonomously so that that happens
好吧开始让我们假设相反 well to start let's assume that rather
比我们想要的自主 than do it autonomously we want to
手动命令迷你无人机 command the mini drone manually that is
我们有切换遥控器 we have a remote control with toggles
直接控制所有四个电机 that directly control all four motor
加速左切换将控制 speeds the left toggle would control the
两个前电机和右拨动开关 two front motors and the right toggle
这将控制两个后电机 would control the two rear motors this
让你进入反馈路径，因为 puts you in the feedback path because
你可以看到无人机在哪里然后 you can see where the drone is and then
对其立场和态度做出反应 react to its position and attitude by
非常具体地移动四个肘节 moving the four toggles in very specific
如果你想增加推力的方法 ways if you want to increase thrust
你可以通过移动加速所有四个电机 you'd speed up all four motors by moving
两个在这个方向上的跷跷板偏航 the two toggles in this direction yaw
需要两个相对的电机 requires that two opposing motors
提高他们的速度和其他两个 increase their speed and the other two
降低速度，使 阳气离开 decrease speed so that yang left for
例如需要这样 的 example would require this kind of
切换动作然后滚动车辆 toggle motion then to roll the vehicle
你需要增加其中一个 you would need to increase one of the
左/右对并减少另一对 left/right pairs and decrease the other
并且你可以驾驶车辆 and to pitch the vehicle you would
增加一个前背对和 increase one of the front back pairs and
以这种方式减少对方你 decrease the other in this way you as
反馈控制器可以获得 the feedback controller could get the
通过专业改变无人机来徘徊 drone to hover by expertly changing the
现在命令这四个电机 commands to these four motors now while
这是可能的方面思考 this is possible thinking in terms of
电机速度似乎真的很难，我们 motor speed seems really hard and we
我想让我们的工作更轻松 want to make our job easier
所以我们可以使用电机混合 so instead we can use the motor mixing
我们在最后创建的算法 algorithm that we created in the last
视频和命令推力滚动俯仰和 video and command thrust roll pitch and
直接偏航 yaw directly
当我们命令推力例如这个 when we command thrust for example this
单推力命令均匀分割 single thrust command gets split evenly
对于所有四个电机，偏航命令是 to all four motors the yaw command is
两个电机正向分配 distributed positive to two motors and
负其他两个等 negative to the other two and so on
现在我们的遥控肘节了 now our remote-controlled toggles are
与直观的滚动间距对齐 aligned with the intuitive roll pitch
偏航和推力而不是 yaw and thrust rather than the
令人费解的电机速度就是这样 mind-bending motor speeds this is the
控制器配置很多 controller configuration that a lot of
操作员在手动飞行时使用 operators use when manually flying their
四轮直升机， 但事实证明 quad copters but it turns out thinking
在滚动俯仰偏航和推力方面 in terms of roll pitch yaw and thrust is
当我们开发一个 also beneficial when we're developing an
自动控制系统，所以我们会保持 autonomous control system so we'll keep
电机混合算法和构建一个 the motor mixing algorithm and build a
用它来反馈控制系统 feedback control system with it in the
循环以及所有权利让我们摆脱 loop as well all right let's get rid of
人类操作员并思考如何 the human operator and think about how
我们可以完成同样的事情 we can accomplish the same thing
自主 autonomously
我们首先关注重点 we'll start by focusing on the thrust
命令推力始终是一样的 command thrust is always in the same
相对于无人机机身的方向 direction relative to the drone airframe
它沿着迷你无人机的z轴 it's along the z axis of the mini drone
这意味着如果无人机正在飞行 that means that if the drone is flying
水平和z轴对齐 level and the z axis is aligned with the
重力矢量然后增加推力 gravity vector then increasing thrust
导致无人机增加 causes the drone to increase its
高度变化率是如何的快 altitude rate which is how fast it's
上升和下降的推力下降 rising and decreasing thrust drops the
海拔率， 这很漂亮 altitude rate and that's pretty
但是如果我们的无人机是直截了当的话 straightforward however if our drone is
以陡峭的俯仰或滚转角度 飞行 flying at a steep pitch or roll angle
然后增加推力耦合 then increasing thrust is coupled to
高度和水平速度 both altitude rate and horizontal speed
因此， 如果我们正在建立一个控制器 therefore if we're building a controller
对于可能飞行 的赛车无人机 for a racing drone that's likely to fly
在极端滚动和俯仰角度， 然后我们 at extreme roll and pitch angles then we
需要考虑这种耦合 need to take this coupling into account
但是对于我们简单的悬停控制器 however for our simple hover controller
我只是假设辊 I'm just going to assume that the roll
在俯仰角度总是很小 in pitch angles are always really small
以这种方式只改变推力 in this way changing the thrust only
有意义地影响高度和 meaningfully impacts altitude rate and
闲来无事所以用这个信息，我们 nothing else so with this information we
可以开始我们的控制设计开始 can start our control design to begin
让我们构建一个使用的控制器 let's build a controller that uses
如果我们的话，我会调整高度 thrust to adjust the altitude if we're
能够测量无人机的高度 able to measure the drone altitude then
我们可以把它反馈给它来比较它 we can feed it back to compare it to an
高度参考产生的错误 altitude reference the resulting error
然后送入高度控制器 is then fed into an altitude controller
正在使用该信息 that's using that information to
确定如何增加或减少 determine how to increase or decrease
我们现在可以想到这一点 thrust for now we can think of this
控制器有某种形式的PID controller has some form of a PID
控制器和我们要谈 controller and we're going to talk about
如何在未来的视频中调整它 how to tune it in future videos in this
海 sea
所以如果无人机是这个控制器 so with this controller if the drone is
徘徊太低的高度错误会 hovering too low the altitude error will
积极的，推力命令会 be positive and the thrust command will
增加导致所有四个电机 increase causing all four motors to
同时和无人机一起加速 speed up at the same time and the drone
如果无人机太高那么会上升 will rise if the drone is too high then
所有四个电机将有所放缓，使 all four motors will slow down so that
无人机将下降，所以就是这样 the drone will descend so that's it
就在我们的工作已经完成，我们已经开发了一个 right our job is done we've developed a
简单的高度控制器将 simple altitude controller which will
徘徊我们的迷你无人机，它是完美的 hover our mini drone and it's perfect
但您知道，这不是 except that you know that that's not the
因为有像骚乱的 情况 case because there are disturbances like
风阵风会引起一点点 wind gusts that will induce a little
滚动或投球到系统和什么时候 roll or pitch into the system and when
这种情况不仅会发生 that happens the thrust will not only
调整高度但也创造了一些 adjust altitude but also create some
水平运动和无人机将 horizontal motion and the drone will
开始离开你和什么 start to move away from you and what
好的是悬停控制器 good is a hover controller that
保持高度，但要求你 maintains altitude but requires you to
追逐它或它会撞到墙壁 chase after it or it'll crash into walls
我们很清楚 ，这几乎不会徘徊 that's hardly hovering nope we clearly
需要一个更好的控制系统 need a better control system
架构和我们应该开始由 architecture and we should start by
试图保持水平飞行 trying to maintain level flight by
将滚动和俯仰角控制为0 controlling roll and pitch angles to 0
如果我们能保持迷你无人机的程度 degrees if we can keep the mini drone
水平然后再次推力只会 level then thrust once again will only
影响高度和无人机不会 impact altitude and the drone won't
现在我们从最后知道了 wander away now we know from the last
我们能够指挥推力的视频 video that we're able to command thrust
独立滚动俯仰和偏航 roll pitch and yaw independently that is
我们可以命令一个动作，而不 we can command one action without
知道我们可以影响其他人 affecting the others knowing this we can
再创建三个反馈控制器 create three more feedback controllers
一个用于滚动俯仰和偏航 one for roll pitch and yaw exactly the
就像我们现在所做的那样 same way that we did for thrust now to
给我们多一点 的房间我要去 give us a little more room I'm going to
重新绘制框图，我们将 redraw the block diagram and we'll
浓缩电机混合算法 condense the motor mixing algorithm
阻止只是说MMA现在的输出 block to just say MMA now the output of
植物不仅仅是海拔高度 the plant is more than just altitude
我们还需要衡量或者 we're also going to need to measure or
估计滚动俯仰角和偏航角 estimate the roll pitch and yaw angles
同样，我要养活所有的东西 as well and I'm gonna feed all of the
系统状态返回然后标记哪个 system States back and then label which
状态我正在为每个控制器使用 state I'm using for each controller so
希望这一切都对你有意义 hopefully this all makes sense to you
我正在喂估计的滚动角度 I'm feeding the estimated roll angle
进入滚动控制器和 into the roll controller and the
估计进入控制器的偏航角 estimated yaw angle into the controller
等等好吗所以现在我们有什么 and so on alright so now what do we have
好吧，我们有四个独立或 well we have four independent or
解耦控制器一个用于推力 decoupled controllers one for thrust
这实际上是一个高度控制器 which is really an altitude controller
因为我们声称在球场上的作用很小 since we're claiming small role in pitch
角度，然后三个控制器 angles and then three controllers that
正在努力 are trying to
滚动俯仰和偏航的零度 zero degrees in roll pitch and yaw
这应该保持 respectively this should maintain
高度，它应该保持迷你 altitude and it should keep the mini
无人机面向前方并与之保持平衡 drone facing forward and level with the
地面现在这显然是一个更好的 ground now this is obviously a better
悬停控制器比我们的第一个但是 hover controller than our first one but
再次，它仍然不完美 again it's still not perfect to
明白为什么让我们玩我们的 understand why let's play our
假想的风阵风 hypothetical wind gust through this
系统现在风可能最初 system now the wind might initially
引入一点滚动角但是我们的 introduce a little roll angle but our
滚动控制器将删除该错误 roll controller will remove that error
并让无人机回到水平飞行 and get the drone back to level flight
然而，在这期间的短暂时间 however for a very brief time during the
滚动推力矢量不直 roll the thrust vector is not straight
上下，因此无人机将 up and down and therefore the drone will
水平移动了一点点 have moved horizontally a little bit
然后另一阵风来了 then another gust comes and causes
另一个滚动或俯仰错误和 another roll or pitch error and the
无人机走开一点点这样 drone walks away a little bit more so
即使无人机不会逃跑 even though the drone won't run away
像我们的第一个控制器一样 continuously like our first controller
这个控制器仍然允许它 this controller will still allow it to
慢慢地蜿蜒而去，没有任何东西 meander away slowly there's nothing in
我们的控制系统架构 our control system architecture that
将无人机带回其中 will bring the drone back to its
起始位置让我们改进这一点 starting position let's improve this
控制系统做我正在做的事情 control system to do just that I'm going
再一次清理我们的方框图 to once again clean up our block diagram
为额外的控制腾出一些空间 to make some room for additional control
现在逻辑还可以，我们有一点点 logic okay now that we have a little
房间让我们考虑一下角色和角色 room let's think about what role and
在徘徊的时候，球场正在做 pitch are doing while hovering it's
很有诱惑力地说两个角度都应该 tempting to say that both angles should
为零，这就是我们设置它的方式 be zero and that's how we set up this
当前版本的控制器 current version of the controller
但是他们可能需要非零 however they may need to be nonzero in
如果我们愿意，可以悬停 order to hover for example if we want to
徘徊在一个强大的恒风然后 hover in a strong constant wind then the
无人驾驶飞机将要瘦到随风 drone will have to lean into the wind at
一些角度来维持它的地面 some angle to maintain its ground
这样而不是指明那个位置 position so rather than specifying that
我们希望水平飞行真的是我们需要的 we want level flight really what we need
是地面位置控制器 is a ground position controller
东西会认识到，当 something that will recognize when the
无人机迷了路，使 drone is wandering off and make the
必要的更正，以恢复它 necessary Corrections to bring it back
到参考点x和y，但只是 to the reference point x and y but just
因为我们不想挑选具体的 because we don't want to pick specific
在俯仰角度中的作用并不意味着 role in pitch angles that doesn't mean
我们不需要 音调的卷 that we don't need the roll in pitch
控制器记得第一个 controllers remember from the first
四轴飞行器无法播放的视频 video that a quadcopter is incapable of
向左或向右移动 moving left right forward or backward
没有先滚动或投球 without first rolling or pitching into
旅行所需的方向，使我们的 the desired direction of travel so our
控制系统需要耦合位置 control system needs to couple position
滚动和俯仰的错误 errors with roll and pitch
这是一个复杂的发声组 and this is a complicated sounding set
演习，但幸运的是由此产生的 of maneuvers but luckily the resulting
控制器是很简单的 controller is pretty simple to
明白我们可以反馈一下 understand we can feedback the
迷你无人机测量XY位置和 mini-drones measured XY position and
将它与参考文献进行比较即可获得 compare it to the reference to get the
现在位置错误我们会说 position error for now we'll say that
基准位置是0044这 the reference position is zero zero this
我们的控制器将导致无人机 way our controller will cause the drone
悬停在起飞点的正上方 to hover right above the take-off point
现在我们的位置控制器需要 now our position controller takes the
将位置错误作为输入然后 position error as an input and then
输出滚动和俯仰角度 outputs roll and pitch angles these are
参考角度是在角色 the reference angles that are role in
音高控制器正试图跟随 pitch controllers are trying to follow
因此，而不是我们作为设计师采摘 so instead of us as the designer picking
滚动和俯仰角我们正在让 roll and pitch angles we're letting the
位置控制器为我们创建它们 position controller create them for us
通过这种方式，位置控制器是 in this way the position controller is
外循环，它正在生成 the outer loop and it's generating the
内循环的引用命令 reference commands for the inner loop
这些是滚动和俯仰控制器 roll and pitch controllers these are
级联循环现在作为快速侧面说明 cascaded loops now as a quick side note
测得的偏航角也会进入 the measured yaw angle also feeds into
位置控制器的原因非常 the position controller the reason very
简单来说就是XY位置误差 briefly is that the XY position error is
相对于地面或世界 relative to the ground or the world
参考框架而滚动和俯仰 reference frame whereas roll and pitch
相对于 无人机 的身体 are relative to the body of the drone
因此，音调并不总是移动 therefore pitch doesn't always move the
无人机在前世界的方向和滚动 drone in the ex-world direction and roll
并不总是在Y中移动无人机 doesn't always move the drone in the Y
世界方向取决于如何 world direction it depends on how the
无人机旋转或其偏航角度，如果 drone is rotated or its yaw angle so if
我们需要将无人机移动到一个非常好的位置 we need to move the drone to a very
它需要在房间的具体位置 specific spot in the room then it needs
知道哟，以确定是否 to know yo in order to determine whether
辊距或的一些组合 roll pitch or some combination of the
我们需要两个才能实现这一目标 two is needed to achieve that so our
位置控制器使用Yod进行转换 position controller uses Yod to convert
世界XY框架和身体之间 between the world XY frame and the body
XY框架没事 ，让我们走过一个 XY frame all right let's walk through a
想运动，看看所有这些 thought exercise to see how all of these
控制器协同工作以维护 controllers work together to maintain
位置和高度，让我们说 ， position and altitude let's say that the
迷你无人机在飞行水平 mini drone is flying level at the
正确的高度， 但有点太远了 correct altitude but a little too far
离开这个意志的地方的左边 left of where it took off this will
导致产生的位置错误 result in a position error that feeds
进入位置控制器 into the position controller the
控制器的比例部分将 proportional part of the controller will
将该误差乘以常数 multiply that error by a constant which
将请求无人机滚动到 will request that the drone roll to the
对角色控制器会看到这一点 right the role controller will see that
由于无人机存在滚动错误 there is a roll error because the drone
仍然是水平的 is still level
并请求轧制扭矩这将 and request a rolling torque this will
通过电机混合算法进行播放 play through the motor mixing algorithm
并要求左边的电机 and request that the motors on the left
无人机的一面加速了 side of the drone speed up and the
右侧的电机减速 motors on the right side slowed down
这将推出无人机的 this will roll the drone to the
现在命令角度无人机将开始 commanded angle now the drone will begin
向右移动 to move to the right
但自从垂直分量 but since the vertical component of
滚动时推力略小 thrust is slightly smaller when rolled
无人机也将开始失败 the drone will also start to lose
高度控制器的高度 altitude the altitude controller will
感知这个错误并增加推力 sense this error and increase the thrust
相应地命令现在作为无人机 command accordingly now as the drone
继续向右移动 continues moving right the position
错误正在下降，因此 error is dropping and therefore the
要求滚动角度通过 requested roll angle through the
比例路径也在下降 proportional path is also dropping
把无人机带回来了 bringing the drone back level this is
现在我们的悬停是一个很好的架构 now a good architecture for our hover
控制系统但有两个明显 control system but there are two glaring
创建和调整它的障碍 obstacles to creating and tuning it
首先， 这要求我们有办法 first this requires us having a way to
估计该州的横摆间距 estimate the state's yaw roll pitch
高度和XY位置这些都是 altitude and XY position these are the
正在反馈给我们的信号 signals that were feeding back into our
控制器和第二我们需要调整 controllers and second we need to tune
六个PID控制器都相互作用 six PID controllers that all interact
彼此，特别是四个 with each other and specifically four of
它们直接耦合在级联循环中 them directly coupled in cascaded loops
我们将如何处理第一个问题 the way we're going to handle the first
问题是通过组合测量 problem is by combining the measurements
来自我们拥有的四个传感器 from the four sensors we have and in
一些案例使用模型和共同 some cases using a model and a common
过滤以估计每一个 filter to estimate each of those
反馈国家的第二个问题 feedback States for the second problem
我们需要一个良好的系统模型 we need a good model of our system so
我们可以使用基于模型的设计和 that we can use model-based design and
MATLAB和Simulink 调整我们的六个PID MATLAB and Simulink to tune our six PID
控制器其实如果我们只是看看 controllers in fact if we just look at
这个反馈的控制器部分 the controller portion of this feedback
系统你可以看到Simulink system you can see that the Simulink
模型几乎完全一样 model has pretty much the exact same
我们建立的控制器架构 controller architecture that we've built
在此视频中外圈XY位置 in this video the outer loop XY position
控制器正在生成参考 controller is generating the reference
内环的俯仰和滚转角度 pitch and roll angles for the inner loop
控制器还有偏航和 controller there's also the yaw and
每个高度控制器 altitude controllers in each of them
输入电动机混合算法 feed into the motor mixing algorithm in
我们要离开的下一个视频 the next video we're going to leave the
概念和图纸的世界和移动 world of concepts and drawings and move
到Simulink建立实际 over to Simulink to build the actual
该控制系统的软件和 software for this control system and
模拟植物和环境动态 model the plant and environment dynamics
所以，如果你不想错过下一个 so if you don't want to miss the next
TechTalk视频不要忘记 Tech Talk video don't forget to
如果你也订阅这个频道 subscribe to this channel also if you
想看看我的频道控制 want to check out my channel control
系统讲座我涵盖了更多的控制 system lectures I cover more control
他们的理论主题 theory topics they
为观看和我会看到以及感谢 as well thanks for watching and I'll see
你下次 you next time