Computers, Materials & Continua DOI:10.32604/cmc.2022.028441 | |
Article |
Design and Implementation of a State-feedback Controller Using LQR Technique
1Mechanical Engineering Department, The University of Lahore, Lahore, Pakistan
2Mechanical Engineering Department, Umm Al-Qura University, Makkah, Saudi Arabia
3Electrical Engineering Department, The University of Lahore, Lahore, Pakistan
*Corresponding Author: Aamir Shahzad. Email: aamir.shahzad1@me.uol.edu.pk
Received: 10 February 2022; Accepted: 01 April 2022
Abstract: The main objective of this research is to design a state-feedback controller for the rotary inverted pendulum module utilizing the linear quadratic regulator (LQR) technique. The controller maintains the pendulum in the inverted (upright) position and is robust enough to reject external disturbance to maintain its stability. The research work involves three major contributions: mathematical modeling, simulation, and real-time implementation. To design a controller, mathematical modeling has been done by employing the Newton-Euler, Lagrange method. The resulting model was nonlinear so linearization was required, which has been done around a working point. For the estimation of the controller parameters, MATLAB LQR function has been utilized. Simulation has been performed for the designed controller and it also has been implemented and tested over the real inverted pendulum. From the results, it is vivid that the designed controller keeps the inverted pendulum in an upright position and rejects the disturbances and falling under gravitational force by adjusting the rotation of the horizontal link.
Keywords: Mathematical modeling; linearization; linear quadratic regulator (LQR); nonlinear system; rotary inverted pendulum
The rotary inverted pendulum is an important topic of research in control engineering. It is an effective tool to test the performance of different control approaches. It is a multi-variable nonlinear dynamical system that is highly unstable. It has two links, one link revolves around an axis in the horizontal plane so that the other can balance itself in an upright position [1–5]. The control of the rotary inverted pendulum helps in designing the altitude controller of rockets and satellites due to its nonlinear behavior. The inverted pendulum control is playing a vital role in real-life applications ranging from robotics to aerospace, locomotive to marine systems and from flexible to pointing control systems. Additionally, the study of dynamics and control of inverted pendulum helps in maintaining the equilibrium of tall buildings [6–12].
Various efforts have been reported in the literature about the design, mathematical modeling and stable control of inverted pendulum by utilizing different control approaches. Model-based control techniques have been used frequently but the fuzzy and non-model-based approaches have been utilized too. Newton’s laws or energy balance approaches have been used to formulate the dynamic model [13–15]. The fuzzy cascade control based on Hierarchical Fair Competition-based Genetic Algorithms has been used in [16]. It consists of two fuzzy controllers which have been placed in a cascade manner and their parameters have been optimized using the genetic algorithm. The inner loop controls the position of the rotating arm while the outer loop provides the appropriate input to the inner loop due to a change in the angle of the vertical arm. Simulation has been performed and the results have been validated on the real hardware. Counter based approach has been used to design a swing-up controller while pole placement with an integrator has been used to stabilize the vertical arm in [17]. The study shows a settling time of 4.5 s for the swing-up controller. Similarly, stabilization of the vertical arm has been shown through simulation. The actual implementation over the hardware has not been reported.
Swing up and vertical stabilization have been achieved in [18] through the energy-based method.
Mathematical modeling and simulation of complex and multivariable systems is an active field of research to find an optimal solution through the design and development of new algorithms. It is a cost-effective process that provides an insight into the robustness and suitability of an algorithm for a particular problem to be solved. It sheds light on the possible outcomes and helps in analysis through variation of system parameters [22–37]. Therefore, it was necessary to develop a complete model of the rotary inverted pendulum, its parameters estimation and testing over real hardware to validate the results found in the simulation. To the best of our knowledge, no such design of controller with linearization and analysis has been done so far. This paper describes the two-link inverted pendulum. In the proposed research work, the following are the key developments contributions:
• To design the controller, complete mathematical modeling has been done using the Newton-Euler, Lagrange approach
• The non-linear model has been linearized around a working point
• Feedback gains of linear quadratic regulator (LQR) controller have been evaluated using MATLAB (2018a, MathWorks, MA, USA)
• The designed controller performance has been tested in a simulation environment as well as it has been implemented over an inverted pendulum. It shows that the controller keeps the pendulum in the upright position and rejects the disturbances
The paper has been organized as follows. Section I is Introduction. In Section II, mathematical modeling has been developed and linearization has been done around the working point. Simulation results have been presented in Section III. Implementation over a real rotary inverted pendulum has been done in Section IV. Section V has the conclusion and future work.
A free-body diagram of the pendulum with reference frames is shown in Fig. 1. It is vivid from Fig. 1, that the horizontal link having a length
The potential energy (PE)
where
where
where
Substituting Eq. (9) in Eq. (2), we get:
The Lagrangian
The states of the system (i.e.,
where the working points
Taking the differential of Eq. (12) with respect to
Now taking
Taking the differential of Eq. (12) with respect to
where:
where
Now differentiating Eq. (12) with respect to
Now taking
where:
Now simplify Eq. (23) to get:
Finally, we get two equations (i.e. Eq. (25) and Eq. (26)) of the system as under:
From Eq. (26), the value of
Substituting the value of
Now simplifying the Eq. (28):
Substituting the value
To design the controller, mathematical modeling has been done by employing the Newton-Euler, Lagrange method. The resulting model is nonlinear so linearization is required, which has been done around a working point. Following are the assumptions from Eqs. (30) and (31).
The linear system can be expressed by:
For the nonlinear system, the linearized system looks as:
The working point is given by:
The linearized system is given by:
The motor torque equation is given by:
where
where:
where,
3 Controller Design and Parameters Estimation
MATLAB (2018a, MathWorks, MA, USA) has been used to evaluate the parameters of the LQR controller. Matrices given in (A) and (B) have been evaluated using the system setup parameters and initial conditions given in Tab. 2. Similarly, the matrix given in (C) has been evaluated using the same set of parameters and MATLAB LQR function.
Fig. 2 shows the linearized model of inverted pendulum with LQR controller simulated in MATLAB Simulink module. In order to analyze performance and the stability of the controller, a horizontal link having an angle theta (
4 Hardware Implementation and Validation
Hardware has been set up as shown in Fig. 4. It depicts the Rotary inverted pendulum module coupled to the Quanser SRV02 plant in the correct configuration. Quanser SRV02 has a direct current (DC) motor enclosed in an aluminum frame and is equipped with a planetary gearbox. The module is attached to the SRV02 load gear and the pendulum arm is attached to the module body. In order to keep the pendulum stable and upright, the LQR has been designed and implemented. LQR is an excellent approach that provides optimal feedback gains to make a closed-loop system robust and stable. It also provides a local approximation to develop optimal control for nonlinear systems [38].
The designed controller has been implemented over the real inverted pendulum. The plots of variation in angles both in simulation and the real environment with the passage of time have been shown in Figs. 5 and 6. The angle in degrees is along the vertical axis versus time in seconds is along the horizontal axis as shown in Figs. 5 and 6. Fig. 6 shows the variation in the horizontal link’s angle
In current research work, a state-feedback controller for the rotary inverted pendulum utilizing the LQR techniques has been designed. Mathematical modeling, linearization, simulation and validation of the designed controller over real hardware has been carried out. It is evident from the simulation and measured results that the designed controller is performing well and is robust enough to keep the pendulum in an upright stable position. For future work, a non-model-based controller or a nonlinear controller can be designed and evaluated and performance comparison can be made.
Acknowledgement: Authors would like to thank Christopher Hille for the thorough discussion.
Funding Statement: The authors received no specific funding for this study.
Conflicts of Interest: The authors declare that they have no conflicts of interest to report regarding the present study.
1. M. R. Dolatabad, A. Pasharavesh and A. A. A. Khayyat, “Analytical and experimental analyses of nonlinear vibrations in a rotary inverted pendulum,” Nonlinear Dynamics, vol. 107, no. 3, pp. 1887–1902, 2022. [Google Scholar]
2. O. Mofid, K. A. Alattas, S. Mobayen, M. T. Vu and Y. Bouteraa, “Adaptive finite-time command-filtered backstepping sliding mode control for stabilization of a disturbed rotary-inverted-pendulum with experimental validation,” Journal of Vibration and Control, vol. 26, no. 1, pp. 107754632110640, 2022. [Google Scholar]
3. N. P. Nguyen, H. Oh, Y. Kim and J. Moon, “A nonlinear hybrid controller for swinging-up and stabilizing the rotary inverted pendulum,” Nonlinear Dynamics, vol. 104, no. 2, pp. 1117–1137, 2021. [Google Scholar]
4. A. de Carvalho, J. F. Justo, B. A. Angélico, A. M. de Oliveira and J. I. da Silva Filho, “Rotary inverted pendulum identification for control by paraconsistent neural networ,” IEEE Access, vol. 9, pp. 74155–74167, 2021. [Google Scholar]
5. H. V. Nghi, D. P. Nhien, N. T. M. Nguyet, N. T. Duc, N. P. Luu et al., “A LQR-based neural-network controller for fast stabilizing rotary inverted pendulum,” in IEEE Int. Conf. on System Science and Engineering (ICSSE), Ho Chi Minh City, Vietnam, pp. 19–22, 2021. [Google Scholar]
6. Y. Dai, K. Lee and S. Lee, “A real-time HIL control system on rotary inverted pendulum hardware platform based on double deep Q-network,” Measurement and Control, vol. 54, no. 3–4, pp. 417–428, 2021. [Google Scholar]
7. H.-R. Li, Z.-Y. Nie, E.-Z. Zhu, W.-X. He and Y.-M. Zheng, “Double loop DR-PID control of a rotary inverted pendulum,” in IEEE Int. Conf. on Networking, Sensing and Control (ICNSC), Xiamen, China, pp. 1–5, 2021. [Google Scholar]
8. Z. S. Mahmood, I. B. Kadhim and A. N. Nasret, “Design of rotary inverted pendulum swinging-up and stabilizing,” Periodicals of Engineering and Natural Sciences, vol. 9, no. 4, pp. 913–920, 2021. [Google Scholar]
9. J. A. Onwuzuruike and S. U. Hussein, “Bond graph modelling of a rotary inverted pendulum on a wheeled cart,” International Journal of Modern Education & Computer Science, vol. 13, no. 6, pp. 25–29, 2021. [Google Scholar]
10. A. Lal, A. Kunjumuhammed, J. Tomy, G. Urmila, M. Sivadas et al., “Stabilization of rotary inverted pendulum using PID controller,” in IEEE 8th Int. Conf. on Smart Computing and Communications (ICSCC), Kochi, Kerala, India, pp. 376–380, 2021. [Google Scholar]
11. I. Chawla and A. Singla, “Real-time stabilization control of a rotary inverted pendulum using LQR-based sliding mode controller,” Arabian Journal for Science and Engineering, vol. 46, no. 3, pp. 2589–2596, 2021. [Google Scholar]
12. M. F. Hamza, H. J. Yap, I. A. Choudhury, A. I. Isa, A. Y. Zimit et al., “Current development on using rotary inverted pendulum as a benchmark for testing linear and nonlinear control algorithms,” Mechanical Systems and Signal Processing, vol. 116, pp. 347–369, 2019. [Google Scholar]
13. O. Saleem and K. M. Hasan, “Robust stabilisation of rotary inverted pendulum using intelligently optimised nonlinear self-adaptive dual fractional-order PD controllers,” International Journal of Systems Science, vol. 50, no. 7, pp. 1399–1414, 2019. [Google Scholar]
14. I. Chawla and A. Singla, “Real-time control of a rotary inverted pendulum using robust LQR-based ANFIS controller,” International Journal of Nonlinear Sciences and Numerical Simulation, vol. 19, no. 3–4, pp. 379–389, 2018. [Google Scholar]
15. C. Wang, X. Liu, H. Shi, R. Xin and X. Xu, “Design and implementation of fractional PID controller for rotary inverted pendulum,” in IEEE Chinese Control and Decision Conf. (CCDC), Shenyang, China, pp. 6730–6735, 2018. [Google Scholar]
16. S.-K. Oh, S.-H. Jung and W. Pedrycz, “Design of optimized fuzzy cascade controllers by means of hierarchical fair competition-based genetic algorithms,” Expert Systems with Applications, vol. 36, no. 9, pp. 11641–11651, 2009. [Google Scholar]
17. V. Nath and R. Mitra, “Swing-up and control of rotary inverted pendulum using pole placement with integrator,” in IEEE Recent Advances in Engineering and Computational Sciences (RAECS), Chandigarh, India, IEEE, 1–5, 2014. [Google Scholar]
18. A. Al-Jodah, H. Zargarzadeh and M. K. Abbas, “Experimental verification and comparison of different stabilizing controllers for a rotary inverted pendulum,” in IEEE Int. Conf. on Control System, Computing and Engineering, Penang, Malaysia, pp. 417–423, 2013. [Google Scholar]
19. J. George, B. Krishna, V. George, C. Shreesha and M. K. Menon, “Stability analysis and design of pi controller using kharitnov polynomial for rotary inverted pendulum,” Sensors & Transducers Journal, vol. 138, no. 3, pp. 104–113, 2012. [Google Scholar]
20. K. Chou and Y. Chen, “Energy based swing-up controller design using phase plane method for rotary inverted pendulum,” in 13th IEEE Int. Conf. on Control Automation Robotics & Vision (ICARCV), Singapore, pp. 975–979, 2014. [Google Scholar]
21. A. Tiga, C. Ghorbel and N. B. Braiek, “Nonlinear/linear switched control of inverted pendulum system: stability analysis and real-time implementation,” Mathematical Problems in Engineering, vol. 2019, no. 2, pp. 1–10, 2019. [Google Scholar]
22. X. R. Zhang, W. F. Zhang, W. Sun, X. M. Sun and S. K. Jha, “A robust 3-D medical watermarking based on wavelet transform for data protection,” Computer Systems Science & Engineering, vol. 41, no. 3, pp. 1043–1056, 2022. [Google Scholar]
23. X. R. Zhang, X. Sun, X. M. Sun, W. Sun and S. K. Jha, “Robust reversible audio watermarking scheme for telemedicine and privacy protection,” Computers, Materials & Continua, vol. 71, no. 2, pp. 3035–3050, 2022. [Google Scholar]
24. A. M. S. Mahdy, K. Lotfy, W. Hassan and A. A. El-Bary, “Analytical solution of magneto-photothermal theory during variable thermal conductivity of a semiconductor material due to pulse heat flux and volumetric heat source,” Waves in Random and Complex Media, vol. 31, no. 6, pp. 2040–2057, 2021. [Google Scholar]
25. A. K. Khamis, K. Lotfy, A. A. El-Bary, A. M. Mahdy and M. H. Ahmed, “Thermal-piezoelectric problem of a semiconductor medium during photo-thermal excitation,” Waves in Random and Complex Media, vol. 31, no. 6, pp. 2499–2513, 2021. [Google Scholar]
26. A. M. S. Mahdy, K. Lotfy, A. El-Bary and H. H. Sarhan, “Effect of rotation and magnetic field on a numerical-refined heat conduction in a semiconductor medium during photo-excitation processes,” The European Physical Journal Plus, vol. 136, no. 5, pp. 1–17, 2021. [Google Scholar]
27. A. M. S. Mahdy, K. Lotfy, A. El-Bary and I. M. Tayel, “Variable thermal conductivity and hyperbolic two-temperature theory during magneto-photothermal theory of semi-conductor induced by laser pulses,” The European Physical Journal Plus, vol. 136, no. 6, pp. (1–212021. [Google Scholar]
28. A. M. S. Mahdy and E. S. M. Youssef, “Numerical solution technique for solving isoperimetric variational problems,” International Journal of Modern Physics C, vol. 32, no. 1, pp. 2150002, 2021. [Google Scholar]
29. Y. A. Amer, A. M. S. Mahdy, T. T. Shwayaa and E. S. M. Youssef, “Laplace transform method for solving nonlinear biochemical reaction model and nonlinear Emden-Fowler system,” Journal of Engineering and Applied Sciences, vol. 13, no. 17, pp. 7388–7394, 2018. [Google Scholar]
30. Y. A. Amer, A. M. S. Mahdy and H. A. R. Namoos, “Reduced differential transform method for solving fractional-order biological systems,” Journal of Engineering and Applied Sciences, vol. 13, no. 20, pp. 8489–8493, 2018. [Google Scholar]
31. A. M. S. Mahdy, “Numerical solutions for solving model time-fractional Fokker–Planck equation,” Numerical Methods for Partial Differential Equations, vol. 37, no. 2, pp. 1120–1135, 2021. [Google Scholar]
32. M. M. Khader, N. H. Swetlam and A. M. S. Mahdy, “The chebyshev collection method for solving fractional order klein-gordon equation,” WSEAS Transactions on Mathematics, vol. 13, pp. 31–38, 2014. [Google Scholar]
33. M. I. A. Othman, A. M. S. Mahdy and R. M. Farouk, “Numerical solution of 12th order boundary value problems by using homotopy perturbation method,” Journal of Mathematics and Computer Science, vol. 1, no. 1, pp. 14–27, 2010. [Google Scholar]
34. A. M. S. Mahdy, Y. A. E. Amer, M. S. Mohamed and E. Sobhy, “General fractional financial models of awareness with Caputo-Fabrizio derivative,” Advances in Mechanical Engineering, vol. 12, no. 11, pp. 1–9, 2020. [Google Scholar]
35. A. M. S. Mahdy, K. A. Gepreel, K. Lotfy and A. A. El-Bary, “A numerical method for solving the Rubella ailment disease model,” International Journal of Modern Physics C, vol. 32, no. 7, pp. 1–15, 2021. [Google Scholar]
36. A. M. S. Mahdy, M. S. Mohamed, K. Lotfy, M. Alhazmi, A. A. El-Bary et al., “Numerical solution and dynamical behaviors for solving fractional nonlinear rubella ailment disease model,” Results in Physics, vol. 24, no. 104091, pp. 1–10, 2021. [Google Scholar]
37. A. M. S. Mahdy, M. Higazy and M. S. Mohamed, “Optimal and memristor-based control of a nonlinear fractional tumor-immune model,” Computers, Materials & Continua, vol. 67, no. 3, pp. 3463–3486, 2021. [Google Scholar]
38. L. Wei and W. Yao, “Design and implement of LQR controller for a self-balancing unicycle robot,” in IEEE Int. Conf. on Information and Automation, Lijiang, China, pp. 169–173, 2015. [Google Scholar]
This work is licensed under a Creative Commons Attribution 4.0 International License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited. |