Real-Time Adaptive Linear Quadratic Regulator Control for the QUBE–2 Rotary Inverted Pendulum
Abstract
1. Introduction
1.1. Related Work
1.1.1. Classical and Adaptive LQR Control
1.1.2. Online Weight Tuning and Fuzzy LQR Approaches
1.1.3. Sliding Mode and Hybrid Optimal Control
1.1.4. Research Gap
1.2. Contributions
- A real-time adaptive LQR framework is proposed in which the state weighting matrix of the LQR cost function is continuously modified online based on real-time tracking error, state dynamics, integral error accumulation, and reference variation.
- A sliding-mode-inspired modulation mechanism is introduced to enhance robustness, where a nonlinear sliding variable influences the adaptation of the LQR weighting matrix rather than directly injecting discontinuous control action.
- A continuous-time Riccati differential equation is implemented and solved online, enabling real-time computation of adaptive LQR gains without relying on built-in LQR solvers, making the approach suitable for real-time embedded implementation.
- The proposed controller is experimentally validated on two Quanser QUBE-Servo 2 rotary inverted pendulum platforms and systematically compared with a conventional fixed-gain LQR controller.
- Experimental results demonstrate significant improvements in tracking performance, disturbance rejection, robustness, and reduction in control effort, confirming the effectiveness of the proposed adaptive weighting strategy.
1.3. Paper Organization
2. Mathematical Formulation
2.1. System Model
2.2. Conventional Continuous-Time LQR
2.3. Adaptive LQR Cost Formulation
2.4. Error-Based Adaptive Weighting Law
2.5. Sliding-Mode-Inspired Modulation
2.6. Continuous-Time Riccati Differential Equation
2.7. Control Law and Saturation
3. Stability and Boundedness Discussion
3.1. Boundedness of Adaptive Parameters
3.2. Properties of the Sliding-Mode-Inspired Modulation
3.3. Practical Stability of the Closed-Loop System
3.4. Role of Actuator Saturation
3.5. Experimental Validation of Stability
3.6. Enhanced Stability Arguments
3.7. Lyapunov Analysis for the Resulting Linear Time-Varying System
3.7.1. Boundedness and Positive Definiteness
3.7.2. Lyapunov Function Candidate
3.7.3. Uniform Exponential Stability
3.7.4. Effect of Saturation and Reference Tracking
- Uniform exponential stability of the origin in the unsaturated case;
- Practical exponential stability under actuator saturation;
- Bounded-state behavior under bounded disturbances.
3.8. Discussion on Disturbance Rejection Capability
4. Experimental Results
4.1. Reference Tracking Performance
4.2. Quantitative Tracking Metrics
4.3. Control Effort and Energy Consumption
4.4. Tracking Performance vs. Control Effort Trade-Off
5. Discussion
6. Conclusions
Author Contributions
Funding
Data Availability Statement
Acknowledgments
Conflicts of Interest
References
- Bryson, A.E.; Ho, Y.C. Applied Optimal Control: Optimization, Estimation and Control; Routledge: Oxfordshire, UK, 2018. [Google Scholar]
- Lewis, F.L.; Vrabie, D.; Syrmos, V.L. Optimal Control; John Wiley & Sons: Hoboken, NJ, USA, 2012. [Google Scholar]
- Lavretsky, E.; Wise, K.A. Robust adaptive control. In Robust and Adaptive Control: With Aerospace Applications; Springer: Berlin/Heidelberg, Germany, 2012; pp. 317–353. [Google Scholar]
- Quanser Inc. Optimal LQR Balance Control of Pendulum; Quanser Inc.: Markham, ON, USA, 2020. [Google Scholar]
- Stamouli, C.; Toso, L.F.; Tsiamis, A.; Pappas, G.J.; Anderson, J. Policy gradient bounds in multitask LQR. IEEE Control. Syst. Lett. 2025, 9, 2495–2500. [Google Scholar] [CrossRef]
- Zhao, F.; Chiuso, A.; Dörfler, F. Policy Gradient Adaptive Control for the LQR: Indirect and Direct Approaches. arXiv 2025, arXiv:2505.03706. [Google Scholar] [CrossRef]
- Fisher, P.A.; Annaswamy, A.M. Adapt and Stabilize, Then Learn and Optimize: A New Approach to Adaptive LQR. arXiv 2025, arXiv:2512.04565. [Google Scholar] [CrossRef]
- Yıldıran, U. Adaptive Control of an Inverted Pendulum by a Reinforcement Learningbased LQR Method. Sak. Univ. J. Sci. 2023, 27, 1311–1321. [Google Scholar] [CrossRef]
- Jha, S.K.; Bhasin, S. Adaptive linear quadratic regulator for continuous-time systems with uncertain dynamics. IEEE/CAA J. Autom. Sin. 2019, 7, 833–841. [Google Scholar] [CrossRef]
- Hernandez, R.; Garcia-Hernandez, R.; Jurado, F. Modeling, simulation, and control of a rotary inverted pendulum: A reinforcement learning-based control approach. Modelling 2024, 5, 1824–1852. [Google Scholar] [CrossRef]
- Saleem, O.; Iqbal, J.; Alharbi, S. Self-Regulating Fuzzy-LQR Control of an Inverted Pendulum System via Adaptive Hyperbolic Error Modulation. Machines 2025, 13, 939. [Google Scholar] [CrossRef]
- Gao, G.; Xu, L.; Huang, T.; Zhao, X.; Huang, L. Reduced-Order Observer-Based LQR Controller Design for Rotary Inverted Pendulum. Comput. Model. Eng. Sci. (CMES) 2024, 140, 305. [Google Scholar] [CrossRef]
- Nguyen, T.V.A.; Dao, Q.T.; Bui, N.T. Optimized fuzzy logic and sliding mode control for stability and disturbance rejection in rotary inverted pendulum. Sci. Rep. 2024, 14, 31116. [Google Scholar] [CrossRef] [PubMed]
- Le, H.D.; Nestorović, T. Integral Linear Quadratic Regulator Sliding Mode Control for Inverted Pendulum Actuated by Stepper Motor. Machines 2025, 13, 405. [Google Scholar] [CrossRef]
- Ge, Y.; Purevdorj, C.; Kasai, S.; Wagatsuma, H. An Adaptive Control Method for a Knee-Joint Prosthetic Leg Toward Dynamic Stability and Gait Optimization. In Proceedings of the International Conference on Artificial Life & Robotics (ICAROB2025), Oita, Japan, 13–16 February 2025; ALife Robotics: Oita, Japan; Volume 30, pp. 867–872.
- Villacres, J.; Viscaino, M.; Herrera, M.; Camacho, O. Controllers comparison to stabilize a two-wheeled inverted pendulum: PID, LQR and sliding mode control. Int. J. Control. Syst. Robot. 2016, 1, 29–36. [Google Scholar]
- Zhao, F.; Dörfler, F.; Chiuso, A.; You, K. Data-enabled policy optimization for direct adaptive learning of the LQR. IEEE Trans. Autom. Control. 2025, 70, 7217–7232. [Google Scholar] [CrossRef]
- Carnevale, G.; Mimmo, N.; Notarstefano, G. Data-driven LQR with finite-time experiments via extremum-seeking policy iteration. arXiv 2024, arXiv:2412.02758. [Google Scholar]
- Sontag, E.D. Some remarks on gradient dominance and LQR policy optimization. arXiv 2025, arXiv:2507.10452. [Google Scholar] [CrossRef]
- Yan, X.; Zhang, W.; Jiao, Y.; Wu, T.; Li, G.; Ma, H.; Ma, H.; Cui, Y.; Lin, Z.; Lin, Z. A Learnable LQR Controller for Uncertain Systems: Hybrid-Driven Recurrent Learning. IEEE Trans. Autom. Sci. Eng. 2025, 23, 1546–1560. [Google Scholar] [CrossRef]
- Bekkar, B.; Ferkous, K. Design of online fuzzy tuning LQR controller applied to rotary single inverted pendulum: Experimental validation. Arab. J. Sci. Eng. 2023, 48, 6957–6972. [Google Scholar] [CrossRef]
- Zhai, Q.; Xia, X.; Feng, S.; Huang, M. Optimization design of LQR controller based on improved whale optimization algorithm. In Proceedings of the 2020 3rd International Conference on Information and Computer Technologies (ICICT), San Jose, CA, USA, 9–12 March 2020; pp. 380–384. [Google Scholar]
- Chacko, S.J.; Neeraj, P.; Abraham, R.J. Optimizing LQR controllers: A comparative study. Results Control. Optim. 2024, 14, 100387. [Google Scholar] [CrossRef]
- Furuta, K. Sliding mode control of a discrete system. Syst. Control. Lett. 1990, 14, 145–152. [Google Scholar] [CrossRef]
- Vaidyanathan, S.; Lien, C.H. Applications of Sliding Mode Control in Science and Engineering; Springer: Berlin/Heidelberg, Germany, 2017; Volume 709. [Google Scholar]
- Quanser, Inc. Pendulum State Space Modeling; Quanser Inc.: Markham, ON, USA, 2020. [Google Scholar]
- Bartos, M.; Köhler, J.; Dörfler, F.; Zeilinger, M.N. Stability of Certainty-Equivalent Adaptive LQR for Linear Systems with Unknown Time-Varying Parameters. arXiv 2025, arXiv:2511.08236. [Google Scholar]
- Khalil, H.K. Nonlinear Systems; Prentice Hall: Upper Saddle River, NJ, USA, 2002; Volume 3. [Google Scholar]
- Quanser Inc. QUBE-Servo 2 User Manual; Quanser Inc.: Markham, ON, USA, 2020. [Google Scholar]














| Symbol | Description | Value | Unit |
|---|---|---|---|
| r | Length of rotary arm | 0.085 | m |
| Moment of inertia of rotary arm about pivot | |||
| Total length of pendulum | 0.129 | m | |
| l | Center of mass (COM) location of pendulum | m | |
| Moment of inertia of pendulum about its pivot | |||
| Mass of pendulum | 0.024 | kg | |
| Mass of rotary arm | 0.095 | kg | |
| g | Gravitational acceleration | 9.81 | |
| Damping coefficient of rotary arm | 1 × 10−3 | N.m.s/rad | |
| Damping coefficient of pendulum | 5 × 10−5 | N.m.s/rad | |
| Torque constant | 0.042 | N.m/A | |
| Motor back-emf constant | 0.042 | V/(rad/s) | |
| Terminal resistance | 8.4 |
| System Parameters | Controller Gains | System Limits | Waveform Specifications | ||||
|---|---|---|---|---|---|---|---|
| Parameter | Value | Parameter | Value | Parameter | Value | Parameter | Value |
| State-Space Matrix A | 35 | 0.8 | Waveform Type | Sawtooth, Sine, Square | |||
| State-Space Matrix B | 12 | 0.5 | Amplitude | −45 to 45 degrees | |||
| Initial LQR Gain K | 8 | 0.5 | Frequency | 0.02 Hz | |||
| LQR Weighting Matrix Q | diag([5, 1, 1, 5]) | 10 | 1 | Duration | 400 s | ||
| LQR Weighting Matrix R | 1 | 0.8 | Sample Time | 0.002 s | |||
| Additional System Parameters | Control Limits | Other Parameters | |||||
| 0.99 | 5 | 0.01 | 0.5 | ||||
| 0.5 | 100 | 0.05 | 0.05 | ||||
| 0.5 | −5 | ||||||
| 5 | |||||||
| Case | MSE | RMSE | MAE | sMAPE | ||||
|---|---|---|---|---|---|---|---|---|
| Fixed | Adaptive | Fixed | Adaptive | Fixed | Adaptive | Fixed | Adaptive | |
| Square-wave—QUBE1 | 507.4 | 130.57 | 22.526 | 11.427 | 16.111 | 4.8877 | 31.852 | 11.527 |
| Square-wave—QUBE2 | 228.38 | 121.18 | 15.112 | 11.008 | 9.3059 | 3.4143 | 21.914 | 8.4142 |
| Sine-wave—QUBE1 | 105.84 | 10.726 | 10.288 | 3.2751 | 9.2137 | 2.9901 | 40.423 | 20.236 |
| Sine-wave—QUBE2 | 63.067 | 4.8123 | 7.9415 | 2.1937 | 7.0892 | 1.879 | 40.982 | 14.362 |
| Sawtooth-wave—QUBE1 | 238.26 | 62.638 | 15.436 | 7.9144 | 10.219 | 2.678 | 54.337 | 15.221 |
| Sawtooth-wave—QUBE2 | 239.93 | 62.444 | 15.49 | 7.9021 | 12.49 | 2.3508 | 77.604 | 20.08 |
| Case | MSE (%) | RMSE (%) | MAE (%) | sMAPE (%) |
|---|---|---|---|---|
| Square-wave—QUBE1 | 74.27 | 49.27 | 69.66 | 63.81 |
| Square-wave—QUBE2 | 46.94 | 27.16 | 63.31 | 61.60 |
| Sine-wave—QUBE1 | 89.87 | 68.17 | 67.55 | 49.94 |
| Sine-wave—QUBE2 | 92.37 | 72.38 | 73.50 | 64.96 |
| Sawtooth-wave—QUBE1 | 73.71 | 48.73 | 73.79 | 71.99 |
| Sawtooth-wave—QUBE2 | 73.97 | 48.98 | 81.18 | 74.13 |
| Case | Fixed RMS (u) | Adaptive RMS (u) |
|---|---|---|
| Square-wave—QUBE1 | 11.261 | 0.6664 |
| Square-wave—QUBE2 | 11.875 | 0.6167 |
| Sine-wave—QUBE1 | 11.249 | 0.5805 |
| Sine-wave—QUBE2 | 11.273 | 0.6016 |
| Sawtooth-wave—QUBE1 | 11.305 | 0.5959 |
| Sawtooth-wave– QUBE2 | 11.344 | 0.6559 |
| Case | RMS Reduction (%) |
|---|---|
| Square-wave—QUBE1 | 94.08 |
| Square-wave—QUBE2 | 94.81 |
| Sine-wave—QUBE1 | 94.84 |
| Sine-wave—QUBE2 | 94.66 |
| Sawtooth-wave—QUBE1 | 94.73 |
| Sawtooth-wave—QUBE2 | 94.22 |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2026 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license.
Share and Cite
Lopez-Jordan, C.; Jafari, M. Real-Time Adaptive Linear Quadratic Regulator Control for the QUBE–2 Rotary Inverted Pendulum. Math. Comput. Appl. 2026, 31, 33. https://doi.org/10.3390/mca31020033
Lopez-Jordan C, Jafari M. Real-Time Adaptive Linear Quadratic Regulator Control for the QUBE–2 Rotary Inverted Pendulum. Mathematical and Computational Applications. 2026; 31(2):33. https://doi.org/10.3390/mca31020033
Chicago/Turabian StyleLopez-Jordan, Cynthia, and Mohammad Jafari. 2026. "Real-Time Adaptive Linear Quadratic Regulator Control for the QUBE–2 Rotary Inverted Pendulum" Mathematical and Computational Applications 31, no. 2: 33. https://doi.org/10.3390/mca31020033
APA StyleLopez-Jordan, C., & Jafari, M. (2026). Real-Time Adaptive Linear Quadratic Regulator Control for the QUBE–2 Rotary Inverted Pendulum. Mathematical and Computational Applications, 31(2), 33. https://doi.org/10.3390/mca31020033

