Quadcopters和其他样式的无人机非常受欢迎 Quadcopters and other styles of drones are extremely popular
即使在树级车辆中，也已编程了复杂的控制系统 Even in tree grade vehicles have sophisticated control systems programmed into them
使他们能够稳定并在很少的人工干预下自主飞行 that allow them to be stable and fly autonomously with very little human intervention
因此，螺旋桨以精确的方式旋转，以控制六个不同自由度的四轴飞行器 Therefore propellers are spun in precise ways to control the quadcopter in six different degrees of freedom
在本系列中，我们将通过 In this series we're gonna walk through
设计控制系统的过程，该系统将使无人机悬停在固定高度 the process of designing a control system that will get a drone to hover at a fixed altitude
现在，即使您不打算编写自己的无人机控制器 Now even if you don't plan on writing your own drone controller
值得了解流程，因为工作流程 it's worth understanding the process because the workflow
我们将要遵循的类似于几乎所有控制项目所需的工作流程 that we're going to follow is similar to the workflow you'll need for almost any control project
话虽这么说 With that being said
该系列使用无人机而不是其他平台 this series is using a drone rather than some other platform
因为硬件的可访问性 because of how accessible the hardware is
以及可用于无人机编程和建模的现有基础架构 and the existing infrastructure available for programming and modeling drones
而且他们真的很有趣 also they're just really fun to fly
因此，考虑到这一点，让我们前往黑板并解决我们的问题 So with that in mind let's head over to the blackboard and set up our problem
我是Brian，欢迎参加MATLAB技术讲座 I'm Brian and welcome to a MATLAB Tech Talk
在本系列中，我们重点介绍四轴飞行器的控制策略 In this series we're focusing on the control strategies for a quadcopter
之所以这样命名是因为它们的四个旋转螺旋桨 named so because of their four rotating propellers
同样，您可以添加更多的旋翼，然后它们采用hexacopter和octocopter之类的名称 similarly you could add more rotors and then they take on names like hexacopter and octocopter
但是所有这些无人机式飞行器都是 but all of these drone style flying machines are part of an entire family of
旋翼飞机称为旋翼飞机 rotating wing aircraft called rotor craft
这包括熟悉的直升机和较不熟悉的旋翼机 This includes the familiar helicopter and the less familiar autogyro
以及其他使用旋转机翼的飞行器 as well as any other flying machine that uses a rotating wing
而不是固定翼来产生升力 rather than a fixed wing to generate lift
即使这些都是旋翼飞行器，但它们都有不同的动力 Even though these are all rotary wing vehicles they all have different dynamics
因此有不同的控制策略 and therefore different control strategies
在本系列中，我们将设计用于四轴飞行器的控制系统，鹦鹉迷你无人机 For this series we're going to be designing a control system for a quadcopter, the parrot mini-drone
现在为了设置 Now in order to set up
我们的控制问题，我们需要花一些时间来了解我们的硬件 our control problem we need to spend a little time understanding our hardware
在这种情况下，硬件已经存在 In this case the hardware already exists
所以我没有能力以任何有意义的方式轻松更换传感器或执行器 so I don't have the ability to easily change the sensors or actuators in any meaningful way
现在，如果您是四轴飞行器开发程序的控制工程师 Now if you're the control engineer for a quadcopter development program
事实并非如此 that wouldn't be the case
您可能应该指导并影响设计过程 you would probably be expected to guide and influence the design process
使硬件经过适当设计以满足您的控制要求 so that the hardware is appropriately designed to meet your control requirements
但是由于我们的硬件已经构建，所以我们必须处理给我们的东西 But since our hardware's already built we have to deal with what's given to us
因此，让我们看一下迷你无人机，看看我们需要使用什么 So let's take a look at the mini drone and see what we have to work with
我们将从传感器开始 We'll start with the sensors
如果我们翻过来看看底部 If we flip it over and look at the bottom
您可以看到两个传感器 there are two sensors that you can see
尽管带有栅格的是超声波传感器 though one with the grid is an ultrasound sensor
用于测量垂直距离 that's used to measure vertical distances
它发出一个高频声脉冲，并测量该脉冲从地板上弹回需要多长时间 it sends out a high-frequency sound pulse and measures how long it takes that pulse to bounce off the floor
然后返回传感器 and return back to the sensor
从地面和无人机之间的测量时间距离可以计算出 From themeasured time distance between the floor and the drone can be calculated
至少高达约13英尺和海拔 at least up to about 13 feet and altitude
之后，反射的声音太柔和，无法感应到传感器 after that the reflected sound is too soft for the sensor to pick up
另一个传感器是相机 The other sensor is a camera
它以每秒60帧的速度拍摄图像，并使用称为光流的图像处理技术 It's taking images at 60 frames per second and using an image processing technique called optical flow
确定对象如何在一帧和下一帧之间移动 to determine how objects are moving between one frame and the next
微型无人机可以根据这种明显的运动来估计水平运动和速度 from this apparent motion the mini drone can estimate horizontal motion and speed
现在，迷你无人机内部有一个压力传感器 Now inside the mini drone there is a pressure sensor
间接测量高度 which is indirectly measuring altitude
随着无人机在海拔高度上的上升，气压会略有下降 as the drone climbs in altitude the air pressure drops slightly
我们可以用这种轻微的压力变化来估算 and we can use this slight change in pressure to estimate
迷你无人机的高度是如何变化的 how the altitude of the mini drone is changing is it going up or down
最后一个传感器是惯性测量单元或简称IMU the last sensor is an inertial measurement unit or IMU for short
它由可测量线性加速度的三轴加速度计和可测量角速度的三轴陀螺仪组成 This is made up of a three axis accelerometer which measures linear acceleration and a 3-axis gyroscope that measures angular rate
从IMU和我们的重力加速度知识 From the IMU and our knowledge of acceleration due to gravity
我们可以估计小型无人机相对于重力的姿态 we can estimate the mini-drones attitude relative to gravity
以及旋转的速度 and how fast it's rotating
这就是传感器 and that's it for the sensors
我们有这四个传感器可以使用 we have these four sensors to work with
我们可以使用超声波和压力来确定高度 we can use ultrasound and pressure to determine altitude
以及IMU和摄像机确定旋转和平移运动 and the IMU and the camera to determine rotational and translational motion
传感器盖好了，让我们谈谈执行器 okay with the sensors covered let's talkabout our actuators
我们有四个马达 we have four motors
每个人都有自己的螺旋桨 each with their own propeller
前两个螺旋桨为白色，后两个螺旋桨为黑色 the front two propellers are white and the back two are black
但是颜色只是用来向操作员指示无人机飞行时朝向的方向 but the colors are just there to indicate to the operator which way the drone is facing when they're flying it
这些电机要认识的更重要的一点是它们的配置和旋转方向 A more important thing to recognize with these motors is their configuration and spin direction
这四个电机以X配置而不是plus配置进行布局 These four motors are laid out in an X configuration as opposed to a plus configuration
两者之间的唯一区别是 The only difference between these two is
俯仰和滚动迷你无人机时，您向哪些电机发送命令 which motors you send commands to when pitching and rolling the mini-drone
一般而言，尽管两者的基本概念相同 In general though the underlying concepts are the same for both
现在，四轴飞行器电机配置中最巧妙的部分是旋转方向 now the most ingenious part of a quad copters motor configuration is the spin direction
相对的电动机沿彼此相同的方向旋转，但与另一对相反的方向旋转 Opposing motors spin in the same direction as each other but opposite direction as the other pair
这是确保推力辊俯仰和偏航可以相互独立控制的必要条件 This is necessary to make sure that thrust roll pitch and yaw can be commanded independently of each other
这意味着我们可以命令一个动作而不会影响其他动作 That means that we can command one motion without affecting the others
我们将了解为什么该配置至少一点点就能实现一阶 We'll see why the configuration makes this true at least to a first order in just a bit
实际上，无人机周围复杂的流体动力学意味着所有运动都以某种方式耦合在一起 In reality complex fluid dynamics around the drone means that all motion is coupled together in some way
但出于我们的目的，我们可以忽略该细节 but for our purpose we can ignore that detail
最终让我们的反馈控制系统纠正该错误 and eventually let our feedback control system correct for that error
现在我们可以谈谈控制问题的概述 now we can talk about the overview of the control problem
我们有我们的工厂 we have our plant
无人机本身 the drone itself
我们有四个执行器将力和扭矩注入系统 and we have our four actuators that inject forces and torques into the system
所以问题是我们如何将正确的输入注入系统 So the question is how do we inject the right inputs into our system
这样输出就是我们想要的结果 so that the output is the result we want
那就是我们能找到一种以非常精确的方式操纵这四个马达的方法，以便使无人机旋转 that is can we figure out a way to manipulate these four motors in a very precise way so that the drone can rotate
并在三维空间中回旋 and maneuver around in three-dimensional space
为了帮助我们，我们有一套传感器，可用于直接或间接估算迷你无人机的状态 To help us we have our set of sensors that we can use to directly or indirectly estimate the state of our mini drone
系统状态是角位置和速率，高度和水平速度之类的东西 System states are things like angular position and rates altitude and horizontal velocity
估计状态取决于控制体系结构以及我们要完成的工作 and the states that were estimating depend on the control architecture and what we're trying to accomplish
我们将在整个系列中对此进行详细介绍 We're gonna flesh that out in more detail throughout this series
最后，了解系统状态并了解我们希望我们的小型无人机执行的操作 Finally with knowledge of the state of the system and an understanding of what we want our mini-drone to do
我们可以开发一个控制器 we can develop a controller
基本上，一种在软件中运行的算法会吸收我们的设定点和估计状态 Basically an algorithm that runs in software that takes in our set point and estimated state
并计算出精确的电机指令，这些指令将注入必要的力和扭矩 and calculate those precise motor commands that will inject the necessary forces and torques
这就是整个问题 That's the whole problem
但是您可能会想到，对于四轴飞行器，想出那种算法并不容易 But as you might imagine coming up with that algorithm isn't straightforward for a quadcopter
我们首先要注意的是，这是一个欠驱动系统 The first thing we should notice is that this is an under actuated system
我们只有四个执行器 We only have four actuators
但是我们有六个自由度 but we have six degrees of freedom
上下左右三个平移方向，左右向前和向后 three translational directions up and down left and right forward and backwards
和三个旋转方向滚动俯仰和偏航 and three rotational directions roll pitch and yaw
因为我们没有每个动作的执行器 and since we don't have an actuator for every motion
那么我们已经知道某些方向在任何给定时间都是无法控制的 then we already know that some directions are uncontrollable at any given time
例如，我们的迷你无人机无法向左移动 As an example our mini drone is not capable of moving left
至少不是没有先朝那个方向旋转 at least not without first rotating in that direction
向前和向后运动也是如此 and the same goes for forward and backward motion as well
我们将通过开发将旋转和推力耦合以实现总体目标的控制系统来解决致动问题 We're going to get around this under actuation problem by developing a control system that couples rotations and thrust to accomplish the overall goals
因此，现在让我们来看一下如何仅使用四个电动机来产生推力横摇和偏航 So now let's walk through how we generate thrust roll pitch and yaw with just four motors
以及为什么旋转方向使我们能够将一个运动与另一个运动解耦 and why the spin direction allows us to decouple one motion from the other
电动机通过旋转螺旋桨产生推力，螺旋桨将空气向下推，引起反作用力上升 A motor produces thrust by spinning a propeller which pushes air down causing a reaction force that is up
如果将电机放置在通过物体重心施加力的位置 If the motor is placed in a position that the force is applied through the center of gravity of an object
然后那个物体将以纯平移运动，完全没有旋转 then that object will move in pure translation no rotation at all
并且如果推力等于或等于重力 and if the force of the thrust is exactly equal to and opposite the force of gravity
然后对象将悬停在原位 then the object will hover in place
距重心一定距离的力既产生平移运动又产生扭矩 A force at a distance from the center of gravity produces both a translational motion as well as a torque
或围绕重心的旋转力矩 or a rotating moment about the center of gravity
如果我们的电动机在旋转时固定在杆上 and if our motor is attached to the bar as it rotates
由于力和重心之间的距离相同，因此扭矩将保持恒定 the torque will stay constant since the distance between the force and the center of gravity stays the same
但是现在力不再总是在相反的重力方向上 but the force is now no longer always in the opposite direction of gravity
因此我们的酒吧将开始从侧面移开并掉出天空 and therefore our bar will begin to move off the side and fall out of the sky
现在，如果在重心的另一侧有一个反作用力，则每个力都是引力的一半 Now if there's a counter force on the opposite side of the center of gravity and each force is half of the force of gravity
然后物体将再次保持静止，因为扭矩和力会相互抵消 then the object will again stay stationary because the torques and forces will cancel each other out
但是我们的执行器产生推力时不会纯粹产生力 but our actuators don't generate purely force when it generates thrust
因为它通过旋转和扭转具有质量的螺旋桨来完成推力 since it accomplishes thrust by rotating and torquing a propeller which has mass
我们的执行器还产生反方向的反作用扭矩 our actuators are also generating a reaction torque that is in the opposite direction
如果我们两个电机都朝着同一方向旋转 and if both of our motors are spinning in the same direction
然后扭矩加倍，我们的杠就会开始旋转 then the torque is doubled and our bar would start to rotate
现在，为了抵消此转矩，我们可以将两个电动机的方向相反 now to counter this torque we could spend the two motors in opposite directions
这在两个维度上都可以正常工作 and that would work just fine for two dimensions
但是只有两个电机的杆将无法产生三维尺寸的扭矩 but a bar with only two motors would not be able to generate torques in the third dimension
那就是我们将无法滚动此栏 that is we wouldn't be able to roll this bar
因此，我们添加了第二个杆，并增加了两个电机来创建我们的四轴飞行器 So we add a second bar with two more motors to create our quadcopter
通过这种配置，我们可以通过使每个电动机加速直到它们各自产生的重力为重力的四分之一来悬停 With this configuration we can hover by accelerating each motor until they each produce a force one fourth that of gravity
只要我们有两个反向旋转的马达 and as long as we have two counter-rotating motors
螺旋桨旋转产生的扭矩将保持平衡，并且无人机不会旋转 the torques from spinning the propellers will balance out and the drone will not spin
将反向旋转电机放在何处都没关系 It doesn't matter where you put the counter-rotating motors
只要在一个方向上有两个，而在另一个方向上有两个 as long as there's two of them in one direction and two in the other direction
但是四旋翼飞行器开发人员选择了一种配置，其中相对的电动机沿相同的方向旋转 But quadcopter developers settled on a configuration with opposing motors spinning in the same direction
所以一定有一个原因，并且有 so there must be a reason for this and there is
这是因为偏航或扁平旋转运动与侧倾和俯仰相互作用的方式 It's because of how yaw or the flat spinning motion interacts with roll and pitch
了解为什么这是真的 To understand why this is true
让我们看看如何命令偏航 let's look at how we would command yaw
我们有专门的反转电机 We have counter rotating motors specifically
因此，在所有电机以相同速度旋转时，系统上没有偏航扭矩 so that there is no yaw torque on the system with all motors spinning at the same speed
因此，如果我们想绕垂直轴花费无人机，或者想让车辆偏航，这是有道理的 So it makes sense that if we want to spend the drone about the vertical axis or we want to have the vehicle yaw
那么我们需要通过降低两个在相同方向上运行的电动机的速度并加快其他两个电动机的速度来创建偏航扭矩 then we need to create a yaw torque by slowing two motors down that are running in the same direction and speed the other two up
通过降低两个电动机的速度并加快两个电动机的速度 By slowing two motors down and speeding two up
适当地，我们可以在整个演习中保持相同的总力 appropriately we can keep the same total force throughout the maneuver
这样我们仍在徘徊并抵消重力 so that we're still hovering and counteracting gravity
但电动机扭矩的总和不为零，车辆将旋转 but the summation of the motor torques is nonzero and the vehicle will spin
因此，我们可以在不影响推力的情况下偏航 So in this way we can yaw without affecting thrust
现在让我们看看yah效果是否滚动和俯仰 Now let's see if yah effects roll and pitch
如果旋转电机对在同一侧 If the rotating motor pairs are on the same side
然后减慢一个减慢速度并增加另一个减慢速度会导致重心周围的力不平衡 then slowing one pared-down and increasing the other pair will cause an imbalance of forces about the center of gravity
车辆将根据电动机对在哪一侧而俯仰或侧倾 and the vehicle will either pitch or roll depending on which side the motor pairs are on
但是，如果我们将两个电机分开并将它们放在无人机的相对侧 However if we separate the two motors and place them on opposite sides of the drone
然后力量会互相平衡 then the forces will balance each other out
这就是为什么电机配置和旋转方向如此重要的原因 And this is why motor configuration and spin directions are so critical
现在，我们可以通过这种方式将命令发送到四个电机 We can now send commands to the four motors in such a way
车辆偏航但不会俯仰或改变其推力 that the vehicle will yaw but not roll pitch or change its thrust
同样，我们可以看一下滚动和俯仰 Similarly we can look at roll and pitch
要滚动，我们减少左/右对之一 To roll we decrease one of the left/right pairs
并增加另一个引起滚动扭矩的 and increase the other causing a rolling torque
为了减小俯仰，我们减少了一对前/后对，并增加了另一对，从而产生了俯仰力矩 And to pitch we decrease one of the front/back pairs and increase the other causing a pitching torque
这两个议案都不会对偏航产生影响 Both of these motions would have no effect on yaw
因为我们要沿相同方向移动反转电机 since we're moving counter rotating motors in the same direction
他们的偏航扭矩将继续互相抵消 and their yaw torque would continue to cancel each other out
现在要更改推力，我们需要同时增加或减少所有四个电动机 Now to change thrust we need to increase or decrease all four motors simultaneously
这样，俯仰偏航和推力是我们可以直接控制的四个方向 In this way roll pitch yaw and thrust are the four directions that we have direct control over
而对电动机的命令将是所需的推力倾角和偏航量的混合 and the commands to the motors would be a mix of the amount of thrust roll pitch and yaw required
现在我们知道，可以通过将所有四个电动机设置为相同的速度来命令推力 As we now know we can command thrust by setting all four motors to the same speed
那么我们可以通过增加两个电机的方向相同来产生偏航，而减少另外两个方向 then we can create yaw by increasing two motors spending the same direction and decrease the other two
通过增加或减少前电动机对来产生间距 Pitch is created by increasing or decreasing the front motor pair
然后以相反的方向命令后对 and then commanding the back pair in the opposite direction
和滚动是相同的，但与左右一对 And roll is the same but with the left right pair
这是我们的简单电机混合算法，可以在直观的侧倾俯仰和推力之间以及不太直观的电机和速度之间进行转换 This is our simple motor mixing algorithm that can convert between the intuitive roll pitch yaw and thrust and the less intuitive motor and speeds
现在就像我之前说的 Now as I said earlier
向左和向右向前移动我们未激活的动作 moving forwards backwards left and right our unactivated motions
绕过的方法是先旋转到推力矢量部分位于重力方向的姿态 and the way we get around that is by first rotating into an attitude where the thrust vector is partially in the gravity direction
部分地在行进方向上以这种方式使无人机加速 partially in the direction of travel to accelerate the drone in that way
现在，如果我们想在进行此操作时保持高度 Now if we wanted to maintain altitude while we do this maneuver
那么我们将增加推力 then we would increase the thrust
因此垂直分量仍在抵消重力的向下拉力 so that the vertical component is still cancelling out the downward pull of gravity
行 All right
因此，我们知道以特定方式操纵四个电机将使我们能够在3D空间中控制无人机 So we know that manipulating the four motors in specific ways will allow us to control the drone in 3d space
我们有一组传感器，可以用来估计系统状态 and we have a set of sensors that we can use to estimate the state of the system
而且我们有一个板载处理器可以运行我们的控制逻辑 and we have an onboard processor that can run our control logic
控制系统的开发最终将在Simulink中完成 The control system development will ultimately be done in Simulink
我们将要建立和模拟四轴飞行器模型的地方 where we're going to build and simulate the quadcopter model
调整控制器 tune the controller
在闭环仿真中对其进行测试 test it in a closed loop simulation
然后最终自动生成飞行代码，然后将其加载到鹦鹉迷你无人机上的机载微控制器中 and then finally automatically generate flight code that we're going to load into the onboard microcontroller on the parrot mini-drone
但是下一步是弄清楚我们如何设置控制系统架构 But the very next step is to figure out how we want to set up the control system architecture
我们将在下一个视频中讨论 and we're going to talk about that in the next video
因此，如果您不想错过下一个Tech Talk视频 So if you don't want to miss the next 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 there as well
谢谢收看，下次见 Thanks for watching and I'll see you next time