Next Article in Journal
Preface: Proceedings of the 8th International Electronic Conference on Sensors and Applications
Previous Article in Journal
Fuzzy-PI Controller Tuned with HBBO for 2 DOF Robot Trajectory Control
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Proceeding Paper

Online Adaptation of a Compensatory Neuro-Fuzzy Controller Parameters Using the Extended Kalman Filter: Application on an Inverted Pendulum †

Design and Drive of Production Systems Laboratory, Department of Automation, Faculty of Electrical and Computing Engineering, University Mouloud Mammeri of Tizi-Ouzou, Tizi-Ouzou 15000, Algeria
*
Author to whom correspondence should be addressed.
Presented at the 1st International Conference on Computational Engineering and Intelligent Systems, Online, 10–12 December 2021.
Eng. Proc. 2022, 14(1), 11; https://doi.org/10.3390/engproc2022014011
Published: 29 January 2022

Abstract

:
This paper presents the implementation of a Compensatory Adaptive Neuro-Fuzzy Inference System (CANFIS) controller to control an inverted pendulum. This controller is developed in order to readjust the parameters relating to the membership functions and the fuzzy rules used as well as to optimize the dynamics of the latter, using a learning algorithm based on the extended Kalman filter. The CANFIS controller is developed on the Simulink environment of the MATLAB software and is implemented on a Raspberry Pi 3 board, with a view to analyzing its real behavior, and testing its speed as well as its robustness through the use of the “Processor-In-the-Loop” (PIL) technique. The results obtained through PIL tests showed the effectiveness of the neuro-fuzzy controller equipped with a compensator.

1. Introduction

The control of non-linear systems is always a rather complex task in the field of automation, because several control techniques require a perfect knowledge of the behavior of the system in order to be able to achieve good performance. The description of a system equipped with its actuators and sensors and the various physical phenomena that appear during operation show the high complexity due to numerous non-linearities as well as the difficulty in perfectly modeling the dynamics of the mechanical sensors-actuators-system. Controlling the system for performing tasks requiring good performance becomes difficult, as knowledge of the system is incomplete and imperfect.
Adaptive control using artificial intelligence techniques has been the subject of several research works in the control of nonlinear systems [1,2,3,4]. The combination of fuzzy logic with neural networks has been recognized as a promising solution to compensate for the non-structural uncertainties of nonlinear systems. Therefore, combining fuzzy logic with neural networks in the form of a single network structure allows building more efficient neuro-fuzzy controllers, and this by taking advantage of the inference capacity of fuzzy reasoning and computational parallelism of neural networks. Among the most efficient adaptive neuro-fuzzy systems, we cite the CANFIS (Compensatory Adaptive Neuro-Fuzzy Inference System) structure, which consists of using a fuzzy compensator which compensates for the bad choice of membership functions, and which uses techniques which allow us to adjust the dynamics of fuzzy rules, so as to adapt to the environment [5]. However, the use of such an adaptive structure requires a high computation time and its implementation in practice then requires powerful control boards in order to minimize the computational time of the algorithm in order to converge on the desired performance.
Due to the computational complexity of these algorithms, several processes are generally necessary so that the controllers are suitable for implementations, because on the one hand, many development boards do not support the double-precision floating-point data type on the MATLAB-Simulink software, and on the other hand, designs based on this floating-point data type consume a significant number of hardware resources compared to designs based on the fixed-point data type [6]. However, in this design methodology, the adaptation of the controller is limited by the fixed point encoding. Several research works have been carried out in this area [7,8,9,10]. In this article, we will use MATLAB-Simulink software to implement the CANFIS controller on a Raspberry Pi 3 board to control an inverted pendulum. These control boards are known by their powerful processors, namely the ARM Cortex processors, and support both fixed and floating point data types. The MATLAB software therefore allows us to considerably reduce the design time of the algorithm, and to implement it on the Raspberry board. The use of the Processor-In-the-Loop (PIL) technique makes it possible to test the behavior of the CANFIS controller on the hardware, while the rest of the control loop is on the Simulink.
This document is organized as follows: in the second part, we present the structure of the fuzzy neuro network with a fuzzy compensator as well as the mathematical formalism, then, we study the learning algorithm. In the third part, we present the control scheme based on the Raspberry Pi 3 board, suitable for dynamic control of the inverted pendulum using the CANFIS controller. In the fourth part, we present the results of the PIL tests obtained by applying this synthesized strategy to the command in tracking of a reference trajectory of the inverted pendulum. Finally, we end our work with a general conclusion and some perspectives.

2. Description of the Adaptive Neuro-Fuzzy Network with a Compensator

CANFIS is a fuzzy inference system based on a multi-layered adaptive network, where the learning algorithm not only adjusts the membership functions, but also optimizes the dynamics of fuzzy reasoning by adjusting the degree of compensation. In this section, we develop an ANFIS controller equipped with a fuzzy compensator, where the adaptation of its parameters is ensured by a learning algorithm based on the extended Kalman filter. To simplify understanding and without loss of generality, we consider a system with two inputs x 1 , x 2 and one output u (Figure 1), modeled by a fuzzy system of the Takagi–Sugeno type, composed of the following four fuzzy rules:
Rule   1 :   if   x 1   is   A 1   and   x 2   is   B 1   then   u 1 = f 1 ( x 1 , x 2 ) = a 1 x 1 + b 1 x 2 + c 1
Rule   2 :   if   x 1   is   A 1   and   x 2   is   B 2   then   u 2 = f 2 ( x 1 , x 2 ) = a 2 x 1 + b 2 x 2 + c 2
Rule   3 :   if   x 1   is   A 2   and   x 2   is   B 1   then   u 3 = f 3 ( x 1 , x 2 ) = a 3 x 1 + b 3 x 2 + c 3
Rule   4 :   if   x 1   is   A 2   and   x 2   is   B 2   then   u 4 = f 4 ( x 1 , x 2 ) = a 4 x 1 + b 4 x 2 + c 4
The degree of activation of a rule is defined by w i .
We consider the pessimistic and optimistic operations, given respectively as follows:
z i = w i
m i = ( w i ) 1 2 .
The fuzzy compensator expressed by this relation:
C i ( z i , m i , γ i ) = ( z i ) 1 γ i ( m i ) γ i ,
where γ i [ 0 , 1 ] is the compensatory degree. Therefore, the net value of the fuzzy neural-network equipped with a fuzzy compensator is given as follows:
u = i = 1 4 ( a i e + b i Δ e + c i ) ( w i ) α i i = 1 4 ( w i ) α i
α i = 1 γ i 2
Consider that x 1 and x 2 are the position error e and its derivative Δ e . We associate two fuzzy sets for each of the inputs, namely   N   ( N e g a t i v e ) and P ( P o s i t i v e ) . μ N et μ P represent the appropriate membership degrees of the variables x i with respect to fuzzy subsets A i and B i , defined by the following member functions:
μ N ( x 1 ) = exp ( ( x 1 ρ 1 σ 1 ) 2 )
μ P ( x 1 ) = exp ( ( x 1 ρ 2 σ 2 ) 2 )
μ N ( x 2 ) = exp ( ( x 2 β 1 δ 1 ) 2 )
μ P ( x 2 ) = exp ( ( x 2 β 2 δ 2 ) 2 ) ,
with: ( ρ i , σ i ) and ( β i , δ i ) being the (mean, variance) of the fuzzy set of the membership functions respectively of x 1 and x 2 .

Learning Algorithm

The controller is characterized by a vector of parameters Φ . Our objective is to find the values of the vector Φ ^ by minimizing the following criterion [11]:
J ( k ) = 1 2 ( y d ( k ) y ( k ) ) 2 = 1 2 ( e ( k ) ) 2 ,
where: y ( k ) is the real output of the system and y d ( k ) is its desired output. The extended Kalman filter approach consists of linearizing the output regulator u d at each step k around the estimated vector Φ d ( k ) . This is equivalent to writing:
u d ( k ) = u ( k ) + Ψ ( k ) ( Φ d ( k ) Φ ( k ) ) .
With:
Ψ ( k ) = u ( k ) Φ ( k ) = [ u ( k ) Φ 1 ( k ) , , u ( k ) Φ n ( k ) ] ,
where n is the dimension of the vector Ψ T . Consequently, the parameters are adjusted according to the following relation [12]:
Φ ( k + 1 ) = Φ ( k ) + K ( k ) Ψ T ( k ) e u
K ( k ) = P ( k ) Ψ ( k ) P ( k ) Ψ T ( k ) + B ( k )
P ( k + 1 ) = P ( k ) K ( k ) Ψ ( k ) P ( k )
K ( k ) = K ( k ) Ψ T ( k ) ,
where Ψ ( k ) is the Jacobian matrix (the observation matrix of the system), P ( k ) is the estimation matrix of the error covariance and B ( k ) is the measurement covariance matrix. In order to approximate the variation e u , we linearize the inverse model of the system around y ( k ) according to the following relation:
u = u ( k ) y ( k ) ( y y ( k ) ) + u ( k ) ,
where y ( k ) is the system output and u ( k ) its input. For this linearized model, the value u d ( k ) can be expressed as follows:
u d ( k ) = u ( k ) y ( k ) ( y d ( k ) y ( k ) ) + u ( k ) .
Therefore, we have:
u d ( k ) u ( k ) = u ( k ) y ( k ) ( y d ( k ) y ( k ) ) .
Then:
e u ( k ) = u ( k ) y ( k ) e ( k ) .
We also have: e ( k ) = y d ( k ) y ( k ) . We assume that y d ( k ) is constant in the neighborhood of y ( k ) . Then:
e ( k ) = y ( k ) .
Therefore:
e u ( k ) = ( k ) e ( k ) e ( k ) .
The relation (17) can be written as follows:
Φ ( k + 1 ) = Φ ( k ) K ( k ) Ψ T ( k ) u ( k ) e ( k ) e ( k ) .
In order to eliminate the constraint γ i [ 0 1 ] defined in Equation (7), we define:
γ i = p i 2 p i 2 + q i 2 .
Consequently, the parameters vector to be readjusted is given by:
Φ i T ( k ) = [ a 1 , b 1 , c 1 , p 1 , q 1 , , a 4 , b 4 , c 4 , p 4 , q 4 ]
Ψ ( k ) = [ u ( k ) a 1 , u ( k ) b 1 , u ( k ) c 1 , u ( k ) p 1 , u ( k ) q 1 , , u ( k ) a 4 , u ( k ) b 4 , u ( k ) c 4 , u ( k ) p 4 , u ( k ) q 4 ]
With:
u a i = e [ w i ] α i i = 1 4 [ w i ] α i
u b i = Δ e [ w i ] α i i = 1 4 [ w i ] α i
u c i = [ w i ] α i i = 1 4 [ w i ] α i
u γ i = 1 2 [ i = 1 4 a i e + b i Δ e + c i ] z i ln ( w i ) i = 1 4 z i
u p i = [ 2 p i ( q i ) 2 ( p i ) 2 + ( q i ) 2 ] u γ i
u q i = [ 2 q i ( p i ) 2 ( p i ) 2 + ( q i ) 2 ] u γ i .
We have:
u = i = 1 4 ( a i e + b i Δ e + c i ) ( w i ) α i i = 1 4 ( w i ) α i = h g .
Then:
u e = h e . g g e . h g 2 .
With:
h e = i = 1 4 ( [ a 2 ( e ρ j ) ( a i e + b i Δ e + c i ) ] w i α i )
g e = 2 i = 1 4 ( ( e ρ j ) w i α i ) ,
where j is the integer part of ( i 1 ) / 2 .

3. Implementation of the CANFIS Controller Equipped with a Compensator on the Raspberry Pi 3 Board: Application on the Inverted Pendulum

In this section, we use the “Processor-In-the-Loop” technique in MATLAB-Simulink, which allows us to test the behavior of the CANFIS controller on the Raspberry Pi 3 board [13]. In this mode of execution, the CANFIS controller runs in the hardware while the rest of the closed loop runs on the Simulink environment. In order to test the performances of the controller, we considered the stabilization problem of an inverted pendulum on a cart. The dynamic equations of the nonlinear system are given by [14]:
x ˙ 1 = x 2
x ˙ 2 = g sin x 1 cos x 1 ( m l m c + m x 2 2 sin x 1 1 m c + m τ ( t ) ) 4 3 l m l m c + m cos 2 x 1 ,
where x 1 is the position of the vertical rod (in radian), x 2 is the angular velocity and τ ( t ) the torque applied to the rod. Its parameters are given in the Table 1.
The implementation of the CANFIS controller was done with a frequency of 10 KHz. The execution diagram of the regulation chain (CANIFIS controller, System and disturbance) in PIL mode under the MATLAB Simulink environment is presented in Figure 2.

4. Results of the PIL Tests

In this section, we present the simulation results of the PIL mode. In order to test the robustness of the two proposed controllers, we added a disturbance on the input of the system at the instant t = 20   s , given as follows:
D ( t ) = 150 sin ( t ) .
Figure 3a,b, Figure 4a,b and Figure 5a,b represent the results of the position tracking, the position tracking errors as well as the control signals delivered by the CANFIS controller. From these figures, we can see that the proposed controller has good performance (tracking, response time and robustness) with a low precision error, in both test cases (with and without disturbances). This is due to the use of a compensator which compensates for errors in the choice of membership functions, even readjusting the dynamics of fuzzy rules, using a learning algorithm based on the extended Kalman filter. The implementation of the proposed controller allowed us to obtain good performances thanks to the sampling frequency of the Raspberry Pi 3 board.

5. Conclusions

In this article, we have proposed the implementation on a Raspberry Pi 3 board of a neuro-fuzzy controller CANFIS, in order to control an inverted pendulum. The CANFIS controller presents good results because it uses a learning algorithm based on the extended Kalman filter, which converges very quickly, and which readjusts the membership functions and optimizes at the same time the dynamics of fuzzy reasoning by adjusting the degree of compensation. The development and implementation of the controller was done through MATLAB’s Simulink environment, which simplified the study and implementation of the code on the Raspberry Pi 3 board.
In conclusion, we have tried through this article to show the efficiency of the CANFIS controller on real hardware (Raspberry Pi 3) in the control of non-linear systems. The implementation of such a controller using the PIL technique has demonstrated its speed and robustness to disturbance rejection.

Author Contributions

Conceptualization, H.K. and H.T.; methodology, H.K., H.T. and R.M.; software, H.K. and H.T.; validation, H.K., H.T. and R.M.; formal analysis, H.K., H.T., M.A.T. and R.M.; investigation, M.A.T. and R.M.; resources, M.A.T.; data curation, H.K. and H.T.; writing—original draft preparation, H.K., H.T., R.M. and S.G.; writing—review and editing, H.K., H.T. and S.G.; visualization, H.K. and H.T.; supervision, H.K. and H.T.; project administration, H.K.; funding acquisition, H.K., H.T., M.A.T. and R.M. All authors have read and agreed to the published version of the manuscript.

Funding

This research received no external funding.

Institutional Review Board Statement

No Institutional Review Board.

Informed Consent Statement

Patient consent was waived.

Data Availability Statement

Study did not report any data.

Conflicts of Interest

The authors declare no conflict of interest.

References

  1. Gil, P.; Oliveira, T.; Palma, L. Adaptive neuro–fuzzy control for discrete-time nonaffine nonlinear system. IEEE Trans. Fuzzy Syst. 2019, 27, 1602–1615. [Google Scholar] [CrossRef]
  2. Sarhadi, P.; Rezaie, B.; Rahmani, Z. Adaptive predictive control based on adaptive neuro fuzzy inference system for a class of nonlinear industrial processes. J. Taiwan Inst. Chem. Eng. 2016, 61, 132–137. [Google Scholar] [CrossRef]
  3. Song, S.; Zhang, B.; Song, X.; Zhang, Z. Adaptive neuro fuzzy backstepping dynamic surface control for uncertain fractional-order nonlinear systems. Neurocomputing 2019, 360, 172–184. [Google Scholar] [CrossRef]
  4. Song, S.; Park, J.H.; Zhang, B.; Song, X.; Zhang, Z. Adaptive command filtered neuro-fuzzy control design for fractional-order nonlinear systems with unknown control directions and input quantization. IEEE Trans. Syst. Man Cybern. Syst. 2020, 51, 7238–7249. [Google Scholar] [CrossRef]
  5. Mellah, R.; Khati, H.; Talem, H.; Guermah, S. Compensatory of adaptive neural fuzzy inference system. In Fuzzy Systems; IntechOpen: London, UK, 2021. [Google Scholar]
  6. Finnerty, A.; Ratigner, H. Reduce Power and Cost by Converting from Floating Point to Fixed Point; Xilinx All Programmable, v. 1.0; Xilinx, Inc.: San Jose, CA, USA, 2017; pp. 1–14. [Google Scholar]
  7. Karakuzu, C.; Karakaya, F.; Çavuşlu, M.A. FPGA implementation of neuro-fuzzy system with improved PSO learning. Neural Netw. 2016, 79, 128–140. [Google Scholar] [CrossRef] [PubMed]
  8. Khati, H.; Mellah, R.; Talem, H. Neuro-fuzzy control of a position-position Teleoperation system using FPGA. In Proceedings of the 24th International Conference on Methods and Models in Automation and Robotics, Miedzyzdroje, Poland, 26–29 August 2019; pp. 64–69. [Google Scholar]
  9. Khati, H.; Talem, H.; Mellah, R.; Bilek, A. Neuro-fuzzy control of bilateral teleoperation system using FPGA. Iran. J. Fuzzy Syst. 2019, 16, 17–32. [Google Scholar]
  10. Dorzhigulov, A.; Bissengaliuly, B.; Spencer, B.F.; Kim, J. ANFIS based quadrotor drone altitude control implementation on Raspberry Pi platform. Civ. Environ. Eng. 2018, 95, 335–345. [Google Scholar] [CrossRef]
  11. Mellah, R.; Guermah, S.; Toumi, R. Adaptive control of bilateral teleoperation system with compensatory neural-fuzzy controllers. Int. J. Control Autom. Syst. 2017, 15, 1–11. [Google Scholar] [CrossRef]
  12. Hayki, S. Kalman Filtering and Neural Networks; John Wiley and Sons Inc.: Hoboken, NJ, USA, 2001. [Google Scholar]
  13. Simulink Support Package for Raspberry Pi Hardware. User’s Guide; MathWorks, MATLAB and SIMULINK, r2021a; The MathWorks Inc.: Natikc, MA, USA, 2021. [Google Scholar]
  14. Yoo, B.; Ham, W. Adaptive fuzzy sliding mode control of nonlinear system. IEEE Trans. Fuzzy Syst. 1998, 6, 315–321. [Google Scholar]
Figure 1. Structure of the Adaptive Neuro-Fuzzy Inference System Controller with compensator.
Figure 1. Structure of the Adaptive Neuro-Fuzzy Inference System Controller with compensator.
Engproc 14 00011 g001
Figure 2. Execution diagram in PIL mode under Simulink.
Figure 2. Execution diagram in PIL mode under Simulink.
Engproc 14 00011 g002
Figure 3. Position tracking: (a) Without disturbances; (b) With disturbances.
Figure 3. Position tracking: (a) Without disturbances; (b) With disturbances.
Engproc 14 00011 g003
Figure 4. Position error: (a) Without disturbances; (b) With disturbances.
Figure 4. Position error: (a) Without disturbances; (b) With disturbances.
Engproc 14 00011 g004
Figure 5. Control signal: (a) Without disturbances; (b) With disturbances.
Figure 5. Control signal: (a) Without disturbances; (b) With disturbances.
Engproc 14 00011 g005
Table 1. Inverted pendulum parameters.
Table 1. Inverted pendulum parameters.
g Gravity constant9.8 m/s2
m c Carriage mass1 kg
m Pendulum mass0.1 kg
l Rod length0.5 m
Publisher’s Note: MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Share and Cite

MDPI and ACS Style

Khati, H.; Talem, H.; Touat, M.A.; Mellah, R.; Guermah, S. Online Adaptation of a Compensatory Neuro-Fuzzy Controller Parameters Using the Extended Kalman Filter: Application on an Inverted Pendulum. Eng. Proc. 2022, 14, 11. https://doi.org/10.3390/engproc2022014011

AMA Style

Khati H, Talem H, Touat MA, Mellah R, Guermah S. Online Adaptation of a Compensatory Neuro-Fuzzy Controller Parameters Using the Extended Kalman Filter: Application on an Inverted Pendulum. Engineering Proceedings. 2022; 14(1):11. https://doi.org/10.3390/engproc2022014011

Chicago/Turabian Style

Khati, Hocine, Hand Talem, Mohand Achour Touat, Rabah Mellah, and Said Guermah. 2022. "Online Adaptation of a Compensatory Neuro-Fuzzy Controller Parameters Using the Extended Kalman Filter: Application on an Inverted Pendulum" Engineering Proceedings 14, no. 1: 11. https://doi.org/10.3390/engproc2022014011

Article Metrics

Back to TopTop