Technical Articles

Teaching Avionics and Control with a Minidrone Competition

By Hamidreza Nemati, University of the West of England

As a student, I often felt there was a wide gap between engineering theory and its practical application to real-world problems. For example, I found that much of the curriculum in aerospace engineering avoided addressing challenges in navigation or image processing. This omission stemmed, in part, from a belief that these topics fell within the domain of computer scientists, not aerospace engineers. I have always found this perspective odd because we live in a complex world where a multidisciplinary approach is needed to teach engineering students how to solve real challenges.

Now that I am a lecturer, I have taken the opportunity to address the gaps I recognized as a student. To do so, I drew on my own experience of winning the MathWorks Minidrone Competition as a postdoctoral researcher. In this competition, which is held in countries around the world, students design, simulate, and implement a vision-based line follower algorithm in Simulink®, before pitting their solution against those of other students in real flight tests on a Parrot® Mambo minidrone (Figure 1).

Two side-by-side images, one of a simulated view from above of the Parrot minidrone flying and the other of the Parrot drone and flight path at the minidrone competition.

Figure 1. A Parrot minidrone flying in a simulation (left) and on a competition course (right).

I learned considerably more about applying engineering theory while considering the real-world environmental effects on drone deployment as a participant in the competition than I had in my classroom studies. At the same time, I gained invaluable experience with Model-Based Design and the development, implementation, and optimization of navigation and image processing algorithms. As a lecturer, I wanted my students to have the benefits of this type of experience. Therefore, I incorporated the MathWorks Minidrone Competition directly into my avionics and control course for third-year students. When I taught this version of the course in the 2021–2022 academic year, six student teams developed and tuned their algorithms in Simulink before ultimately taking turns testing them in the final competition. Despite some spectacular crashes, the students were as enthusiastic as I had been about how much they had learned from the experience.

Structuring the Course

When thinking about how to teach the course, I decided to use the same structure as the minidrone competition, in which students complete a series of milestones as they work toward a complete design. This structure mainly covers two areas of the UK Standard for Professional Engineering Competence and Commitment: knowledge and understanding, along with design, development, and solving engineering problems.

Before jumping into the design work, however, I set aside some time to ensure my students had a good understanding of the concepts they would need. Starting with a review of MATLAB® and Simulink basics, I had the students complete the MATLAB Onramp and Simulink Onramp tutorials. I also offered extra credit to students who completed the Stateflow Onramp tutorial to encourage them to get a head start on learning to create, edit, and simulate state machines—skills I knew they would be grateful for having later in the course when they were planning flight states.

Over the next few weeks, the course covered aircraft dynamics and modeling, drone avionics, and the kinematics and dynamics of micro aerial vehicles, including the Parrot minidrone. The final lesson in this series focused on the fundamentals of computer vision, which provided students with the necessary foundation for completing the course’s first project.

Developing Computer Vision Algorithms

I split the class into teams of four to six students and had them work toward the first major milestone: developing a line detection algorithm in MATLAB. To help them get started, I covered some basic edge, line, and object detection techniques in lectures. Students also completed the Image Processing Onramp tutorial in MATLAB and Simulink. The line detection algorithm they were to implement is part of the image processing component of the flight control system for the minidrone. As part of the competition (and my course), students were provided with a basic Simulink model of this system (Figure 2). They implemented the Image Processing System block first, before working on the Control System block.

Simulink model of the flight control system showing the workflow for the Image Processing System and Control System blocks. 

Figure 2. A Simulink model of the flight control system. 

Beyond basic edge and line detection, students also had to implement a circle detection algorithm, which is needed to identify the small landing area that the drone is required to set down in at the end of the flight path (Figure 3). I encouraged my students to explore advanced image processing techniques, offering extra credit for implementing shadow removal or illumination invariant measures. I was impressed with the innovative ideas that the students came up with for both line detection and circle detection algorithms. In both cases, they devised interesting approaches that I had not expected.

Simulated view from above of the end of the flight path and the designated landing area for the drone. 

Figure 3. Simulated top-level view of the end of a path and its landing area.

Path Planning

The next major milestone was to implement the path planning block in the Simulink control system model. In this phase, I distinguished the term “path planning” from “trajectory tracking” so that students developed algorithms that were independent from the path’s physical parameters, such as length and geometry. Instead, they worked with the color of the path and calculated any required parameters based on the information obtained from images. This block receives the results from the students’ image processing algorithms as inputs (Figure 4).

A Simulink model of the control system. 

Figure 4. A Simulink model of the control system, including the path planning subsystem.

As I did with the image processing algorithms, I introduced students to some well-known path planning algorithms—including RRT, RRT*, and A*—without restricting them to these approaches. The teams first worked on following a straight path until the drone reached a junction, and then built upon their algorithms until the drone could follow a complete path to its landing area. To test their algorithms, the teams ran closed-loop simulations in Simulink with a model of the drone supplied by MathWorks (Figure 5). Once again, my students exhibited outside-the-box thinking in their implementations; one team implemented an algorithm that successfully navigated the entire path without ever altering the heading of the drone! 

Figure 5. Simulation of a drone following a path. 

Control Design and Tuning

Once the students had implemented their path planning algorithms, I shifted the focus to attitude and altitude control design. I had them retune gains for the proportional-integral-derivative controller by employing optimization algorithms to minimize one of the following criteria: integral absolute error, integral squared error, integral time-weighted absolute error, or even the root-mean-square value of the error. Attitude and altitude controllers are included in the base model provided by MathWorks, but I cautioned them against being too aggressive. As part of their overall implementation strategy, I urged them to keep their designs simple because I knew that an overly complex design or aggressively tuned controller would likely lead to difficulties when it was time to test on real hardware. 

While students worked on model-free linear controllers, such as PID, I also introduced them to model-based linear control designs, including the linear-quadratic regulator (LQR). Furthermore, I presented the comparison of implementing LQR with the more advance nonlinear control strategy known as Sliding Mode Control (SMC) to show the effectiveness of applying robust controllers in the presence of uncertainties and external disturbances. However, given that SMC suffers from undesirable high frequency vibrations, I implemented a Continuous Sliding Mode Control (CSMC) that is able to eliminate these vibrations using the fractional exponent of the sliding surface and guarantee the control system performs robustly. To compare the performance of linear (PID) and nonlinear (CSMC) control designs, we ran simulations and plotted the resulting paths in MATLAB (Figure 6). Some of my colleagues were surprised that I had taught undergraduates model-based control techniques, such as LQR. I explained that once we had a working model, it was actually quite easy to swap out the PID controller with the LQR controller and demonstrate how advance control approaches can be applied. 

Two graphs showing drone flight paths plotted with a PID controller and CSMC controller.

Figure 6. Simulated paths of a drone with a PID controller (top) and CSMC controller (bottom).

Deploying to Parrot Minidrones

For their final milestone, students ran the algorithms they had modeled, simulated, and verified in Simulink on real hardware. For this step, they used the Simulink Support Package for Parrot Minidrones to deploy their algorithms wirelessly via Bluetooth® to a Parrot Mambo minidrone.

The drone competition was held at the Bristol Robotics Lab, with several lab researchers attending to watch the final runs. On the day of the event, MathWorks engineers were on hand to help with the setup.

The first flight tests did not go as the teams expected, largely because students had set the gains too high and aggressive on their controllers. Instead of the steady path-following they had seen in simulations, the real drones exhibited erratic behavior and suffered more than a few heavy impacts. While disappointed at first, the students soon got to work adjusting their gains and simplifying aspects of their design to account for the real-world effects that they were now faced with. One team’s drone successfully completed the entire course, winning the competition. Multiple teams stayed after the competition had closed to continue improving their algorithms, demonstrating a level of interest for the project that was shared by the entire class.

The students’ continued enthusiasm is one of many reasons I’m eager to teach the course again next year with the minidrone competition as its centerpiece. I am also looking forward to an opportunity for my students to participate in an official MathWorks Minidrone Competition here in the UK or nearby.

About the Author

Currently a lecturer in avionics and control at University of the West of England Bristol, Dr. Nemati holds a PhD in Aeronautics and Astronautics from Kyushu University in Fukuoka, Japan. His research interests include autonomous navigation and intelligent control, including systems that control hydraulic manipulators and provide robust stabilization of micro-aerial vehicles.

Published 2023

View Articles for Related Capabilities

View Articles for Related Industries