# Transition from Low- to High-Fidelity UAV Models in Three Stages

Evolve your UAV plant model continuously to stay in sync with the latest information available.

Background

An unmanned aerial vehicle (UAV) design cycle provides incrementally better access to UAV characteristics as the design progresses. By increasing its fidelity, this information can be used to continuously evolve a plant model through a Model Based Design approach.

Towards the end of the design cycle, there is enough information to develop a high-fidelity plant. To accurately model the UAV, a high-fidelity model incorporates modeling all forces and moments, wind and environmental effects and sensors in detail. However, this level of information may be unavailable to a designer early in the design process. To build such a complex model, it can take several flight and wind tunnel tests to create enough detailed aerodynamic coefficients to compute all forces and moments that affect the UAV. These factors can potentially block guidance algorithm design until the end of the design process, when a more realistic estimate of UAV dynamics is obtained.

To concurrently design a guidance algorithm sooner, a UAV algorithm designer can start with a low-fidelity model and evolve their plant model as and when additional data becomes available.

Designing a guidance algorithm using only a low-fidelity model can also pose a risk. Without controller or aerodynamic constraints, an optimistic guidance technique can fail for a real UAV with slower aircraft dynamics.

This example highlights an alternative approach. You progress from the low-fidelity Guidance Block to a medium and then high-fidelity model by progressively adding layers of control and dynamics to the simulation. In this process, the medium-fidelity model becomes a useful tool for leveraging limited information about a plant model to tune and test guidance algorithms.

The medium-fidelity model is thus used to test a given path following an algorithm. Since the high-fidelity model is unavailable until the end of the design process, the high-fidelity model is only used later to validate our modelling approach by comparing step response and path following behavior.

### Open Example and Project Files

To access the example files, click Open Live Script or use the `openExample` function.

```openExample('shared_uav_aeroblks/UAVFidelityExample') ```

Open the Simulink™ project provided in this example.

```cd fidelityExample openProject('fidelityExample.prj') ```

The project contains three versions of a UAV model, low-fidelity, medium-fidelity and high-fidelity with steps to study their step response and path following behaviour.

### Low-Fidelity Model

Assume your UAV has the following design specifications shown in the table below. The low-fidelity variant provided in this model is tuned to achieve the desired response, but you can tune these gains for your specific requirements. The low-fidelity plant uses the UAV Guidance Block which is a reduced order model for a UAV. To run the low-fidelity variant, click the Simulate Plant shortcut under the Low Fidelity group of the project toolstrip.

This shortcut sets the FidelityStage parameter to 1, configures the FidelityStepResponse model to simulate the low-fidelity model, and outputs the step response. The step response is computed for height, airspeed, and roll response.

Open the UAV Fixed Wing Guidance Model block in the FidelityStepResponse/FixedWingModel/LowFidelity subsystem. In the Configuration tab, inspect the gains set for height, airspeed, and roll response. This guidance block integrates the controller with the dynamics of the aircraft. The low-fidelity variant gives a first estimate of how fast the UAV can realistically respond to help tune high-level planners.

### Medium-Fidelity Model

As the UAV design progresses, the lift and drag coefficients become available. A motor for the aircraft is selected by the user, which defines the thrust curves. To test the validity of the guidance algorithm against this new information, the example adds this information to the plant model in this step.

To design a medium-fidelity model, the model needs only preliminary aerodynamic coefficients, thrust curves, and response time specifications. To model a medium-fidelity UAV, you can use the Fixed-Wing Point Mass Block. The block only requires lift, drag and thrust force inputs, which are much easier to approximate at an early design stage than detailed forces and moments of an aircraft. To set up the medium-fidelity variant, click the Setup Plant shortcut under the Medium Fidelity group of the project toolstrip.

Examine the Vehicle Dynamics tab in the model under FidelityStepResponse/FixedWingModel/Mid Fidelty/UAV Plant Dynamics/Vehicle Dynamics.

The medium-fidelity model represents the UAV as a point mass with the primary control variables being the angle of attack and roll. This medium-fidelity plant model takes in roll, pitch, thrust as control inputs. The point mass block assumes instantaneous dynamics of roll and angle of attack. This model uses a transfer function to model roll lag based on our roll-response specification shared in the table within the previous step.

The medium-fidelity aircraft controls pitch instead of angle of attack. Since the angle of attack is an input to the point mass block, the plant model converts pitch to alpha using the following equation.

$\Theta ={\gamma }_{\mathit{a}}$+$\alpha$

$\Theta$,${\gamma }_{\mathit{a}}$ and $\alpha$ represent pitch, flight path angle in the wind frame, and angle of attack respectively.

Unlike the low-fidelity model, the medium-fidelity model splits the autopilot from the plant dynamics. The medium-fidelity plant needs an outer-loop controller for height-pitch and airspeed-throttle control to be added. The predefined controllers provided are using standard PID-tuning loops to reach satisfactory response without overshoot. To inspect the outer-loop controller, open the `Outer_Loop_Autopilot` Simulink model.

### Medium-Fidelity Step Response

The low-fidelity plant was tuned in the previous step by assuming that all response time specifications are met by the UAV. To test this assumption, use the medium-fidelity plant. The study of the step response of the improved plant is used to contrast the performance of the low-fidelity and medium-fidelity variant. To simulate the medium-fidelity step response, click the Simulate Plant shortcut under the Medium Fidelity group of the project toolstrip. The step response plots appear as figures.

Notice that the model meets the design criteria shown in the table below by achieving an air speed settling time of 0.6 seconds and a height response of 4.1 seconds. However, the height response is slower than the low-fidelity variant. This lag in response is expected due to the additional aerodynamic constraints placed on the medium-fidelity plant.

### Simulate Path Following Algorithm

With a more accurate response from the UAV medium-fidelity model, you can now test waypoint follower or guidance algorithms to follow waypoints. For the guidance algorithm design, see the "Tuning Waypoint Follower for Fixed-Wing UAV" example.

To simulate and visualize the medium-fidelity UAV path following the model, click the Simulate Path Follower shortcut under the Medium Fidelity group of the project toolstrip.

Notice that the medium-fidelity UAV follows the desired path accurately.

### High-Fidelity Step Response

The medium-fidelity model was used to test a path follower design using simple aircraft parameters available at an early design state. However, it is important to continue adding fidelity to capture UAV control response to study more complex situations. For example, the use of more detailed aerodynamics coefficients allows analysis of complex motions such as doublet maneuvers. Another example is, adding actuator dynamics lets you study the subsequent effect on inner loop controllers for attitude, which can cause destabilization. In this way, the high-fidelity plant allows refinement of control system design. In this step, to study the change in response, we look at a high-fidelity plant with these added dynamics.

The high-fidelity plant inputs all forces and moments to a 6-DOF block, adds on-board sensors, and models actuator dynamics for the UAV. Unlike the mid-fidelity plant, the high-fidelity version does not take attitude inputs directly. Instead, an inner loop controller is added to control attitude. Additionally, a yaw compensation loop balances the non-zero sideslip. The model reuses the outer-loop controller designed for the medium-fidelity model. To validate that the medium-fidelity model provided useful intermediate information, use the response of the higher fidelity model.

To simulate and visualize the high-fidelity step response, click the Simulate Plant shortcut under the High-Fidelity group of the project toolstrip. Notice that despite added complexity, the trajectory matches well with the medium-fidelity model. Also, notice the design specifications are relatively the same for the high-fidelity stage. This similarity shows that the medium-fidelity plant modelled UAV dynamics accurately.

### Simulate Path Following Algorithm for High-Fidelity

Towards the end of the design cycle, the high-fidelity model finally becomes available. To get the final UAV path following characteristics, you can now test the guidance algorithm developed in previous steps on the high-fidelity plant. Click the Simulate Path Follower shortcut under the High-Fidelity group of the project toolstrip.

Notice that the model obtains a similar response to the medium-fidelity model using the guidance and outer-loop control parameters. This validates the guidance algorithm with a high-fidelity plant.

### Conclusion

The medium-fidelity model accurately predicts the UAV dynamics making optimum use of limited information available during design. The example designs the outer loop controller and tests a waypoint follower without needing all the information in a high-fidelity plant model.

To model additional dynamics such as actuator lag, the medium-fidelity plant is flexible and can continuously evolve alongside design. The example obtains results under zero-wind conditions. In the presence of wind disturbances, the controller and path follower performance tracking might be adversely affected. To augment the autopilot controller to compensate for wind effects, leverage the atmospheric wind model in the high-fidelity plant model.