HYPOTHESIS AND THEORY article
Online Tuning of PID Controller Using a Multilayer Fuzzy Neural Network Design for Quadcopter Attitude Tracking Control
- 1Faculty of Mechanical and Aerospace, Sejong University, Seoul, South Korea
- 2Department of Convergence Engineering for Intelligent Drone, Sejong University, Seoul, South Korea
- 3Faculty of Mechatronics and Electronics, Lac Hong University, Bien Hoa, Vietnam
This study presents an online tuning proportional-integral-derivative (PID) controller using a multilayer fuzzy neural network design for quadcopter attitude control. PID controllers are simple but effective control methods. However, finding the suitable gain of a model-based controller is relatively complicated and time-consuming because it depends on external disturbances and the dynamic modeling of plants. Therefore, the development of a method for online tuning of quadcopter PID parameters may save time and effort, and better control performance can be achieved. In our controller design, a multilayer structure was provided to improve the learning ability and flexibility of a fuzzy neural network. Adaptation laws to update network parameters online were derived using the gradient descent method. Also, a Lyapunov analysis was provided to guarantee system stability. Finally, simulations concerning quadcopter attitude control were performed using a Gazebo robotics simulator in addition to a robot operating system (ROS), and their results were demonstrated.
In the 4th industrial revolution era, the application of multi-copters has significantly expanded, and it has thus attracted the interest of many researchers specialized in multi-copter control engineering. Multi-copters need to maintain accurate attitudes to ensure stable flight, so the development of accurate and stable controllers for multi-copters is essential. The most popular controller used for multi-copters is the cascaded proportional-proportional integral derivative controller (PPID) (Hernandez and Frias, 2016; Salas et al., 2019; Santos et al., 2019; Xuan-Mung and Hong, 2019a,b). Since PID is a linear controller, it is generally hard to use to achieve the highest control performance for non-linear control systems (Sarabakha et al., 2017). Furthermore, in the design of a PID controller, it is necessary to obtain the exact mathematical model of the control system and to optimize the gain value to achieve the desired performance. However, this work requires complexity calculations and an accurate modeling plant.
Gain tuning for PID controllers is time-consuming, as it depends on the knowledge of dynamic plants and the experience of expert operators (Kim et al., 2007). Mathematical models are different, as they depend on the size and appearance of multi-copters. Even if it is the same aircraft, the center of gravity can be different (Kurak and Hodzic, 2018). Therefore, the gain values are always flexible, and it may take longer to find suitable values. However, such tasks must be completed correctly, as an incorrect calculation can lead to terrible problems, such as falling or bumping into a people or objects. In past decades, many studies have been conducted to solve such problems (time-consuming, costly, etc.; Fatan et al., 2013; Kuantama et al., 2017; Noordin et al., 2017; Rouhani et al., 2017; Sumardi and Riyadi, 2017; Prayitno et al., 2018; Thanh and Hong, 2018; Chen et al., 2019; Rabah et al., 2019; Soriano et al., 2020). The Ziegler Nichols method is a well-known for tuning PID parameters (Azman et al., 2017). However, it produces oscillatory responses and yields overshoot problems (Zahir et al., 2018). Moreover, it cannot be applied in the online-tuning of parameters, and the control performance can be further improved.
In recognizing the above-mentioned limitation of traditional PID controllers, many researchers have provided methods for auto-tuning PID parameters (Amoura et al., 2016; De Keyser et al., 2016; Concha et al., 2017; Live et al., 2017; Mendes et al., 2017; Wang, 2017; Bernardes et al., 2019). In which, using the fuzzy neural network to tune PID parameter controllers has attracted the attention of many researchers. In 2018, Davanipour et al. proposed a self-tuning PID controller based on a fuzzy wavelet neural network (Davanipour et al., 2018). In 2019, Tripathy et al. introduced a fuzzy PID controller for load frequency control using spider monkey optimization (Tripathy et al., 2019). In 2017, Wang et al. provided an improved fuzzy PID controller design using predictive functional control structure (Wang et al., 2017). These studies could reduce the effort required for tuning the required parameters for PID controllers. However, most of their methods were complicated, but the control performance could be further improved.
In recent years, many studies have investigated the fuzzy neural network (FNN), which is a combination of fuzzy systems and neural networks. Therefore, combined FNN systems have the advantages of both fuzzy systems and neural networks, such as human-like reasoning and learning capabilities. Using the neural network structure, FNN parameters can be trained online to achieve suitable values. According to the above discussions, this study presents a method for auto-tuning PID parameters using multilayer fuzzy neural network (PID-MFNN) to control the attitude the quadcopters. Compared with the previous studies (Wang et al., 2017; Davanipour et al., 2018; Tripathy et al., 2019), our proposed PID-MFNN has some advantages, such as no need for offline training. The major differences and improvements among this study and related works are shown in Table 1. Also, the fuzzy weights and fuzzy membership functions can be updated online, and the multilayer structure is applied to improve the control performance. The main contributions of this study are summarized as follows: (1) the successful design of a multilayer structure was provided to improve the learning ability and flexibility of a FNN; (2) the adaptation laws for updating the parameters of a controller online were derived by using the gradient descent method; (3) the simulation results of controlling the attitude of a quadcopter were provided to illustrate the effectiveness of the control design method.
The rest of this paper is organized as follows. The quadcopter dynamics model and quadcopter controller are given in section Problem Formulation. The PID-MFNN structure and its learning parameter are described in section PID-MFNN Structure and Parameter Learning. The simulation results of controlling the quadcopter attitude are presented in section Simulation Results. Finally, the conclusions are given in section Conclusion.
Quadcopter Dynamics Model
The quadcopter schematic and its reference frames are shown in Figure 1. In which, the earth-frame and quadcopter body frame are denoted by E(xE, yE, zE) and B(x, y, z). The dynamic equations of the quadcopter are given as:
where θ, ϕ, and ψ stand for the three Euler angles: roll, pitch, and yaw, respectively; Jx, Jy and Jz stand for the moment of inertia for the x, y, and z axes, respectively; l denotes the length of the quadcopter's arm; U1 denotes the total thrust on the body in the z-axis; U2, U3, and U4 denote the roll, pitch, and yaw torques, respectively, which are given as
where denotes the thrust of the i-th motor; Ωi denotes the speed of the i-th motor; Ct and Cd stand for the thrust and drag coefficients, respectively.
The quadcopter controller scheme is given in Figure 2. There are two kinds of controllers that need to be considered in quadcopter control: position controller and attitude controller. The PPID attitude controller is given in Figure 3. The output of the outer-loop controller is given by
where Gθ, Gϕ, and Gψ denote the proportional gain for the roll, pitch, and yaw outer-loop controller, respectively; eθ, eϕ, and eψ are the angle errors of the roll, pitch, and yaw, respectively.
where θref, ϕref, and ψref are the angle references of the roll, pitch, and yaw, respectively.
The output of the PID inner-loop controller is given by
where , , , , , , , , and , are the PID gains for the roll, pitch, and yaw inner-loop controller; , , and denote the angular velocity errors of the roll, pitch, and yaw, respectively.
To obtain suitable values for the PID gains in the outer-loop and inner-loop controller, the PID-MFNN was designed in the following section to adjust the gains for the PPID controller online.
PID-MFNN Structure and Parameter Learning
The fuzzy rule forms for the proposed PID-MFNN controller are:
where ii is the fuzzy input; μijk is the membership function (MF) for the input i-th, block j-th, and layer k-th; wklo is the fuzzy weight for the layer k-th, rule l-th, and output o-th.
The auto-tuning algorithm structure of the PID-MFNN controller is shown in Figure 4 in which, the MFNN structure is applied to adjust the PPID controller gains online. As shown in Figure 5, the MFNN structure includes five spaces as follows:
1) The input space: the fuzzy input vector, I = [i1, i2, …, ini], is prepared in this space. Each node corresponds to one input and is directly transferred to the next space.
2) The membership function space: the membership grades are calculated in this space using the fuzzy inputs and the Gaussian membership functions (GMFs). As shown in Figure 6, the multilayer fuzzy membership function is provided to improve the learning ability and flexibility of the FNN. The outputs of this space are computed as:
where mijk and vijk are the mean and variance of the GMFs.
3) The fuzzy firing space: the fuzzy firing strength is calculated in this space using the membership grades as follows:
where fkl is the fuzzy firing strength for the l-th rule in the k-th layer.
Then, the fuzzy firing vector is presented as
4) The fuzzy weight space: in this space, the fuzzy weights wklo are provided to connect the fuzzy firing space and output space. The fuzzy weight vector for the o-th output is presented as
5) The output space: the final outputs of this space are the PID gains for the outer-loop and inner-loop controllers. Defuzzification is performed using the product operation as follows:
Using the proposed MFNN to adjust the PID gains online, the desired performance of the control network can be achieved. The adaptation laws for updating the parameters of the proposed PID-MFNN controller online are explained in the following section.
Figure 6. Fuzzy membership function and rule base: (A) the conventional fuzzy system and (B) the proposed multilayer fuzzy neural network with two layers.
First, considering the outer-loop controller, Equation (3) can be rewritten, where the gains Gθ, Gϕ, and Gψ are obtained using the output of the proposed MFNN in Equation (10).
where Θ is replaced by (θ, ϕ, ψ).
By rewriting the Equation (6),
A Lyapunov function is defined as , using the gradient descent approach and chain rule, and the parameter update laws for PID-MFNN can be obtained as follows:
where , , and are the connecting weight, mean, and variance of the outer-loop MFNN controller; , , and are the positive learning rates.
Then, considering the inner-loop controller, Equation (5) can be rewritten, where the gains , , , , , , , , and are obtained using the outputs of the proposed MFNN.
where ; ;
where α is replaced by (p, i, d).
By rewriting the Equation (4),
A Lyapunov function can be defined as , using the gradient descent approach and chain rule, and the parameter update laws for PID-MFNN can be obtained as:
where , , and are the connecting weight, mean, and variance of the inner-loop MFNN controller; TΘ can be Tϕ, Tθ, or TΨ, which are the quadcopter transfer functions for the yaw, pitch and roll angles; , , and are the positive learning rates.
Using the proposed adaptation laws in (16–18) and (23–25), the parameters of the proposed PID-MFNN can be obtained. Then, the suitable gains for the outer-loop and inner-loop PPID controller can be achieved.
The Convergence Analysis
The Lyapunov cost function is defined as
By applying the Taylor expansion,
By rewriting (28) using (29) and (16),
By rewriting (27) using (30),
From (31), if is chosen to satisfy , then ΔV(t) < 0. Consequently, the convergence of the adaptation law is guaranteed by the Lyapunov theorem. Similarly, the convergence of the adaptation laws for , , and can be obtained.
The computational complexity of our approaches using big O notation is given as:
+ Big O notation for PID-CFNN:
+ Big O notation for PID-MFNN:
T: is the simulation time.
nj1: the number of membership functions in input 1.
nj2: the number of membership functions in input 2.
nk: the number of layers.
In our proposed network, we choose nj1 = nj2 = 3 and nk = 2.
The quadcopter parameters used in this model were chosen as shown in Table 2.
The goal of the control system is to control the attitude of the quadcopter following the reference set-point trajectory:
The Gazebo simulation interface is shown in Figure 7. The tracking performances of the quadcopter attitude under square wave and sine wave commands are given in Figures 8, 11, respectively. The black line presents the reference set-point trajectory. The red and blue lines present the quadcopter attitude output using the PID-MFNN controller and the PID conventional fuzzy controller (PID-CFNN), respectively. The control signals under the square wave and sine wave commands are shown in Figures 9, 12, respectively. The tracking errors under the square wave and sine wave commands are given in Figures 10, 13, respectively. The comparison results concerning the root mean square error (RMSE) between the proposed PID-MFNN controller and PID-CFNN controller are given in Tables 3, 4. From Figures 8–13, it can be seen that the proposed PID-MFNN controller has better control performance with a faster convergence speed and smaller tracking errors compared with the conventional fuzzy controller, which demonstrates the effectiveness of our proposed control method. The RMSE was used to evaluate the effectiveness of the control performance as follows:
where ns is the number of samples.
Figure 8. The tracking performance for the quadcopter attitude control for the square wave commands.
The parameter settings of the proposed PID-MFNN controller were chosen as ni = 2, nj = 3, and nk = 2; the initial GMF for the fuzzy rules are given as mij1 = [−0.6, 0, 0.6], vij1 = [0.3, 03, 0.3], mij2 = [−0.4, 0, 0.4], and vij2 = [0.2, 02, 0.2]; the initial fuzzy weight is wklo = 0.2; the learning rates were chosen as ; the sampling time was 0.01 s. The same parameters were chosen for PID-CFNN, but only the number of layers was nk = 1, and all GMFs were put in one layer.
The simulation results in Figures 8, 10 show that the proposed PID-MFNN controller has better performance than the PID-CFNN controller in terms of the rising time, settling time, and overshoot. The multilayer structure in our proposed controller, which contains a multilayer MF, provides it with a better scope regarding errors and disturbances compared with the single MF structure in PID-CFNN. The proposed PID-MFNN had a little longer computation time than the PID-CFNN due to the processing time of the multilayer structure. However, this did not affect the control performance, and the proposed PID-MFNN controller could achieve a smaller RMSE in both simulation cases. Apply some methods such as latent analysis in Wu et al. (2019) and Wu et al. (2020) to reduce the computational cost for the proposed multilayer fuzzy neural network will be our future work.
Remark 1. The conventional PID usually hard to achieve high control performance for controlling non-linear systems due to its parameters are usually tuned for local points based on a linearization method (Mohan and Sinha, 2008; Cetin and Iplikci, 2015). Therefore, it is not suitable for controlling highly complex and non-linear systems, such as quadcopters. However, in our proposed PID-MFNN method, we designed adaptation laws for updating the MFNN network parameters online, so the output of the MFNN network can auto-tune the PID gains. Therefore, our proposed PID-MFNN is suitable for quadcopters as well as other non-linear control systems.
Remark 2. By separating the member functions into a multilayer structure, the proposed method can better cover the changes in inputs. Moreover, with the proposed multilayer structure, the learning ability and flexibility of the network can be further improved.
Remark 3. The difficulties and limits in this study are described as follows. When applying our method in an experiment with real quadcopters, suitable initial parameters needed to be chosen. Otherwise, control could be lost. In our study, the simulation results were obtained using a Gazebo robot simulator, and it was easy to choose these parameters using the trial-and-error method. In our future work, we plan to apply some optimal algorithms to realize suitable initial parameters.
In this study, auto-tuning PID parameters using MFNN were successfully designed for controlling the attitude of quadcopters. The proposed method provided an effective method for obtaining suitable gains for PID controllers without the need for a mathematical system model or complicated calculations. In addition, a new multilayer structure was provided to improve the learning ability and flexibility of the used FNN. The parameters of the proposed network could be updated online using adaptation laws. Finally, the effectiveness of the proposed method was illustrated through the results of the conducted numerical simulations of quadcopter attitude control using a Gazebo robotics simulator and ROS. Our designed controller can also apply to a real quadcopter, and in our future work, we plan to apply some optimal algorithms to achieve suitable initial parameters.
Data Availability Statement
The original contributions presented in the study are included in the article/supplementary material, further inquiries can be directed to the corresponding author/s.
All authors listed have made a substantial, direct and intellectual contribution to the work, and approved it for publication.
This work was supported by the Basic Science Research Program through the National Research Foundation of Korea (NRF) funded by the Ministry of Education (2020R1A6A1A03038540) and by Korea Institute for Advancement of Technology (KIAT) grant funded by the Korea Government (MOTIE) (N0002431, the Competency Development Program for Industry Specialist).
Conflict of Interest
The authors declare that the research was conducted in the absence of any commercial or financial relationships that could be construed as a potential conflict of interest.
Amoura, K., Mansouri, R., Bettayeb, M., and Al-Saggaf, U. M. (2016). Closed-loop step response for tuning PID-fractional-order-filter controllers. ISA Trans. 64, 247–257. doi: 10.1016/j.isatra.2016.04.017
Azman, A. A., Rahiman, M. H. F., Mohammad, N. N., Marzaki, M. H., Taib, M. N., and Ali, M. F. (2017). “Modeling and comparative study of PID Ziegler Nichols (ZN) and Cohen-Coon (CC) tuning method for multi-tube aluminum sulphate water filter (MTAS),” in 2017 IEEE 2nd International Conference on Automatic Control and Intelligent Systems (I2CACIS) (Sabah: IEEE), 25–30. doi: 10.1109/I2CACIS.2017.8239027
Bernardes, N. D., Castro, F. A., Cuadros, M. A., Salarolli, P. F., Almeida, G. M., and Munaro, C. J. (2019). Fuzzy logic in auto-tuning of fractional PID and backstepping tracking control of a differential mobile robot. J. Intell. Fuzzy Syst. 37, 4951–4964. doi: 10.3233/JIFS-181431
Concha, A., Varadharaj, E., Hernandez-Rivera, N., and Gadi, S. (2017). “A novel implementation technique for genetic algorithm based auto-tuning PID controller,” in 2017 IEEE International Conference on Power, Control, Signals and Instrumentation Engineering (ICPCSI) (Chennai: IEEE), 1403–1408. doi: 10.1109/ICPCSI.2017.8391942
Davanipour, M., Javanmardi, H., and Goodarzi, N. (2018). Chaotic self-tuning PID controller based on fuzzy wavelet neural network model. Iran. J. Sci. Technol. Trans. Electr. Eng. 42, 357–366. doi: 10.1007/s40998-018-0069-1
Fatan, M., Sefidgari, B. L., and Barenji, A. V. (2013). “An adaptive neuro pid for controlling the altitude of quadcopter robot,” in 2013 18th International Conference on Methods & Models in Automation & Robotics (MMAR) (Miȩdzyzdroje: IEEE), 662–665. doi: 10.1109/MMAR.2013.6669989
Kim, T.-H., Maruta, I., and Sugie, T. (2007). “Particle swarm optimization based robust PID controller tuning scheme,” in 2007 46th IEEE Conference on Decision and Control (New Orleans, LA: IEEE), 200–205.
Kuantama, E., Vesselenyi, T., Dzitac, S., and Tarca, R. (2017). PID and Fuzzy-PID control model for quadcopter attitude with disturbance parameter. Int. J. Comput. Commun. Control 12, 519–532. doi: 10.15837/ijccc.2017.4.2962
Live, H., Wang, H., Zhu, X., Shen, Z., and Chen, J. (2017). “Simulation research of fuzzy auto-tuning PID controller based on matlab,” in 2017 International Conference on Computer Technology, Electronics and Communication (ICCTEC) (Dalian: IEEE), 180–183. doi: 10.1109/ICCTEC.2017.00047
Noordin, A., Basri, M. M., Mohamed, Z., and Abidin, A. Z. (2017). Modelling and PSO fine-tuned PID control of quadrotor UAV. Int. J. Adv. Sci. Eng. Inform. Technol. 7, 1367–1373. doi: 10.18517/ijaseit.7.4.3141
Prayitno, A., Indrawati, V., and Trusulaw, I. I. (2018). Fuzzy gain scheduling PID control for position of the AR. Drone. Int. J. Electr. Comput. Eng. 8, 1939–1946. doi: 10.11591/ijece.v8i4.pp1939-1946
Rouhani, H., Same, M., Masani, K., Li, Y. Q., and Popovic, M. R. (2017). PID controller design for FES applied to ankle muscles in neuroprosthesis for standing balance. Front. Neurosci. 11:347. doi: 10.3389/fnins.2017.00347
Salas, F. G., Orrante-Sakanassi, J., Juarez-Del-Toro, R., and Parada, R. P. (2019). A stable proportional-proportional integral tracking controller with self-organizing fuzzy-tuned gains for parallel robots. Int. J. Adv. Rob. Syst. 16:1729881418819956. doi: 10.1177/1729881418819956
Santos, M., Honório, L., Costa, E., Silva, M., Vidal, V., Neto, A. S., et al. (2019). “Detection time analysis of propulsion system fault effects in a hexacopter,” in 2019 20th International Carpathian Control Conference (ICCC) (Kraków-Wieliczka: IEEE), 1–6. doi: 10.1109/CarpathianCC.2019.8765990
Sarabakha, A., Fu, C., Kayacan, E., and Kumbasar, T. (2017). Type-2 fuzzy logic controllers made even simpler: from design to deployment for UAVs. IEEE Trans. Industr. Electron. 65, 5069–5077. doi: 10.1109/TIE.2017.2767546
Soriano, L. A., Zamora, E., Vazquez-Nicolas, J., Hernández, G., Barraza, J. A., and Balderas, D. (2020). PD control compensation based on the reinforcement learning applied to a robot manipulator. Front. Neurorobot. 14:78. doi: 10.3389/fnbot.2020.577749
Sumardi, M., and Riyadi, M. A. (2017). “Particle swarm optimization (PSO)-based self tuning proportional integral derivative (PID) for bearing navigation control system on quadcopter,” in 2017 4th International Conference on Information Technology, Computer, and Electrical Engineering (ICITACEE) (Semarang), 181–186
Tripathy, D., Barik, A. K., Choudhury, N. B. D., and Sahu, B. K. (2019). “Performance comparison of SMO-based fuzzy PID controller for load frequency control,” in Soft Computing for Problem Solving, eds J. C. Bansal, K. N. Das, A. Nagar, K. Dee, and A. K. Ojha (Khordha: Springer), 879–892. doi: 10.1007/978-981-13-1595-4_70
Wu, D., Luo, X., Shang, M., He, Y., Wang, G., and Wu, X. (2020). A data-characteristic-aware latent factor model for web services QoS prediction. IEEE Trans. Knowl. Data Eng. doi: 10.1109/TKDE.2020.3014302. [Epub ahead of print].
Wu, D., Luo, X., Shang, M., He, Y., Wang, G., and Zhou, M. (2019). A Deep latent factor model for high-dimensional and sparse matrices in recommender systems. IEEE Trans. Syst. Man Cybern. Syst. doi: 10.1109/TSMC.2019.2931393. [Epub ahead of print].
Xuan-Mung, N., and Hong, S. K. (2019b). Robust adaptive formation control of quadcopters based on a leader-follower approach. Int. J. Adv. Rob. Syst. 16:1729881419862733. doi: 10.1177/1729881419862733
Keywords: quadcopter attitude, fuzzy neural network, proportional-integral-derivative, attitude tracking control, fuzzy PID
Citation: Park D, Le T-L, Quynh NV, Long NK and Hong SK (2021) Online Tuning of PID Controller Using a Multilayer Fuzzy Neural Network Design for Quadcopter Attitude Tracking Control. Front. Neurorobot. 14:619350. doi: 10.3389/fnbot.2020.619350
Received: 21 October 2020; Accepted: 14 December 2020;
Published: 18 January 2021.
Edited by:Jose De Jesus Rubio, Instituto Politécnico Nacional (IPN), Mexico
Reviewed by:Jiancheng Lyu, Qualcomm, United States
Yu Cao, Huazhong University of Science and Technology, China
Di Wu, Chongqing Institute of Green and Intelligent Technology (CAS), China
Copyright © 2021 Park, Le, Quynh, Long and Hong. This is an open-access article distributed under the terms of the Creative Commons Attribution License (CC BY). The use, distribution or reproduction in other forums is permitted, provided the original author(s) and the copyright owner(s) are credited and that the original publication in this journal is cited, in accordance with accepted academic practice. No use, distribution or reproduction is permitted which does not comply with these terms.
*Correspondence: Sung Kyung Hong, firstname.lastname@example.org
†These authors share first authorship