理解模型预测控制,第7部分:用Simulink和模型预测控制工具箱进行自适应MPC设计
从系列:理解模型预测控制
Melda Ulusoy, MathWorks
在本视频中,您将学习如何设计一个自适应MPC控制器的自动转向车辆系统的动态变化与纵向速度。
在为控制系统最可能的运行条件设计MPC控制器之后,可以基于该设计实现自适应MPC控制器。在每个时间步中,自适应MPC根据当前的运行条件更新设备模型和标称条件。在本视频中,您将学习如何计算和更新自适应MPC块所需的离散植物模型。您还将学习如何从自适应MPC控制器生成代码,并将看到一个示例,展示使用MPC控制和图像处理算法使自己保持在车道内的真实自动驾驶汽车。
在本视频中,我们将使用自适应MPC来自动驾驶汽车,其横向车辆动力学是随着时间的变化,由于纵向速度的变化。在之前的视频中,我们讨论了线性横向车辆动力学,并假设汽车具有恒定的纵向速度。所以,植物动态没有变化状态矩阵A是恒定的。为了控制该系统,我们使用了传统的MPC控制器。现在我们让纵向速度随着汽车的行驶而变化。所以,状态矩阵A也会改变。传统的MPC控制器使用恒定的内部装置模型,不能有效地处理变化的动态。那么,我们该如何应对植物动态的变化呢?在第4部分视频中,我们讨论了自适应MPC让你在操作条件变化的每个时间步提供一个新的线性植物模型,因此它在新的操作条件下做出更准确的预测。所以,为了处理不断变化的植物动态,我们将使用自适应MPC。
我们打开一个新的Simulink模型,从这个自定义库中添加植物开始。如前所述,该装置被开发为一个状态空间系统,其输入为转向角,输出为横向位置和偏航角。此时其动力学随纵向速度变化。因此,这现在成为了植物块的输入。我们将连接一个恒定的块作为纵向速度我们将初始值设为15米/秒然后再改为另一个值。另一个输出是我们稍后将使用的状态。如果你想查看这些块的下面,看看它们是如何构建的,你可以从视频描述中给出的链接下载这个Simulink模型。接下来,我们将连接模型预测控制工具箱下的自适应MPC块。该块具有与常规MPC块相同的输入和输出,除了它还采用在当前操作条件的每个时间步更新的工厂模型。在此之前,我们为横向位置和偏航角设计了一个自定义参考。 We’ll first connect this reference to the controller. Then we connect the plant output to the measured outputs and the steering angle to the controller output. To implement the adaptive MPC, we can simply start with the MPC controller that we designed in the previous video for a longitudinal velocity of 15 m/s. We already have the MPC controller object in our workspace. By typing it in the command window, we can see the design parameters such as the prediction and control horizons, constraints and weights. One thing to note is that the adaptive MPC block requires a discrete plant model. So, we need to convert the continuous time state space model used by mpc1 to discrete time. There are different ways to do it. Here, we use the c2d command and update the plant model of the MPC object with the discretized plant. Now, we go back to the adaptive MPC block and type in the MPC object. Next, we need to provide the controller with a plant model that is updated at each time step for the current operating condition. The pre-built update plant model block takes care of this calculation. When we double click on it, we see that it has been implemented as a MATLAB function. As inputs, this function takes Vx, u and x and first calculates the state space matrices. It then computes the discrete model and also updates the nominal conditions with the current operating conditions. Now it’s time to connect the inputs and outputs for this block. We already have all the inputs here, longitudinal velocity, the steering angle and the states. The “model” input of the adaptive MPC control block requires the discrete-time model and nominal conditions in this order that we’ve created in the MATLAB function. To connect the outputs to the controller, we select the block, and create a bus signal. Now, we’re ready to try different longitudinal velocities and see how the controller handles the varying plant dynamics. In the previous video, the traditional MPC controller designed for an operating condition of 15 m/s had worked well while it failed to control the system at a different longitudinal velocity of 35 m/s. With adaptive MPC, we get a good controller performance when longitudinal velocity is 15 m/s. If we now change it to 35 m/s, we still get a good tracking of the lateral position and the yaw angle. We can even replace this constant block with a continuously changing signal such a sine wave and see that adaptive MPC still can deal with the changing plant dynamics and successfully control the system. We designed an adaptive MPC controller, ran several simulations to evaluate the controller performance. Now if you want to run your controller on your autonomous car, you can simply generate code using Embedded Coder and deploy it to your car. Here’s the generated C code. You can call the MPC controller code from your real-time scheduler using the entry points shown in the code interface report. Embedded Coder also lets you customize the call interfaces as required by your software framework and architecture.
这段视频展示了一个例子,如何生成代码的MPC控制器和图像处理算法在自动驾驶汽车上运行,以保持它在车道内。在Simulink之外开发的图像处理和车道检测算法为MPC控制器提供这些输入。下面是这些算法的工作原理。安装在车顶上的摄像头可以捕捉到汽车的正面。图像处理算法识别实线和虚线标记,并检测汽车正在行驶的车道。车道的中间是中心线,它被用来计算汽车从这条线的位置偏移以及偏航角。该信息被MPC控制器使用,它试图保持汽车在中心线上。左边的图用红色表示汽车偏离中心线,用绿色表示偏航角,而右边的图则表示转向角。
在本视频中,我们讨论了如何使用自适应MPC来控制动态变化的工厂,还讨论了如何生成C代码并部署它进行实时控制。有关模型预测控制的更多信息,请查看我们之前的技术讲座视频。
相关产品2022世界杯八强谁会赢?
了解更多
您也可以从以下列表中选择网站:
如何获得最佳的网站性能
选择中国网站(中文或英文)以获得最佳的网站表现。其他MathWorks国家网站没有针对从您的位置访问进行优化。