Model-based Design of a Line-tracking Algorithm for a Low-cost Mini Drone through Vision-based Control

This Thesis research project aims to design a Line-tracking algorithm for a low-cost mini drone through Vision-based control with image processing techniques. The design process is the application of the principles of Model-based software design, which is a modern technique to design control systems, based on the development of a model of the plant and the controller with enough detail to have a realistic representation of its behavior to accomplish the specifications. The designed model is tested in a simulation environment (Model-in-the-loop phase). Then, if it satisfies the requirements, it is tested in real-time, deploying the algorithm on the Hardware to evaluate if its performances are still acceptable or if it requires to be updated. A significant advantage that characterizes this technique is the auto-code generation, which allows us to automatically translate the blocks of the model built through Simulink into a C-code executable by the hardware, instead of writing it manually. This research project is adapted from a competition organized by Mathworks, which aims to make a drone follow a line of a specific color and land at the end of it on a circle. The task should be accomplished in as little time as possible but at the same time remaining stable and following the path as precisely as possible (within the low-cost limits of the mini drone used). The environment used to design and develop the control system is MATLAB, with Simulink and their add-on toolboxes like Aerospace blockset, image processing, computer vision, and Hardware support package for Parrot mini drone, which is the specific company that made the drone model of this project. Firstly, the preliminary goal is the accomplishment of the stabilization of flight maneuvers through a suitable control system architecture and PID controllers tuning. Then, the Flight Control System design proceeds with Image processing and Path planning subsystems design. The line-tracking algorithm implementations developed are two. The first one is based on the analysis of the pixels of the image acquired from the downward-facing camera and elaboration through image processing techniques like color thresholding and edge detection. The path planning logic was implemented through Stateflow, which is an add-on tool of Simulink, useful for State machines design. This first designed control system also has another simplified version, useful because it is computationally lighter on the hardware compared to the first standard version. The second algorithm, instead, is realized by using user-defined functions, like thresholding operation for noise removal in the binary image, or like the function that searches and detects the path and the line angles, and by some other already existing functions provided by the computer vision toolbox. Finally, their performances were both tested on the hardware and then analyzed and compared. The validation phase was discussed, commenting on their limits, and highlighting other issues encountered, not previously noticed within the simulation 3D environment during the Model-in-the-loop test.