In this example we will use FORCES PRO to design and test a state estimator and a model predictive controller for an open-loop unstable highly dynamic fighter jet. This case study is one of the examples used in the MATLAB® MPC Toolbox. The user is encouraged to investigate the performance difference for the tools, which will vary between two and three orders of magnitude depending on the prediction horizon and the computing platform.

We will use a model of an F16 aircraft linearized at 3000 ft altitude and 0.6 Mach velocity and discretized with a 50 millisecond sampling time. The model is described in the following publication:

P. Kapasouris, M. Athans and G. Stein*, "Design of feedback control systems for unstable plants with saturating actuators", *Proc. IFAC Symp. on Nonlinear Control System Design, Pergamon Press, pp.302--307, 1990

The model has four states and two actuators described by:

\[ x:= \begin{bmatrix} \text{forward velocity (ft/s)} \\ \text{angle of attack (degrees)} \\ \text{pitch rate (degrees/s)} \\ \text{pitch angle (degrees)} \end{bmatrix} \qquad u:= \begin{bmatrix} \text{elevator angle (degrees)} \\ \text{flaperon angle (degrees)} \end{bmatrix} \]

The goal of our controller is to stabilise the aircraft and track references given by the pilot for the angle of attack and pitch angle with zero steady-state error. The controller should also ensure that the following system constraints are satisfied:

\[ \begin{bmatrix} -0.5 \\ -100 \end{bmatrix} \leq \begin{bmatrix} \text{angle of attack (degrees)} \\ \text{pitch angle (degrees)} \end{bmatrix} \leq \begin{bmatrix} 0.5 \\ 100 \end{bmatrix} \qquad \begin{bmatrix} -25 \\ -25 \end{bmatrix} \leq \begin{bmatrix} \text{elevator angle (degrees)} \\ \text{flaperon angle (degrees)} \end{bmatrix} \leq \begin{bmatrix} 25 \\ 25 \end{bmatrix} \]

The discrete model data and all Simulink® files for simulating your custom controller can be downloaded by clicking here.

**Control Design**

To start designing the controller and estimator for this system copy the FORCES PRO block (inside `'LTI_MPC_lib.mdl'` in your client files) to your Simulink® diagram and give a name to your controller. In the following example I have called it `'F16_Controller'`.

Make sure that your FORCES PRO client is in your MATLAB® path, load the data in the file `'F16Aircraft_data.mat` and double click the FORCES PRO block to start configuring your controller.

In the first dialog, input the variable names \(A\), \(B\) and \(C\) for the discrete-time system matrices.

We then need to define the control objectives. Our goal is to track references for the outputs of the system - the angle of attack and pitch angle. The controller module will read an output reference and will calculate the appropriate offset-free steady-state references for the states and inputs of the system. The controller does not know the reference changes a priori so it cannot make use of that information.

In this case we have set the prediction and control horizon to be 5 steps in the future, i.e. 250 milliseconds. Increasing the prediction horizon would improve the tracking performance of the controller.

For the cost function we can decide to load matrices that penalize the deviation of the states and inputs from their steady-state references. In this case, the `'Qy'` and `'R'` matrices specify that the objective of tracking the outputs is 1000 times more important than minimizing the use of the actuators. Alternative you can decide to specify the tracking objectives for the individual outputs manually.

We then need to specify the bounds on the system's outputs and actuators. The snapshot on the right shows how to define the constraint on the angle of attack. Note that the constraint is soft, which means that the controller tries to maintain the angle of attack within bounds, but if this is not physically possible it attempts to minimize the constraint violation. In this example it is important to set the output constraints as soft because the aircraft operates on the constraints most of the time. If the constraints are not allowed to be violated the smallest disturbance could lead to infeasible optimization problems and the controller not returning valid actuator commands. Define also the other output constraint and the bounds on the elevator and flaperon angles.

Finally, we need to design an observer to estimate the current state of the aircraft from the output measurements. Select `'Output Feedback'` to reveal the observer parameters. Here you can define the relative importance between rejecting sensor noise and process noise arising from uncertainty in the model. If the model is highly uncertain use a higher value for the process noise entries, whereas if the sensors are very inaccurate use a higher value in the measurement noise entries.

Fill in the solver settings on the final tab and type

**>> configure_block**

to generate a customized estimator and controller for your problem. The solver and interfaces are automatically built on your machine and the block becomes ready for simulation.

**Simulation**

We can simulate the closed-loop behaviour of our controller and estimator by connecting the controller in the following output feedback configuration. Note that if you have asked to obtain solver runtime information your controller block will have an additional port that has to be connected to a workspace variable.

We can run Simulink® to simulate a change in reference defined in the time series `'out_ref'` The scenario involves a step change in the pitch angle reference from 10 degrees to -10 degrees. One should obtain the following closed-loop trajectories that show how the output references are successfully tracked with zero steady-state error while the actuator limits are never exceeded.

Input

Output:

Alternatively, we can change the reference switch and test any reference change, also during runtime.