Design and implementation of a model predictive control on a pixhawk flight controller.

Date
2018-12
Journal Title
Journal ISSN
Volume Title
Publisher
Stellenbosch : Stellenbosch University
Abstract
ENGLISH ABSTRACT: Quadcopters have undergone a steady rise in popularity in the last decade. They have been adopted in the military, fire and rescue missions, security systems and photography, just to list a few. The rate of adoption of quadcopters is on the rise as more applications for their use are discovered. At the Solar Thermal Energy Research Group (STERG), Stellenbosch University, quadcopters are used in the calibration and inspection of heliostats and to improve point focusing of the heliostats. Therefore, it is necessary to use quadcopters with excellent performance to achieve these objectives. STERG uses the Pixhawk autopilot, one of the most popular open source flight controllers available, for quadcopter research. The Pixhawk runs on the PX4 firmware comprised of modules used for state estimation, positionand angular control and others. A Proportional Derivative (PD) controller is implemented on the PX4 firmware to control the angular rates of a quadcopter. However, previous studies show that this controller is inadequate and necessitates a need for an alternative. Model Predictive Control (MPC) was chosen as the alternative, due to its ability to generate a sequence of inputs needed to control a system by minimising the error between reference values and predicted outputs and also its ability to handle constraints. Nevertheless, MPC has not been implemented on the PX4 firmware before, as it requires a mathematical model of the specific quadcopter to be used. Thus, the aim of this thesis is to evaluate the feasibility of implementing MPC on the Pixhawk, running the PX4 firmware, to control the angular rates of a quadcopter. The MPC angular rates controller was designed and implemented in MATLAB. The controller was then programmed in C++ for compatible inclusion in the relevant PX4 module. A multicopter simulator was used to run the modified PX4 firmware on a simulated quadcopter to control its angular rates. Subsequently, the PX4 firmware was uploaded onto the Pixhawk. Several challenges were encountered in this stage, with the most prominent, being the size of the memory on the Pixhawk. Measures such as code optimisation, stack size adjustment and disabling unused modules were necessary to ensure a successful firmware upload. A quadcopter running the modified PX4 firmware the Pixhawk was flight tested and thereafter, the angular rates flight data was plotted and analysed. The plots show that the MPC angular rates controller is able to achieve close reference tracking of angular rates. The findings from this novel approach demonstrate the feasibility of implementing model predictive control on the PX4 firmware, and proposes using a Pixhawk with a larger memory in order to integrate MPC into other PX4 control modules.
AFRIKAANSE OPSOMMING: Hommeltuie het die afgelope dekade meer gewildheid geraak. Hulle word gebruik in die weermag, brand- en reddingsmissies, sekuriteitsisteme en fotografie, om net ’n paar te noem. Hommeltuie word al meer gebruik soos meer toepassings vir hul gebruik ontdek word. By die Son Termiese Energie Navorsingsgroep (STERG), Universiteit Stellenbosch, word hommeltuie gebruik in die kalibrasie en inspeksie van heliostate en om die puntfokus van die heliostate te verbeter. Daarom is dit nodig om hommeltuie te gebruik met uitnemende prestasie om hierdie doelwitte te bereik. STERG gebruik die Pixhawk outoloots, een van die gewildste oopbron vlugbeheerders beskikbaar vir hommeltuignavorsing. Die Pixhawk gebruik die PX4 fermatuur wat bestaan uit modules vir toestandafskatting, posisie- en hoekbeheer en ander. ’n Proporsionele afgeleide (PD) beheerder is ge´’implementeer op die PX4-fermatuur om die hoektempo’s van die hommeltuig te beheer. Vorige studies toon egter dat hierdie beheerder ontoereikend is en ’n alternative beheerder noodsaak. Modelvoorspellende beheer (MVB) is gekies as ’n alternatief, omdat dit ’n reeks intree-waardes kan genereer om ’n stelsel te beheer deur die fout tussen die verwysingswaardes en die voorspelde uitree te minimeer, asook omdat dit die vermoë het om begrensings te hanteer. Nietemin is die MVB nog nie voorheen op die PX4-fermatuur geïmplementeer nie, aangesien dit ’n wiskundige model benodig van die spesifieke hommeltuig wat gebruik word. Dus, die doel van hierdie proefskrif is om die uitvoerbaarheid van MVB wat uitvoer op ’n Pixhawk met PX4-fermatuur te evalueer, waar die MVB die hoektempo van ’n hommeltuig beheer. Die MBV-hoektempo beheerder is ontwerp en geïmplementeer in MATLAB. Die beheerder is in C++ geprogrammeer vir aanpasbare insluiting in die betrokke PX4-module. ’n Hommeltuig-simulator is gebruik om die gewysigde PX4-fermatuur op ’n gesimuleerde hommeltuig uit te voer en so die hoektempo te beheer. Daarna is die PX4-fermatuur op die Pixhawk gelaai. Verskeie uitdagings is in hierdie stadium ondervind, die mees prominente was die grootte van Pixhawk se geheue. Maatreëls soos kodeoptimering, stapelgrootte aanpassing en om ongebruikte modules af te skakel was nodig om ’n suksesvolle fermatuuroplaai te verseker. ’n Hommeltuig wat die gewysigde PX4-fermatuur op die Pixhawk uitvoer, is in vlug getoets en daarna is die hoektempo vlugdata geteken en ontleed. Die plotte toon dat die MVB-hoektempo beheerder in staat is om die verwysing vir hoektempo’s goed te volg. Die bevindinge van hierdie nuwe benadering demonstreer die haalbaarheid om modelvoorspellende beheer op die PX4 fermatuur te ïmplementeer, en stel voor dat ’n Pixhawk met ’n groter geheue gebruik moet word om MVB te integreer met ander PX4 beheer modules.
Description
Thesis (MEng)--Stellenbosch University, 2018.
Keywords
Model predictive control -- Design, Px4 firmware, Pixhawk, Constraints (Artificial intelligence), UCTD, Autopilot (Computer program language), Flight control
Citation