从系列中:理解模型预测控制
MathWorks的Melda Ulusoy
学习如何使用模型预测控制工具箱™为自动驾驶汽车转向系统设计MPC控制器。
本视频将介绍MPC控制器的设计过程。使用模型预测控制工具箱附带的MPC设计器应用程序,您可以指定MPC设计参数,如控制器采样时间、预测和控制范围、约束和权重。然后可以对控制器进行微调并评估其性能。对于本视频中演示的自动转向车辆示例,使用“驾驶场景设计器”应用程序创建自定义参考轨迹,该应用程序是自动驾驶工具箱™的一部分。
看看参考示例了解更多关于横向车辆动力学和MPC控制设计的信息。
在本视频中,我们将使用MPC Designer应用程序来设计一个MPC控制器,在变道机动场景中自动驾驶汽车。让我们从这个系统的参数开始。汽车的全局位置是相对于X轴和Y轴表示的。这些向量表示汽车的纵向和横向速度。在这个控制问题中,我们希望汽车遵循参考轨迹。我们需要控制的是横向位置和偏航角。我们要通过调整转向角度来做到这一点。横向位置和偏航角的参考值是相对于水平轴计算的。在本例中,我们将假设恒定的纵向速度为15米/秒,并使用线性化的汽车模型表示横向车辆动力学。欲了解更多信息,请查看视频描述中给出的链接,该链接将带您进入这个模型预测控制工具箱示例。
让我们切换到Simulink来构万博1manbetx建自动转向控制系统。这是我们想要构建的标准MPC控制图。我们首先将植物添加到我们的模型中。在这里,我有一个自定义库,其中包括我之前创建的块。该装置就是其中之一,并已发展为一个状态空间模型代表横向车辆动力学。装置的输入是转向角,两个输出是横向位置和偏航角。现在,我们将连接你可以在模型预测控制工具箱中找到的MPC控制器。这个块的第一个输入是测量的输出。我们把输出连起来。第二个输入是引用。 In this example, we want to simulate a car changing lanes. To create a custom reference trajectory for such a scenario, I’m going to use the Driving Scenario Designer that is part of Automated Driving Toolbox. Using this app, I create a road with two lanes that are 4 meters wide, then add a car and add waypoints to generate the lane-change maneuver. You can adjust the waypoints manually from the side panel if needed. The car’s speed is set to 15 m/s. If I now simulate this scenario step by step, the app shows me how the yaw angle changes. I exported this scenario as a MATLAB function and created a block that outputs the reference lateral position and yaw angle values. I add this custom reference to my model and connect it to the controller. Here, we assume there are no measured disturbances, so we’ll remove the third input. Now that we connected all system components, we’ll continue designing the MPC controller. For this, we open the MPC block and click on “Design,” which opens up the MPC Designer. The MPC Designer is an interactive tool that lets you design MPC controllers and is shipped as part of Model Predictive Control Toolbox. Remember in the previous videos we talked about MPC design parameters such as sample time, prediction and control horizons, and constraints and weights. You can specify all these parameters in the MPC Designer, tune the controller, and then evaluate the controller’s performance. Now, we’ll go back to the MPC Designer and start by defining the MPC structure. We’ll enter the number of manipulated variables and measured outputs, and set the controller sample time to 0.1s. Then we click “define and linearize.” Remember that MPC uses an internal plant model to make predictions and an optimizer to find the optimal control action. Now, when we click “define and linearize,” the app imports and linearizes the plant from the Simulink model and uses it as the internal plant model. It also runs the default simulation scenario and displays the input and output responses. Next, we click on the I/O Attributes to type in the signal labels and units. Note that if these signals differ too much in magnitude, for example, say one is around 1 and the other one is around 1000, then you can use scale factors to bring them to similar scale. We’ll keep the default values for this example as the magnitude difference is not too much. Next, we’ll edit the default scenario. We can choose different types of reference signals from these options. The closest to our lane change scenario would be a ramp input for the lateral position reference and a constant reference of zero for the yaw angle to minimize it. We click OK and this updates the responses. Next, we’ll switch to the tuning tab where we can specify MPC design parameters. These are the default values for prediction and control horizons. Let’s see how the system behavior changes for a larger prediction horizon. For 15 and 20, the response looks more sluggish, so we will set it back to 10. Next, we’ll play with the control horizon. Increasing it to 3 provides a better control of the lateral position. If we increase it further, it doesn’t affect the response significantly, so we settle on a control horizon of 3.
接下来,我们将设置约束。输入约束是由车辆的物理限制所决定的。在这个例子中,我们假设方向盘最多可以转30度,所以我们输入/6弧度作为输入约束。为了驾驶员的舒适度,我们将把转向角度的变化率限制在15度/秒。注意,默认情况下,所有的输入约束都是硬的,输出约束是软的。我们会试着将输出保持在这些值之间。接下来,我们将指定权重。如果我们希望输入和输出有一个目标,我们需要将权重设置为一个非零值。对于转向角度,我们将保持默认权重为零,因为它不需要跟踪目标。我们还将保持输入速率的默认权重。 You can increase this weight if you want to have even smaller input increments. And for the outputs, we’ll set the weight for the lateral position to 1 and the yaw angle weight to 0.1, as position tracking is our primary objective. After setting all these parameters, you can fine tune your controller by using this slider. We’ll slide it right for a more aggressive control. And the response looks good.
现在,我们对控制器性能感到满意,然后单击“export controller”,这将更新MPC控制器块并运行模拟。注意,在我们的Simulink模型万博1manbetx中,我们使用了之前为变道场景设计的自定义参考。现在我们来看看模拟结果。我们得到了两个输出的满意跟踪。转向角控制在控制器控制的范围内。
在本视频中,我们已经走过了MPC控制器的设计过程,但我还要提到,在发行版2018a中,有一个Lane Keep辅助系统块,有效地简化了设计过程。点击视频描述中的链接了解更多信息。
我们展示了设计的控制器表现良好,但请注意,我们使用的汽车动力学只适用于特定的操作条件,即当纵向速度为15米/秒时。然而,如果汽车在行驶过程中纵向速度发生变化,汽车的动力也会发生变化。所以,如果我们现在改变速度为35米/秒,这将导致控制器降级。为了解决这一问题,我们需要设计一种自适应MPC控制器,它可以根据运行条件的变化更新内部装置模型。这就是我们下个视频要讨论的内容。
您也可以从以下列表中选择网站:
选择中国网站(中文或英文)以获得最佳的网站表现。其他MathWorks国家网站没有针对从您的位置访问进行优化。