You are on page 1of 6

CONFIDENTIAL. Limited circulation. For review only.

Robust control of a two-wheeled robot*


Petko Petkov1 , Tsonyo Slavov2 and Jordan Kralev3

Abstract— This paper describes the design and the results of ensure robust stability and robust performance of the closed-
the Hardware-in-the-Loop (HIL) simulation of a robust control loop system. A comparison of the closed-loop frequency
system of a two-wheeled robot implementing µ-controller. The responses and robustness properties corresponding to the
design utilizes a single-input multi-output uncertainty model
obtained by an appropriate identification procedure. This model LQG and µ-controllers is done in section IV. Finally, in
is used to design a µ-controller that ensures robust stability and section V we give some results from the hardware-in-the-
robust performance of the closed-loop system. The controller loop (HIL) simulation of the closed-loop system with the
is embedded in a Raspberry Pi 4B microcontroller and results embedded controller.
from the closed-loop system HIL simulation are presented.
I. INTRODUCTION II. THE ROBOT MODEL
The control of two-wheeled robots is a serious challenge
The robot motion in the vertical plane is described by
for the robust control theory, see for instance [8], [9], [14],
the tilt angle φ while the motion in the horizontal plane
[15], [18]. One of the most serious problems in the design of
is characterized by the wheels’ average angle θ = (θL +
a two-wheeled robot control system is to derive an adequate
θR )/2 where θL and θR are the left and right wheel angles,
model of the robot dynamics in presence of uncertainties in
respectively. The motion around the vertical axis is controlled
the dynamics of sensors, motors, and actuators. For this aim
separately and is not considered here since it is the same as
it is appropriate to use closed-loop identification procedures
the one described in [10].
which allow to obtain a simple linear model for small
The robot is equipped with two servo drives for actuation,
deviations from the upright robot position. An important part
micro-electromechanical (MEMS) inertial sensor for mea-
of the identification procedure is the uncertainty modeling
suring the angular velocity φ̇ of robot body in the vertical
which is done on the basis of the identification results
plane, quadrature encoders for measuring the position of the
[3], [15], [18]. As a result of this modeling one obtains a
wheels, and a digital microcontroller implementing the dis-
quantitative description of robot uncertainty in the form of
crete real-time stabilization algorithm with sampling period
Linear Fractional Transformation which is subsequently used
T0 = 0.005 s. The robot balancing is achieved by rotating
in the robust analysis and design of the control system.
the wheels in the appropriate direction. The computation of
In our previous studies [10], [15], we implemented a robot
control actions to both DC brushed drive motors is realized
dynamics model obtained by a single-input single-output
in single precision based on signals from the gyro sensor
closed-loop identification. However, as shown in [18], better
measuring the angular rate (and, after integration, the tilt
results in the design can be obtained by using a single-input
angle φ) and signals from rotary encoders measuring the
multi-output identification procedure [11], [12]. That is why
wheels rotation angles. The control of the DC motors is
in this paper we use the model derived in [18] to design a µ
executed by Pulse Width Modulated (PWM) signals.
controller ensuring robust stability and robust performance
of the closed-loop system. In this paper, the robot vertical movement and wheels
A detailed plant description of the robot used is already dynamics are described with an estimated multi-output state-
presented in [10], [15]. That is why in section II we provide space model with one input (the control signal u) and two
only short information about the robot which is necessary outputs (wheels angular rate θ̇ and body tilt angle φ). The
for the further presentation. A single-input two-output robot satisfaction of the condition for unbiased parameter estimates
model of 5th order is derived and validated which is used to obtained by the identification procedure guarantees that the
obtain an uncertainty model with two output multiplicative exact parameter values are contained in the confidence in-
uncertainties. As an alternative to the Linear Quadratic tervals of parameter estimates with probability close to 1.
Gaussian (LQG) design, done in [18], in section III we This allows to derive a parametric uncertainty model with
present the design of an 15th order µ-controller aimed to scalar uncertainties. The number of these uncertainties is
equal to the number of estimated parameters which makes
*This work was supported by Research and Development Sector of the the implementation of such a model unpractical. That is
Technical University of Sofia
1 Petko Petkov is with the Bulgarian Academy of Sciences, 1040 Sofia, why it is preferred to derive uncertainty models of the
Bulgaria e-mail: php@tu-sofia.bg transfer functions Gθ̇u and Gφu containing unstructured
2 Tsonyo Slavov is with the Department of Systems and (complex) uncertainties [17] at the price of introducing some
Control, Technical University of Sofia, 1157 Sofia, Bulgaria conservatism in the model. Based on parameter confidence
ts-slavov@tu-sofia.bg
3 Jordan Kralev is with the Department of Systems and Control, Technical intervals, maximum relative deviations from nominal models
University of Sofia, 1157 Sofia, Bulgaria jkralev@tu-sofia.bg in the frequency domain are obtained. To derive models

Manuscript 50 submitted to 8th International Conference on Control, Decision


and Information Technologies (CODIT). Received January 4, 2022.
CONFIDENTIAL. Limited circulation. For review only.

with multiplicative uncertainties, these deviations are approx-


imated, through optimization procedure, with shaping filters
which are represented by transfer functions of 3rd order.
The nominal 5th order discrete-time model equations are
x(k + 1) = Ax(k) + Bu(k) + Ke e(k), (1)
y(k) = Cx(k) + Du(k) + e(k),
where x(k) = [x1 , x2 , . . . , xn ]T is the state vector, u(k)
is the control signal, y(k) = [θ̇ φ]T is the output vector,
e(k) = [eθ̇ eφ ]T is the residue error vector. The matrices
A, B, C, D, Ke , obtained from the identification procedure,
have the values (up to four decimal digits)
A= (2)

0 1 0

 −7.0976 · 10−1 1.6834 · 100 −7.9018 · 10−1

 0 0 0 ... →
 0 0 0
−2.9747 · 10−4 2.8183 · 10−4 5.6080 · 10−1 Fig. 1. Uncertain plant model


0 0 Bode plot of Gd /dt,u
9.9694 · 10−2 7.6250 · 10−1 
 20
From: u1 To: [+plant(1)+deltatheta]

← ... 1 0 ,

Magnitude (dB)
0 1  0
−2.1149 · 100 2.5546 · 100
-20
 
−3.8502 · 10−3
-40

 1.6537 · 10−1 
 450

B= −1.2123 · 10−5 , (3) 360


Phase (deg)

  270
 5.8352 · 10−5 
180
2.2311 · 10−4 90
0
  -90
8.3952 · 10 −1
−5.1882 · 10 −1
10-2 10-1 100 101 102
 7.4844 · 10−1 Frequency (rad/s)
 5.9226 · 10−1 

 1.6353 · 10−4
Ke =  −4
1.8714 · 100 ,
 Fig. 2. Bode plot of Gθ̇u
 5.4093 · 10 2.7881 · 100 
1.0845 · 10−3 3.3755 · 100
  are shaping filters used to represent the output model uncer-
1 0 0 0 0
C= , tainty and ∆θ̇ , ∆φ are the output uncertainties satisfying
0 0 1 0 0
  |∆φ̇ | < 1, |∆θ̇ | < 1.
0
D= .
0
The robot model with output multiplicative uncertainties
The resulting one-input two-outputs uncertain model with is shown in Figure 1. The uncertain plant that results is of
output multiplicative uncertainties has the form 11th order.
Gθ̇u (z) = (1 + Wθ̇ (z)∆θ̇ )Gθ̇u,nom (z), (4) The Bode plots of the uncertain models Gθ̇u and Gφu are
shown in Figures 2 and 3, respectively.
Gφu (z) = (1 + Wφ (z)∆φ )Gφu,nom (z) (5)
III. µ-CONTROLLER DESIGN
where Gθ̇u,nom (z), Gφu,nom (z) are nominal transfer func-
tions obtained from the state-space model (3), The purpose of the µ-controller is to ensure robust stability
and robust performance of the closed-loop system in the
0.2768z 3 − 0.6515z 2 + 0.4862z − 0.1112 presence of unstructured or structured dynamics [20], [17],
Wθ̇ (z) = ,
z 3 − 1.66z 2 + 0.5027z + 0.1601 [6].
0.8343z 3 − 1.826z 2 + 1.257z − 0.262 The closed-loop system block diagram corresponding to
Wφ (z) = the µ-synthesis problem is shown in Figure 4, where rθ
z 3 − 1.118z 2 + 0.2128z − 0.0879

Manuscript 50 submitted to 8th International Conference on Control, Decision


and Information Technologies (CODIT). Received January 4, 2022.
CONFIDENTIAL. Limited circulation. For review only.
Bode plot of G
Z
Kθ θ + KR err
,u
From: u1 To: [+plant(2)+deltaphi] = (rθ − θ) + Kθ̇ θ̇ + Kφ φ. (6)
0

-20
Magnitude (dB) Using the notation
-40

GR (z)Gθ̇u (z)
 
-60

-80 Ts  −GR (z)2 G (z) 


-100 GR (z) = , Gu (z) =  θ̇u ,
z−1  Gθ̇u (z) 
270
Gφu
180
Phase (deg)

90  
0
0
-90
 GR (z) 
Grθ (z) =  ,
-180  0 
-270
10-2 10-1 100 101 102 0
Frequency (rad/s)
where Ts = 0.005 s is the sampling period, the closed-loop
Fig. 3. Bode plot of Gφu system is described by the equations
yc = Grθ rθ + Gu u, (7)
u = Kyc . (8)

The weighted closed-loop system errors ep and eu satisfy


the equation
   
ep Wp So Grθ
= rθ (9)
eu Wu Si KGrθ
where Si = (1 − KGu )−1 is the input sensitivity transfer
function and So = (I − Gu K)−1 is the output sensitivity
transfer function matrix.
The performance criterion used in controller design re-
quires that the transfer function matrix from the exogenous
Fig. 4. Block diagram of the closed-loop system input signal rθ to the output signals ep and eu to be small in
the sense of k · k∞ , for all possible uncertain
R plant models.
This leads to small weighted signals θ, (rθ − θ), θ̇ and φ
and small control action u in the desired frequency range.
is the wheels reference angle and ep , eu are the weighted The transfer function matrices Wp and Wu reflect the relative
closed-loop system outputs. The aim of the controller K, importance of the different frequency ranges for which the
determined by µ-synthesis, is to ensure robust stability and performance requirements should be fulfilled [20].
robust performance of the closed-loop system in the presence The µ-synthesis is applied for several choices of per-
of the plant uncertainties ∆θ̇ and ∆φ . To obtain better formance weighting functions that ensure a good balance
position accuracy a feedback from the integrated tracking between system performance and robustness. On the basis of
error err = rθ − θ is introduced to the controller. The simulation and experimental results the performance weight-
control action to the plant is realized by a microcontroller ing function is chosen as low pass filter as (in the continuous-
in real-time with sampling frequency fs = 200 Hz. For this time case)
reason the µ-synthesis is implemented to design a discrete-
3s+1
0.5 50s+1 0 0 0
 
time controller at the same sampling frequency.
4s+1
Let  0 4.7 125s+1 0 0 
Wp (s) =  ,
0.7 0.3s+1
T
0 0 0
 Z  
30s+1
yc = θ, (rθ − θ), θ̇, φ, 0 0 0 4s+1
0.75 50s+1
R
is the output feedback vector where (rθ − θ) denotes The control weighting function is chosen as a high pass
discrete-time integration of the difference rθ − θ using filter with appropriate bandwidth to impose constraints on
the forward Euler method. The controller transfer function the spectrum of control actions [6]. In the given case the
matrix K is represented as control weighting function is chosen as a first-order filter as
h i 1 s+1
K = Kθ KR err Kθ̇ Kφ . Wu (s) = 0.4 .
30 0.1s + 1
Then the control action is determined by the expression The weighting functions are discretized for the sampling
period of 0.005 s and included in the open-loop system
u = Kyc model.

Manuscript 50 submitted to 8th International Conference on Control, Decision


and Information Technologies (CODIT). Received January 4, 2022.
CONFIDENTIAL. Limited circulation. For review only.
-controller magnitude plots Magnitude plot of the tracking error e (z)/r (z)
100 20
K
80 K err
K d /dt 0
60 K

Singular Values (dB)


40 -20
Magnitude (dB)

20
-40
0

-20 -60

-40
-80
-60 LQG controller
-controller
-80 -100
10-4 10-2 100 102 10-3 10-2 10-1 100 101
Frequency (rad/s) Frequency (rad/s)

Fig. 5. µ-controller magnitude plot Fig. 7. Magnitude plot of the sensitivity function So Grθ

Bode plot of the closed-loop system (z)/r (z) Magnitude plot of the input sensitivity function
From: ref To: [+Intg1] 0
0 LQG controller
-controller
Magnitude (dB)

-10
-50

Singular Values (dB)


-20
-100

-30
-150
360
-40
Phase (deg)

-50
-360
LQG controller
-controller
-60
-720
10-1 100 101 102
10-1 100 101 102
Frequency (rad/s)
Frequency (rad/s)

Fig. 6. Bode plot of the uncertain closed-loop system Fig. 8. Magnitude plot of the sensitivity function Si KGrθ

The µ-synthesis is performed by using the Robust Control and the µ-controller designed in this paper. In the case of
Toolbox R
3 function musyn [1]. After the eighth iteration, µ-controller we use a 15th order approximation obtained by
the maximum value of µ is decreased to 0.503 and the the function reduce.
final controller obtained is of 36th order. The controller The Bode plot of the closed-loop system is shown in
order is reduced to 15th by using the command reduce of Figure 6. It is seen that for both controllers the closed-loop
Robust Control Toolbox R
3 without deterioration of closed- bandwidth is approximately 1 rad/s the µ controller having
loop performance. the larger bandwidth.
The magnitude plots of Kθ , KR err , Kθ̇ and Kφ are The magnitude plots of the tracking errors are shown
shown in Figure 5. in Figure 7. It is seen that the µ controller ensures better
It should be noted that the robust control law presented attenuation of the tracking error in the frequency range under
is designed in MATLAB R
using double precision (64 bits) interest.
floating-point arithmetic. In our case, this control law is From the magnitude plots of the input sensitivity function,
embedded in a processor which use single-precision (32 bits) given in Figure 8, one may conclude that the LQG controller
arithmetic. This circumstance may affect the behavior of the attenuates better the effect of disturbances and noises in the
discrete-time closed-loop system. For this reason, the closed- control action. This is the price to be paid for the wider
loop system stability in single-precision should be checked bandwidth and better tracking in the case of µ controller.
after the design. In Figure 9 we show the plots of upper bounds on
The properties of the designed controller are discussed in the structured singular value corresponding to the robust
the next section. stability of the closed-loop system for both controllers.
The bounds are obtained using the function robuststab
IV. COMPARISON OF THE CLOSED-LOOP from Robust Control Toolbox R
3 . For each controller, the
SYSTEMS WITH LQG AND µ CONTROLLERS system achieves robust stability in respect to the uncertainties
In this section, we compare the frequency domain prop- corresponding to the identification of the robot model. The
erties of the Linear Quadratic controller designed in [18] closed-loop system with µ controller has a better stability

Manuscript 50 submitted to 8th International Conference on Control, Decision


and Information Technologies (CODIT). Received January 4, 2022.
CONFIDENTIAL. Limited circulation. For review only.
Robust stability Tracking wheel angle reference
0.7 1500

0.6 1000

0.5
500

0.4

[deg]
0

0.3
-500
0.2

-1000 reference
0.1 LQG controller
LQG controller -controller
-controller
-1500
0 0 50 100 150 200 250 300 350 400
10-2 10-1 100 101 102 103 Time [s]
Frequency (rad/s)

Fig. 11. Tracking wheel angle reference


Fig. 9. Robust stability of the closed-loop system

Robot inclination
0.4
Robust performance
0.8
0.3
0.7
0.2
0.6
0.1
0.5

[deg]
0
0.4
-0.1
0.3
-0.2
0.2
-0.3 LQG controller
0.1 -controller
LQG controller
-controller -0.4
0 50 100 150 200 250 300 350 400
0
Time [s]
10-2 10 -1
10 0
10 1
10 2
10 3

Frequency (rad/s)
Fig. 12. Tilt body angle
Fig. 10. Robust performance of the closed-loop system

and 6.2·10−5 s for the µ-control action. Both times are much
margin in comparison to the system with LQG controller as smaller than the sampling period T0 = 0.005 s.
one may expect. In Figure 11 we show the change of the wheel angle for
The robust performance for LQG and µ controllers is the two controllers. It is seen that in both cases the tracking
shown in Figure 10. The robust performance analysis is done error is relatively small. The greater oscillations in the case
for the same weighting functions used in the µ-synthesis of µ-controller are explained by the larger controller gain in
by using the function robustperf. Not surprisingly, a this case corresponding to better robust performance.
better performance margin is obtained in the case of the µ- The variations of the tilt body angle during the same
controller which yields the best performance. It is interesting, experiments are small for both controllers as seen in Figure
that in the given case the LQG regulator with Kalman filter 12.
achieves robust performance in presence of uncertainties Finally, the control action for the two controllers is shown
corresponding to the identified robot model. This is in con- in Figure 13. As a control action one considers the duty
trast with the case of single-input single-output identification coefficient of the PWM signal that is used to control the DC
reported in [10]. motors. The maximum value of the control action for the
two controllers does not exceed 5, which is much smaller
V. HIL SIMULATION RESULTS than the maximum allowable value equal to 128.
The HIL simulation scheme of the control system which
implements the robot control code is the same as the one R EFERENCES
used in [18]. With the aid of Simulink Coder R
[13], a con- [1] G. Balas, R. Chiang, A. Packard, M. Safonov. Ro-

R
trol code is generated from the Simulink model which is bust Control Toolbox R
3 User’s Guide. Natick,
MA: The MathWorks, Inc., 2020. Retrieved from
embedded in the Raspberry Pi 4B microcontroller [16]. The http://www.mathworks.com/help/pdf_doc/robust/
comunication between real-time robot Simulink R
model and robust_ug.pdf
microcontroller is done via TCP/IP protokol. The simulation [2] F. Feriyonika, A. Hidayat. Balancing control of two-wheeled robot by
using Linear Quadratic Gaussian (LQG). Journal of Telecommunica-
is done for 400 s (80000 samples). The maximum value of tion, Electronic and Computer Engineering, 12(2020), 55–59. ISSN:
the computational time is 5.2·10−5 s for LQG control action 2180 – 1843

Manuscript 50 submitted to 8th International Conference on Control, Decision


and Information Technologies (CODIT). Received January 4, 2022.
CONFIDENTIAL. Limited circulation. For review only.
Robot control
5
[17] S. Skogestad, I. Postlethwaite. Multivariable Feedback Control, 2nd
4 ed. John Wiley and Sons Ltd, Chichester, UK, 2005. ISBN: 978-0-
470-01167-6
3
[18] T. Slavov, P. Petkov, S. Sherif, J. Kralev. Multi-output identification
2 and LQG control of a two-wheeled robot. 2021 International Confer-
ence Automatics and Informatics (ICAI), 30 Sept. - 2 Oct. 2021, Varna,
Control action

1
Bulgaria. IEEE, 2021. DOI: 10.1109/ICAI52893.2021.9639736
0 [19] C. Sun, T. Lu, K. Yuan. Balance control of two-wheeled self-
balancing robot based on Linear Quadratic Regulator and Neural
-1
Network. Fourth International Conference on Intelligent Control and
-2 Information Processing (ICICIP), Beijing, China, 9-11 June 2013,
-3
862–867. IEEE, 2013. DOI: 10.1109/ICICIP.2013.6568193
[20] K. Zhou, J.C. Doyle, K. Glover. Robust and Optimal Control. Prentice
LQG controller
-4
-controller
Hall, Upper Saddle River, NJ, 1996. ISBN: 0-13-456567-3
-5
0 50 100 150 200 250 300 350 400
Time [s]

Fig. 13. Control action

[3] J.L. Figueroa, S.I. Biagiola. Modelling and uncertainties characteriza-


tion for robust control. Journal of Process Control, 23(2013), 415–428.
DOI: 10.1016/j.jprocont.2012.11.008
[4] G.F. Franklin, J.D. Powell, M.L. Workman. Digital Control of
Dynamic Systems, 3rd ed. Addison Wesley Longman, Inc., Menlo
Park, CA, 1998. ISBN 0-201-33153-5
[5] M.S. Grewal, A.P. Andrews. Kalman Filtering: Theory and Practice
with MATLAB R
, 4th ed. John Wiley & Sons, Inc., New York, 2015.
ISBN 978-1-118-85121-0
[6] D.-W. Gu, P.Hr. Petkov, M.M. Konstantinov. Robust Control Design
with MATLAB R
, 2nd ed. Springer-Verlag, London, 2013. ISBN:
978-1-4471-4681-0
[7] S. Khatoon, M. Istiyaque, N. Hasan, D.K. Chaturvedi. Two-wheeled
self-balancing mobile robot using Kalman filter and LQG regulator.
In: M. Muzammil, A. Chandra, P.K. Kankar, H. Kumar (eds) Recent
Advances in Mechanical Engineering. Lecture Notes in Mechanical
Engineering. Springer, Singapore, 2021. DOI: 10.1007/978-981-15-
8704-7_26
[8] V.N. Kien, N.H. Quang, N.K. Trung. Application of model re-
duction for robust control of self-balancing two-wheeled bicycle.
TELKOMNIKA, 19(2021), 252–264. DOI: 10.12928/TELKOM-
NIKA.v19i1.16298
[9] D. Komor, R.-C. Roman, R.-E. Precup, R.-C. David, I. Pamfilii.
Models of two-wheeled mobile robots with experimental validation.
2020 IEEE 14th International Symposium on Applied Computational
Intelligence and Informatics (SACI), 21-23 May 2020, Timisoara,
Romania. IEEE, 2020. DOI: 10.1109/SACI49304.2020.9118823
[10] J. Kralev, Ts. Slavov, P. Petkov. Design and experimental
evaluation of robust controllers for a two-wheeled robot. In-
ternational Journal of Control, 89 (2016), 2201-2226. DOI:
10.1080/00207179.2016.1151940
[11] L. Ljung. System Identification: Theory for the User, 2nd ed.. Prentice-
Hall, Inc., Englewood Cliffs, NJ, 1999. ISBN: 978-0136566953
[12] L. Ljung. System Identification Toolbox R
User’s Guide.
The MathWorks Inc., Natick, MA, 2020. Retrieved from
https://www.mathworks.com/help/pdf_doc/
ident/ident_ug.pdf
[13] The MathWorks, Inc. (2021). Simulink Coder. Natick, MA. Retrieved
from: https://www.mathworks.com/help/pdf_doc/rtw/
rtw_ug.pdf
[14] B. Nail, Kouzou A., Hafaifa A. Digital stabilizing and control for
two-wheeled robot. In: Derbel N., Ghommam J., Zhu Q. (eds) New
Developments and Advances in Robot Control. Studies in Systems,
Decision and Control, vol 175. Springer, Singapore, 2019. DOI:
10.1007/978-981-13-2212-9_11
[15] P.H. Petkov, T.N. Slavov, J.K Kralev. Design of Embedded Robust
Control Systems using MATLAB R
/Simulink R
. IET Control, Robotics
and Sensor Series 113. The Institution of Engineering and Technology,
London, 2018. ISBN 978-1-78561-330-2
[16] Raspberry Pi 4 Model B. Raspberry Pi (Trading)
Limited, Cambridge, UK, 2021. Retrieved from:
https://www.raspberrypi.org/products/
verb”raspberry-pi-4-model-b/”

Manuscript 50 submitted to 8th International Conference on Control, Decision


and Information Technologies (CODIT). Received January 4, 2022.

You might also like