What exactly is model predictive control MPC (3)

        In the previous two articles, what is MPC and the parameter design of MPC are introduced. These are just the basis of our simulation programming. This section will use examples to illustrate how MPC is used in Matlab.

6. How to use matlab toolbox to build MPC controller in Simulink

        

         The example used is an example in Matlab. For specific instructions, directly search for the title "Autonomous Vehicle Steering Using Model Predictive Control" in the help documentation of Matlab China.

        According to the previous description, we expect the MPC control framework to be as shown in the figure above. So our control system also needs a similar framework when it is built.
Step 1: Build a model of the controlled object

 

The input to the car is the steering angle of the steering wheel, and the output is the position and yaw angle of the car.

Step 2: Build the model of the MPC controller 

 Double-click the blank space of SIMULINK to open the search function, enter MPC, and search. Select MPC Controller.

         The first input is the output of the plant.

         The second input is the given reference value. Our goal is to make the car form on the road we expect, and this expectation is given by us manually. We can give the coordinates of the route, but it is very troublesome to give each coordinate point of a curve. Matlab provides us with plug-ins, you can just draw lines directly.

 

         Create two four-meter-wide lanes according to the boxed places in the image above. And create a car and put it on the road.

        Set the driving path of the car by yourself, set the speed of the car to 15m/s, the data in the orange box of the stand-alone machine can make the car move, and the position of the car in the green box is changing. The √ sign (export) in the above figure can convert the formal trajectory of the car into a Matlab function. 

        

        Add the data to the reference value. The md pin is used as an interference pin, we don't consider it. Let's start to design the relevant data of the MPC controller. Set sampling time, prediction step size, control step size and other parameters. (About these parameters, introduced earlier)

 

 According to the steps, set the output to two.

Set the sampling time to 0.1s. Then click the box below.

 

         Set the input and output, both on the right are 1 to make them approximate, if the difference is large, you can use the scaling factor to adjust to an approximate value.

 

 The purpose of setting this parameter is to be closer to the real lane, so that it has a climbing scene.

The above is to set the prediction step size and control range. You can try to modify the value according to the situation, and choose a set of values ​​that you are satisfied with considering the calculation time and control accuracy.

 

 The above sets the maximum and minimum values ​​of the steering wheel rotation. We assume that the maximum angle is 30 degrees. The maximum rate of rotation is 15 degrees per second. The value of the output is also set, and the output is soft-constrained within a range. Inputs are hard constraints.

 The above part is to set the input and output weights, and set the desired value according to your actual needs.

 The simulation results are shown in the figure.

Guess you like

Origin blog.csdn.net/szl__lzs/article/details/121685990