File Exchange

image thumbnail

Simulink Drone Reference Application

version (53.7 MB) by Mariano Lizarraga
Simulink Project showing a small fixed-wing drone, its autopilot, and the operator interface


Updated 26 Nov 2019

GitHub view license on GitHub

This Simulink Project shows the implementation of a Remotely Piloted Radio-Control fixed-wing aircraft (i.e. Drone, UAV), an autopilot for flight stabilization, and an operator interface to control its trajectory.

The model consists of three main components:

1. Plant model
A Six-Degree-Of-Freedom (6-DOF) dynamics model for a foam-built, 65-inch wingspan, Multiplex Mentor hobby radio controlled aircraft. It consists of models for the aircraft dynamics, the weather, the motor, the actuators and the sensors. The plant receives commands for the four actuator channels: (1)Throttle, (2) Ailerons, (3) Rudder, and (4) Elevator. In turn, it produces a set of readings as those that a sensor suite would produce on board this type of aircraft.

The plant model uses a flat-earth approximation and therefore it will only work for flights which have a range of approximately 20 Km..

2. An autopilot model.
The autopilot controller is a classical lateral/longitudinal channel flight controller which includes Guidance, Navigation and Control (except attitude estimation as this is assumed to be obtained directly from the sensor suite). The autopilot, based on the ground control station commands and the sensor readings, produces control commands for the control surfaces and also reports telemetry back to the ground station. This block stabilizes the aircraft to keep it in-flight.

It allows the operator to command it to fly in four different modes:
- Waypoint guidance.
- Circular Guidance.
- Return to Base.
- Mid-level contro commands (Uc, phi_c, H_c)

3. An aircraft operator interface.
This represents the console operating the RC Aircraft in flight. It issues commands sent from the ground to the aircraft (waypoints, airspeed, height, etc...).

The block receives telemetry reported by the aircraft such as attitude, sensor readings, and overall aircraft status. This will allow to set the desired behavior of the aircraft while in-flight.

This model has the option to interact with the well-know, publicly available Open Source Micro Air Vehicle ground station software QGroundControl. To communicate with QGroundControl, the model uses the MAVLink communications protocol.


This Simulink Project exercises several common workflows in flight control development. Its purpose is to show a recommended approach to a Model-Based Design (MBD) process to develop a proof of concept Drone flight controller (autopilot). Particularly we show the following workflows:

1. Flight Controller Design: Develop a fixed-wing drone autopilot and test its behavior in a reasonably realistic 6DOF aircraft simulation.

2. Simulate the Flight Controller Under Different Conditions: Rapidly asses the performance of an autopilot under many simulated flight conditions, using local parallel simulations.

3. Flight Envelope Characterization Rapidly characterize the Aircraft’s performance by doing a wide range of environmental and initial conditions sweep using MATLAB Distributed Computing Server.

4. Drone SME Capabilities Assessment Demonstrate to a Subject Matter Expert (SME), early in the design process, the Drone’s capabilities and gather feedback on usability and its functionality, via co-simulation between Simulink and QGroundControl Ground Station Software.

5. Test Behavior of the Fight Controller’s Generated Code Test the code behavior using Simulink's Software-In-the-Loop on the development computer for same results (within bounds) of the designed autopilot.

6. Deploy and Test Correctness of the Flight Controller’s Generated Code Test the code’s behavior on a development board (a Raspberry Pi) for same results (within bounds) using Simulink's Processor-In-the-Loop.

7. System Integration Test (Hardware-In-the-Loop) Test the flight controller deployed in the development board (Raspberry Pi) with a 6DOF aircraft simulation running in a Speedgoat Real-Time computer with Simulink Real Time.

Cite As

Mariano Lizarraga (2020). Simulink Drone Reference Application (, GitHub. Retrieved .

Comments and Ratings (14)

Miguel Crespo

Francisco Molina

wt s

dujtep thawonsusin

Abhishek GS

Ankur Bose

Greg Drayer

Amit Charantimath

Mariano Lizarraga

Hello Bo,
Excellent catch! Thank you for providing feedback. I have fixed the issue and am planning to push a new version soon with support for 19a, Simulink Requirements file and a System Composer architecture.

Bo Wang

In the Compute Frenet subsystem, the tangential T is the same as the normal N.
Maybe N = T X [0 0 1]

Mariano Lizarraga

Hello Tehniat,
I am not familiar with your complete project but the easiest way you could go about it is, once you detect an obstacle, to create a trajectory (using waypoints) around it and send it to the drone. Note that the current model has a (hard) limit of 10 waypoints but that can be modified.

Regarding 18a, the model currently only supports R2017b. We are in the process of migrating and testing it in R2018a but we currently do not have a time frame to move it. I encourage you to fork the repository in GitHub and provide feedback via GitHub's issues.


Tehniat Fatima


I am working with Simulink and Mavlink to create a UAV model for obstacle avoidance using fuzzy logic. My fuzzy system is in MATLAB fuzzy logic toolbox. Your example is closely related to my requirements. My query is where should i add the fuzzy system for inputs like target angle, target distance, obstacle angle and obstacle distance. Is it possible to get these parameters from your model? Also i want to change heading angle or speed according to the fuzzy output. Can you please guide me in this direction. Another thing is i am using MATLAB R2018a and the QGroundControlInterface is giving me error about protected model.
Looking forward for your response.


Hi Mariano

Thanks for this submission. It is a very nice example.

MATLAB Release Compatibility
Created with R2017b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!