Issue 
Int. J. Simul. Multisci. Des. Optim.
Volume 8, 2017



Article Number  A8  
Number of page(s)  9  
DOI  https://doi.org/10.1051/smdo/2017001  
Published online  10 February 2017 
Research Article
Tuning PID attitude stabilization of a quadrotor using particle swarm optimization (experimental)
^{1}
LCP, Ecole Nationale Polytechnique, Elharrach, 16200
Algiers, Algeria
^{2}
Faculty of Technology, M’sila University, 2800
M’sila, Algeria
^{*} email: kho_moh@yahoo.fr
Received:
31
October
2016
Accepted:
3
January
2017
Proportional, Integral and Derivative (PID) controllers are the most popular type of controller used in industrial applications because of their notable simplicity and effective implementation. However, manual tuning of these controllers is tedious and often leads to poor performance. The conventional ZieglerNichols (ZN) method of PID tuning was done experimentally enables easy identification stable PID parameters in a short time, but is accompanied by overshoot, high steadystate error, and large rise time. Therefore, in this study, the modern heuristics approach of Particle Swarm Optimization (PSO) was employed to enhance the capabilities of the conventional ZN technique. PSO with the constriction coefficient method experimentally demonstrated the ability to efficiently and effectively identify optimal PID controller parameters for attitude stabilization of a quadrotor.
Key words: Quadrotor dynamic model / PID controller / ZieglerNichols method / Particle swarm optimization
© M. Khodja et al., Published by EDP Sciences, 2017
This is an Open Access article distributed under the terms of the Creative Commons Attribution License (http://creativecommons.org/licenses/by/4.0), which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.
1 Introduction
The most popular of Unmanned Arial Vehicles is the quadrotor. Because of its ability to perform agile manoeuvres, takeoff and land vertically, and hover, it is an ideal choice for search and surveillance, rescue, monitoring, military, and agriculture applications in both outdoor and indoor environments.
However, it is difficult to model [1, 2] complex and suitable quadrotor control systems. Many control methods, such as fractional sliding mode [3], backstepping [4], nonlinear proportionalintegralderivative (PID) [5], sliding model controllers [6], and fuzzy PID [7], have been studied. The simplest control method among these is the PID controller [8] because of its low program complexity, low processing speed, and small program size, occupying little memory. Therefore, the PID can be implemented in a lowcost microcontroller.
In PID control design, the parameters of the controllers are tuned manually or by using the tuning rules found in the linear controlbased literature, such as ZieglarNichols (ZN) tuning [9, 10]. Unfortunately, the manual tuning method has limitations of being time consuming and very tedious. While the conventional ZN method has been very useful and helpful in our research in terms of practicality, it is criticized by many other researchers.
After developing a quadrotor, we were met with the problem of how to choose PID gains in order for our quadrotor to achieve stability. The fastest method with the least required effort to experimentally select the appropriate PID gains was the ZN tuning. Within a few minutes of implementation we could obtain the PID gain values required to stabilize the quadrotor. With respect to time and effort, the ZN method was the most advantageous. However, regarding robustness, overshoot, steadystate error, and rise time, the ZN method falls short of the necessary standards. To overcome this, we instead employed a modern heuristics approach [11–14], specifically particle swarm optimization (PSO) with the constriction coefficient method unlike in [15] they use the basic PSO. PSO used to determine the optimal PID gains for attitude stabilization of the quadrotor experimentally counterpart in [15] they applied for position control and is very clear the optimization of the attitude stabilisation has more priority than position control optimization for quadrotor. This stands in contrast with many other research efforts whose results come only from simulations [16–18]. The second advantage of the ZN method found in this study is that it produces PID gains that can be put into intervals, such that the PSO search within an interval by determining the sum of the Integral of Square Error (ISE) and the maximum of the overshoot as a multiobjective function [19] or a fitness function. Using this process, we found the optimized PID controller via simulation (offline) and validated the results experimentally. The results demonstrated the effectiveness of PSO applied to PID controllers for attitude stabilization of the quadrotor.
This paper is organized as follows: Section 2 provides a general description and presents a dynamical model of a quadrotor. Section 3 gives an overview of the ZN method. Section 4 gives an overview of PSO and presents the PID controller design method incorporating PSO using a simulation to achieve stabilization of the quadrotor. Section 5 shows the simulation and experimental results. Section 6 provides the conclusions of the study.
2 The quadrotor model
A quadrotor has four propellers mounted on the end of two perpendicular arms and is actuated by four brushless DC motors. A basic configuration of a quadrotor [20] is shown in Figure 1.
Figure 1. A basic configuration of a quadrotor. 
Each rotor pair of the same arm rotates in the same direction; one pair rotates clockwise, while the other rotates counter clockwise. The quadrotor moves by adjusting the angular velocity of each rotor. We used the simplified attitude dynamical model of a quadrotor same in [1] given by:(1) where f_{i} are the thrust forces generated by four motors, l is the length of the quadrotor arm, and τ_{θ}, τ_{φ}τ_{Ψ} are the generated torques of roll and pitch and yaw plans. τ_{m1}, τ_{m2}, τ_{m3}, τ_{m4} are induced moments from there propeller rotation [20], inertial of quadrotor are I_{x}, I_{y}, and I_{z} calculated by SOLIDWORKS, the trust and drag coefficients data I found them in this technical data on this website [23] (see Table 1).
Quadrotor parameters.
The dynamic thrust of the motordriven propeller was identified experimentally as described in references [2, 21] also the trust coefficient calculated in same experiment is approximate to trust coefficient in [23] (see Table 1). The frequency response of the propeller (GemFan 5030) speed with respect to the duty ratio of the motor speed controller (see Table 2) showed that dynamic thrust and duty ratio could be modelled as a firstorder transfer function [21].
Some experiment results for trust calculation.
Our platform was based on a 250 mm (QAV250) fiberglass frame similar to experiment in this work [24]. The onboard autopilot software was developed in home, and the electronic components included an Arduino Due, an IMU, and an electronic speed controller the real photo of quadrotor in Figure 2. The front adds part because Arduino Duo is long and the black thing below it is just polyster to reduce noise affected on Ultrasonic sensor. Since the software was mostly customdeveloped, it could easily interface with any additional sensors and modify the control laws of the PID control strategy [17] for attitude stabilization in Figure 3.
Figure 2. The realized quadrotor. 
Figure 3. PID control strategy for attitude stabilization [17]. θ_{d}: Desired roll angle; φ_{d}: desired pitch angle; Ψ_{d}: desired yaw angle. 
3 Tuning the PID controller using the ZieglerNichols method
The Ziegler and Nichols proposed rules [9, 10] for determining the values of proportional gain K_{p}, integral time K_{i}, and derivative time K_{d}. The determination of such parameters of PID controllers or tuning of PID controllers can be achieved onsite using experiments involving the quadrotor. There are two methods within the ZN tuning approach. The first method of ZN tuning is based on the openloop step response of the system.
The second method of ZN tuning, used in this paper, is a closedloop tuning method that requires finding the ultimate gain and period. This can be achieved by adjusting the controller gain (K_{c}) until the system undergoes sustained oscillations (at the ultimate gain or critical gain), while maintaining the integral time constant (T_{i}) at infinity and the derivative time constant (T_{d}) at zero. This paper used the second method as shown in Table 3 [9, 10].
ZieglerNichols tuning rule based on critical gain K_{c} and critical period P_{c}.
After completing development of the quadrotor, we had to determine the PID parameters efficiently, and with little theoretical basis since initially, the quadrotor dynamics were not precisely determined. Therefore, the ZN method was applied as the first step towards stabilizing the quadrotor because it enabled experiments to be used for realtime acquisition of responses that could be plotted to determine PID parameters. Our quadrotor was symmetric, so therefore we only applied this method to the pitch component of the PID controller.
To verify the performance we used the integral of square error (ISE) as comparison criteria, defined as follows:(2)
Therefore, for PSOPID tuning, this criteria (2) was used as the objective function to seek a set of PID gains such that the control system met the minimum performance criteria.
4 PID tuning by particle swarm optimization
There are a lot of heuristic optimization methods, and one of the most technical of these is PSO, first created by Kennedy and Eberhart in 1995 [13]. It is based on Swarm Intelligence methods, and aims to identify the optimal solution by imitating the movement of particles in a swarm similar to fish schooling or birds flocking.
There are several algorithms used for PSO [11–13]. In this work, the integral of square error (ISE) and maximum overshoot of error were fitness functions (multiobjective functions), and the constriction coefficient [13, 22] method was selected because method was selected because never used before with our case. The swarm is guaranteed to converge [13] and with simplest control of the convergence speed, whereby the speed in (3) and position in (4) of each particle changed according the following:(3)where:with: c_{1} and c_{2} are the acceleration coefficients, and r_{1} and r_{2} are random values in [0, 1].(4)
PSO was used to tune PID gains (K_{p}, K_{i}, and K_{d}) offline using the model given in equation (1). PSO first produced an initial swarm of particles in the search space. Each particle represented a solution for PID gains, where their values were set within the range of the produced ZN gains. Fifteen and 20 were chosen as the number of particles within the swarm and iterations within the search, respectively. A good set of PID controller gains yielded a good system response, and resulted in minimization of the performance criteria in listed in equation (2). The general strategy of the optimization problems is represented in Figure 4.
Figure 4. The general strategy of optimization. Note: Overshoot = Max(Actual angle) − Desired angle. 
5 Results and discussion
In this section we describe the simulation and experimental results for three sets of PID gains. The first PID gains were obtained using the ZN method. The second PID gains were obtained using PSO, for which the objective function was equal to sum of the integral square of error and maximum of overshoot. The third PID gains were also obtained using the PSO method, but the objective function was replaced with the Integral Square of Error function.
5.1 ZN PID tuning
This First, we employed ZN tuning experimentally to determine PID controller gains. Then, we varied the ZN gain (K_{c}) until an oscillation appeared in our experiment as shown in Figure 5.
Figure 5. Critical gain (K_{c}) variation in real time. 
Figure 6 shows the pitch angle error when the ZN gain was varied. Here, a decrease in error could be observed as K_{c} increased, until oscillation occurred. Based on the ZN method, the critical gain is depicted in the black rectangular region in Figure 6 and its corresponding value is shown in Figure 5 (K_{c} = 40). A magnified rendition of the black rectangle shown in Figure 6 was used to calculate the critical period (P_{c} = 0.2 s), as shown in Figure 7.
Figure 6. Pitch error angle when K_{c} was varied in real time. 
Figure 7. Magnified black rectangle to calculate critical period P_{c} in real time. 
Using the second ZN method in Table 1, we found that:
K_{c} = 40, P_{c} = 0.2 for PID rule: K_{p} = 0.6 × K_{c} = 24; K_{i} = 0.5 × P_{c} = 0.1; K_{d} = 0.125 × P_{c} = 0.025.
5.2 PSO – PID gains optimization
We established intervals for the resulting PID gains achieved using the ZN method, as shown in Table 4. The PSO method then searched for the optimal PID gains depending on the objective function. The search for the optimal PID was conducted offline, meaning that all calculations were performed via simulation, for which the determined gains were verified both using the simulation and experimentally. We used two different objective functions: the first was the sum of the maximum of the overshoot and the Integral Square of Error (ISE), and the second was just the Integral Square of Error.
Limited PSO search interval based on ZN derived gains.
The PSO needed to determine number of particles and iterative number in order to calculate the PID gains. In our case the number, of particles was set to 15 and the iterative number was set to 20. Figure 8 shows changes in the particles’ positions during the search for optimized PID gains according to the first objective function. The blue points represent the swarms, the black points represent the local best particles, and the red points represent the global best particles.
Figure 8. Change in particles’ position during the search for the optimal PID controller gains. 
The calculated PID gains obtained using two objective functions and the ZN method, are summarized in Table 5.
Summary of PID gains obtained by ZN tuning and PSO.
The PID gains shown in Table 5, were tested in our simulation model, and the step responses for the pitch angles are shown in Figure 9. The comparative simulation results are given in Table 6, based on ISE, overshoot, and rise time.
Figure 9. Pitch angles step responses for the three PID gains in simulation. 
Comparison of the ZN and PSO gains for pitch angle stabilization.
The objective function of PSO2 was only the Integral Square of Error. From Table 6, it can be seen that the rise time was the same for PID ZN and PSO2, given the existing overshoot, but with lower ISE in the latter. It is very clear that the rise time and overshoot in the PID ZN case was ameliorated by the PSO2. However, when we added the maximum of the overshoot as a second criterion to the objective function, it resulted in a lower overshoot, but with a smaller rise in ISE.
The PID controllers in Table 5, were tested experimentally, and the plots of the pitch error angle in steadystate for PID ZN, PID PSO1, and PID PSO2 are shown in Figures 10, 12, and 14, respectively. The pulse responses are shown in Figures 11, 13, and 15, respectively and the comparative results are listed in Table 7, based on ISE for steadystate and pulse response conditions.
Figure 10. Pitch error angle in steadystate for ZN PID. 
Figure 11. Pitch error angle for ZN PID. 
Figure 12. Pitch error angle in steadystate for PID PSO1. 
Figure 13. Pitch error angle for PID PSO1. 
Figure 14. Pitch error angle in steadystate for PSO2. 
Figure 15. Pitch error angle for PSO2. 
Experimental comparative results for three optimized PID gains.
The simulation results of the ZN tuned PID show that the pitch angle error response produced high ISE, high overshoot, and low rise time, but a better PID performance was obtained by applying PSO. Different objective functions provided different PID controller gains. In case when the overshoot was taken into consideration by the objective function, the pitch error response produced the lowest overshoot with a low ISE, but the highest rise time. In the case when the overshoot was not taken into consideration by the objective function, the response produced the lowest ISE with an existing overshoot. The experimental results in Table 7 and Figures 10–14 depict the corresponding simulation analyses. However, the Integral Square of Error of PSO1 was lower than PSO2 because the response of the latter had greater overshoot than PSO1. In actual tests, the quadrotor is a noisy system and we cannot eliminate the gyroscopic torque and Corioliscentripetal force that were neglected in the simulation results. For roll and the yaw motions, PID controllers were optimized using the same method presented in Figure 16, and demonstrated successful results and the error of three angles roll, pitch and yaw around 0.3°.
Figure 16. Error angle of the roll, pitch and yaw implemented together in experiment. 
6 Conclusion
This research paper presents an optimized PID controller for attitude stabilization of a quadrotor using PSO the constriction coefficient method was never used before for attitude control of a quadrotor. The main advantage of optimization process that find the optimal solution with scientific method not as manual finding depending on the luck, and let the user of it more confidence with their results. The proposed method was tested both using a MATLAB simulation and experimentally. The simulation and experimental results were also compared with a conventional ZN tuning PID controller and with two different objective functions that the PSO depends on to search the optimal PID controller. The efficiency of PSO was verified through experimental results.
References
 Bouabdallah S. 2007. Design and control of quadrotors with application to autonomous flying. Switzerland: Autonomous Systems Laboratory, Swiss Federal Institute of Technology Lausanne. (In the text)
 Alexis K, Nikolakopoulos G, Tzes A. 2012. Model predictive quadrotor control: attitude, altitude and position experimental studies. IET Control Theory & Applications, 6(12), 1812–1827. [CrossRef] [MathSciNet] (In the text)
 Carlos IE, Aldo JMV, Anand SO. 2016. Attitude control of quadrotors based on fractional sliding modes: theory and experiments. IET Control Theory & Applications, 10(7), 825–832. [CrossRef] [MathSciNet] (In the text)
 Chen F, Jiang R, Zhang K, Jiang B, Tao G. 2016. Robust backstepping sliding mode control and observerbased fault estimation for a quadrotor UAV. IEEE Transactions on Industrial Electronics, 63(8), 5044–5056. (In the text)
 Benboualia A, Tadjine M, ChrifiAlaoui L. 2016. Robust tracking control of quadrotor using a nonlinear PID on eulidean group. The Mediterranean Journal of Measurement and Control, 12(1), 529–536. (In the text)
 Haoping W, Xuefei Y, Yang T, et al. 2015. Attitude control of a quadrotor using model free based sliding model controller, in Proceedings of International Conference on Control Systems and Computer Science, Bucharest. p. 149–154. (In the text)
 Faiz AS, Kushsairy K, Izhar ABM, et al. 2015. Attitude stabilization of quadrotor (UAV) system using fuzzy PID controller (an experimental test), in Proceedings of International Conference on Computing Technology and Information Management, Johor. p. 99–104. (In the text)
 Tanveer MH, Faiz AS, Hazry D, et al. 2013. Stabilized controller design for attitude and altitude controlling of quadrotor under disturbance and noisy conditions. American Journal of Applied Sciences, 10(8), 819–831. [CrossRef] (In the text)
 Ogata K. 2010. Modern control engineering, 5th edn, Pearson Education, New Jersey, USA. (In the text)
 Mallesham G, Mishra S, Jha AN. 2011. ZieglerNichols based controller parameters tuning for load frequency control in a microgrid, in Proceedings of International Conference on Energy Automation and Signal, Bhubaneswar, Odisha. p. 1–8. (In the text)
 Federico M, Beata W. 2015. Particle swarm optimization (PSO). A tutorial. Chemometrics and Intelligent Laboratory Systems, 149, 153–163. [CrossRef] (In the text)
 Dian PR, Siti MS, Siti SY. 2011. Particle swarm optimization: technique, system and challenges. International Journal of Computer Applications, 14(1), 19–26.
 Andries PE. 2007. Computational intelligence: an introduction, 2nd edn. John Wiley & Sons, West Sussex, England. (In the text)
 Khodier M. 2013. Optimisation of antenna arrays using the cuckoo search algorithm. IET Microwaves Antennas & Propagation, 7(6), 458–464. [CrossRef] (In the text)
 Mac TT, Copot C, Duc TT, Keyser RD. 2016. AR.Drone UAV control parameters tuning based on particle swarm optimization algorithm, in Proceedings of International Conference on Automation, Quality and Testing, Robotics – THETA 20th edition (AQTR), ClujNapoca, Romania, p. 475. (In the text)
 Mohammed JM, Mofeed TR, Abduladhem AA. 2014. Design optimal PID controller for quad rotor system. International Journal of Computer Applications, 106(3), 15–20. [CrossRef] (In the text)
 Boubertakh H, Bencharef S, Labiod S. 2013. PSObased PID control design for the stabilization of a quadrotor, in Proceedings of International Conference on Systems and Control, Algiers, Algeria. p. 514–517. (In the text)
 Bolandi H, Rezaei M, Mohsenipour R, et al. 2013. Attitude control of a quadrotor with optimized PID controller. Intelligent Control and Automation, 4(3), 335–342. [CrossRef] (In the text)
 Hélio FF, Paulo BDMO, Eduardo JSP, et al. 2015. Manyobjective PSO PID controller tuning, in Proceedings of 11th Portuguese Conference on Automatic Control, Portuguese. 183–192. (In the text)
 Hao L, Yongqiang B, Geng L, et al. 2012. Robust attitude control of uncertain quadrotors. IET Control Theory & Applications, 7(11), 1583–1589. (In the text)
 Myunggon Y. 2016. A transfer function model of thrust dynamics for multirotor helicopters. International Journal of Engineering Research & Technology, 5(1), 15–18, ISSN 22780181 (In the text)
 Goranka Š, Sanjin B, Roberto Ž. 2014. Comparative analysis of PSO algorithms for PID controller tuning. Chinese Journal of Mechanical Engineering, 27(5), 928–936. [CrossRef] (In the text)
 http://ecalc.ch/. (In the text)
 Liu C, Prior SD. 2015. Design and implementation of a mini quadrotor control system in GPS denied environments. Unmanned Aircraft Systems (ICUAS), 2015 International Conference on, Denver, CO, p. 462–469. (In the text)
Biography
Khodja Mohammed Abdallah received the engineer degree from M’sila university – M’sila – Algeria, in 2006 and the MS degrees from National Polytechnic School of Algiers (ENP), – Alharrche – Algiers, Algeria, in 2011, in electrical engineering, and actually PhD student in same school and from 2012 to now assistant professor in electrical engineering department at M’sila university. Current research interests include intelligent control for robotic systems.
Prof Mohamed Tadjine received his Engineering degree from the National Polytechnic School of Algiers (ENP), Algeria in 1990 and a PhD degree in Automatic Control from the National Polytechnic Institute of Grenoble (INPG), France, in 1994. From 1995 to 1997, he was a Researcher at the Automatic Systems Laboratory, Amiens, France. Since 1997, Professor Tadjine has been with the Department of Electric Engineering, ENP, Algeria. His research interests are in robust and nonlinear control.
Prof Mohamed Seghir Boucherit was born in 1954 in Algiers. He received the Engineer degree in Electrotechnics, the Master degree and the Doctor (PhD degree) in Electrical Engineering, from the National Polytechnic School of Algiers (ENP), of Algiers, Algeria, in 1980, 1988, and 1995, respectively. Upon graduation, he joined the Electrical Engineering Department of the National Polytechnic School of Algiers (ENP). He is a Professor, Head of the Industrial systems and Diagnosis research team of the Process Control Laboratory and his research interests are in the area of Electrical Drives, Process Control Applications, and Diagnosis.
Moussa Benzaoui received the Master degree from M’sila university – Mechanical Department –M’sila Algeria, in 2016. Current research interests include design of drone using SOLIDWORKS.
Cite this article as: Khodja MA, Tadjine M, Boucherit MS & Benzaoui M: Tuning PID attitude stabilization of a quadrotor using particle swarm optimization (experimental). Int. J. Simul. Multisci. Des. Optim., 2017, 8, A8.
All Tables
ZieglerNichols tuning rule based on critical gain K_{c} and critical period P_{c}.
All Figures
Figure 1. A basic configuration of a quadrotor. 

In the text 
Figure 2. The realized quadrotor. 

In the text 
Figure 3. PID control strategy for attitude stabilization [17]. θ_{d}: Desired roll angle; φ_{d}: desired pitch angle; Ψ_{d}: desired yaw angle. 

In the text 
Figure 4. The general strategy of optimization. Note: Overshoot = Max(Actual angle) − Desired angle. 

In the text 
Figure 5. Critical gain (K_{c}) variation in real time. 

In the text 
Figure 6. Pitch error angle when K_{c} was varied in real time. 

In the text 
Figure 7. Magnified black rectangle to calculate critical period P_{c} in real time. 

In the text 
Figure 8. Change in particles’ position during the search for the optimal PID controller gains. 

In the text 
Figure 9. Pitch angles step responses for the three PID gains in simulation. 

In the text 
Figure 10. Pitch error angle in steadystate for ZN PID. 

In the text 
Figure 11. Pitch error angle for ZN PID. 

In the text 
Figure 12. Pitch error angle in steadystate for PID PSO1. 

In the text 
Figure 13. Pitch error angle for PID PSO1. 

In the text 
Figure 14. Pitch error angle in steadystate for PSO2. 

In the text 
Figure 15. Pitch error angle for PSO2. 

In the text 
Figure 16. Error angle of the roll, pitch and yaw implemented together in experiment. 

In the text 
Current usage metrics show cumulative count of Article Views (fulltext article views including HTML views, PDF and ePub downloads, according to the available data) and Abstracts Views on Vision4Press platform.
Data correspond to usage on the plateform after 2015. The current usage metrics is available 4896 hours after online publication and is updated daily on week days.
Initial download of the metrics may take a while.