A Fuzzy LQR PID Control for a Two-Legged Wheel Robot with Uncertainties and Variant Height

— This paper proposes a fuzzy LQR PID control for a two-legged wheeled balancing robot for keeping stability against uncertainties and variant heights. The proposed control includes the fuzzy supervisor, LQR, PID, and two calibrations. The fuzzy LQR is conducted to control the stability and motion of the robot while its posture changes with respect to time. The fuzzy supervisor is used to adjust the LQR control according to the robotic height. It consists of one input and one output. The input and output have three membership functions, respectively, to three postures of the robot. The PID control is used to control the posture of the robot. The first calibration is used to compensate for the bias value of the tilting angle when the robot changes its posture. The second calibration is applied to compute the robotic height according to the hip angle. In order to verify the effectiveness of the proposed control, a practical robot with the variant height is constructed, and the proposed control is embedded in the control board. Finally, two experiments are also conducted to verify the balancing and moving ability of the robot with the variant posture


I. INTRODUCTION
In recent years, autonomous robots have been invented rapidly to share manpower requirements in factories, restaurants [1], airports [2], and delivery [3] [4].Unlike conventional robots and human workers operating as separate workspaces, human-robot cooperation is used to complete complex tasks.As a result, the human-robot interaction must be considered in the robot design, which means that the robots and humans can share the workspace together [5].Two-wheel inverted pendulum (TWIP) robots [6], an extended system of inverted pendulums, and mobile robots, own advantages such as compactness, mobility, and humanlike functions.This kind of robot has more applications in logistics transportation, commuting, and navigation, selfbalancing capability.Because the TWIP mobile platform [7] is classified as an underactuated system that implements the 3-DOF motion of pitch, yaw, and straight movement with only two actuator inputs, high-performance motion control for this robot is a highly challenging task for the control community and recently numerous results have been reported as well-classified.
When the TWIP robots work at a small pitch angle around the balancing point, some conventional linear control techniques such as PID control [8][9][10][11] and linear quadratic regulator (LQR) [8][9] [12][13][14][15][16] have been employed.However, when the robot operates in nonlinear regions with large pitch angles because of external disturbances, modeling errors, or internal maneuvers, the control performance of the linear control approaches will be degraded.In order to alleviate these problems and enhance the control performance, many nonlinear control methods have been investigated, such as feedback linearization control [17] [18], sliding mode control [19][20][21], backstepping control [22][23][24], and model predictive control [25] [26].These approaches usually require a mathematical model for the design procedure.In practice, it is hard to determine exactly the mathematical model, parameters usually change with respect to time due to the aging and affections of the external environment.In order to handle these challenges, adaptive control [19] [27][28][29], neural network control [19] [30][31][32], and fuzzy control [33][34][35][36] have been investigated for the TWIP robots.In [19], a neural network was used to estimate the unknown model parameters and a robust adaptive control was applied to compensate for the estimator errors and uncertainties in a two-wheeled self-balancing robot system.In [27], an adaptive backstepping control was constructed for a wheeled inverted pendulum system under the presence of the model parameter uncertainties.In [30], an adaptive neural network was used to compensate for the unknown terms in the output dynamics of a self-balancing robot.In [33], a fuzzy logic control and a pole placement state-feedback controller were both designed for a two-wheeled self-balancing robot against the disturbance force.The pole placement statefeedback controller was used to keep the balance of the robot, and the fuzzy logic control was used to control the position of the robot.In [37], a fuzzy and PD control was applied for a two-wheeled self-balancing robot with structured and unstructured uncertainties.The PD control was used to control the balancing of the robot and the fuzzy PD control was utilized to control the position of the robot.
The conventional TWIP robots are well known moving fast and stably on a flat road.However, when they move in uneven terrain, such as gullies and slopes, their limitations appear.They cannot overcome an obstacle when the radius of the wheel is less than the height of the obstacle or the contact point is above the center of the wheel [38].In order to manage this challenge, some advanced self-balancing robots [38][39][40][41] are constructed to work corporately with people.The study in [38] designed a terrain-adaptive two-legged wheeled robot with leg mechanisms which can jump over obstacles.Klemm et al. [39]  two-legged wheeled jumping robot, that moved on uneven terrain and also climbed the stairs by jumping.Zhou et al. [40] proposed a centroidal adjustment control to let the robot have higher robustness in moving.Some conventional control approaches [39][42-48] have been investigated to manage the balance and height control problems in these types of robot.In [39], a linear quadratic regulator (LQR) and PID controller were applied for the Ascento robot to control the stabilization, driving and jumping.For the stabilization and driving, the LQR controller was designed from linearization state space models linearized around ten different leg heights.In [42], a cascade PID controller was proposed for a bipedal leg-wheeled robot to guarantee the stabilization and driving.In [49], LQR controller and fuzzy PD controller were investigated on a new type of wheel legged robot with parallel four-bar mechanism for stable movement and jumping over obstacles.
Based on the above analysis, this paper presents a fuzzy LQR PID control for a two-legged wheeled robot (TLWR) for keeping stability against uncertainties and variant heights.The proposed control is designed based on the fuzzy supervisor, LQR, and PID.As a result, this approach does not require the rigor mathematical model.The fuzzy LQR, including a LQR control and a fuzzy supervisor, is utilized to control the stability and motion of the robot with the variant posture.According to the robotic height, the fuzzy supervisor will estimate the gains of the LQR control.The supervisor consists of one input and one output which have three membership functions, respectively, to three postures of the robot.The PID control is used to control the posture of the robot.In order to verify the effectiveness of the proposed control, the practical robot was constructed and the proposed control was embedded in the control board.Additionally, two experiments were also conducted to verify the balancing and moving ability of the robot.Because the sensor displacement plane is tilted according to the posture of the robot, some computations are implemented to compensate this tilting angle.The main contributions of this paper are summarized as follows: 1.A proposed control is constructed based on the fuzzy supervisor and three LQR controllers which are respectively designed according to three postures of the TLWR, low, medium and high postures.As a result, the complexity in the TLWR is reduced in the control design.
2. The effectiveness of the proposed control is verified on a practical testbench and the challenges, measuring the robotic height and compensating angles for the pitch angle in the real testbench, are also discussed in this paper.
This paper is constructed as follows: In section 2, the problem formulation of the two-legged wheeled balancing robot with variant height, including equivalent centroid calculation, TLWR Modeling, and linear state space model, is discussed.The proposed controller consisting of PID control and Fuzzy LQR control are designed in Section 3. In Section 4, some experiments are conducted in practical robot and the results of the proposed control are compared to another control.Finally, some conclusions and future works are mentioned in Section 5.

II. DESCRIPTION AND MODELING OF THE TWO-LEGGED WHEELED ROBOT
The structure of the self-balancing two-legged wheeled robot is presented in Fig. 1.The robotic system is equipped with a control board, an inertial measurement unit (IMU), a Zigbee module, three DC motors including encoders, and one 12V rechargeable lead-acid battery.The control board is designed as a primary controller, with the IMU being used to calculate the rate and angle of platform inclination.Additionally, the control board can drive the robotic platform's yaw control.Two motors, including encoders are installed at the feet of the robot to drive the robotic motion.Another is added in the hip to adjust the height of the robot.In order to save energy of the hip motor, torsion springs are installed in inner joints at the knees of the robot.Deadreckoning computations are manipulated based on the information from two optical encoders mounted in the drive motors.Remark 1: In this paper, we limit the application of the upper body to sagittal motion.The yaw control of the robot is realized by the differential motion of the two wheels, and the pitch angle of the torso is controlled by the hip joint.The roll angle of the TLWR can be controlled by adjusting the height of the two legs, but in this paper, both legs perform the same motion, so the roll angle is always kept at zero.Additionally, the symbols of the TLWR utilized in this paper are summarized in Table I.The joint angle between the coordinate system 0 th and 1 th  2 The joint angle between the coordinate system 1 th and 2 th  3 The joint angle between the coordinate system 2 th and 3 th  4 The joint angle between the coordinate system 2 th and 4 th  5 The joint angle between the coordinate system 4 th and 5 th  6 The joint angle between the coordinate system 5 th and 6 th  Distance between the coordinate system 2 th and 3 th

A. Equivalent Centroid Calculation
The coordinate systems involved in this paper are exhibited with         of universal frame and         of wheel-axle frame.In the decoupling process, the five-link multi-rigid body system is equivalent to a lumped mass point as presented in Fig. 2. The position of the equivalent centroid is weighted by the masses of the individual links and their centroid positions.To establish the relationship between this center of mass and the axle coordinate system, the Denavit-Hartenberg (D-H) convention was used to establish the kinematic model.By setting up the coordinates as presented in Fig. 3, the D-H parameters of the TLWR are shown in Table II.The homogeneous transformation matrix from the ith coordinate to the i-1-th coordinate is given as (1).
The homogeneous transformation matrix between the coordinate system i and the axle coordinate system is as (2).
The position of the CoM of the upper body relative to the world coordinate system can be presented as (3).4) and (5).

B. TLWR Modelling Assumption 2:
The driving wheels are subject to rolling constraints and there is no slippage between the wheel and the ground.
In this study, the pendulum length in ( 4) is used to analyze the dynamics of the inverted pendulum.The state variables of the wheel inverted pendulum are selected as   = [  ]  .By using Euler Lagrange approach, the dynamic equations of the TLWR can be expressed as (6).

C. Linear State Space Model
In this study, three postures of the TLWR presented in Fig. 4 are considered in the control design.Its linear state space models are given as (7).

A. PID Control
In order to control the posture of the TLWR, a PID control is used to drive the hip motor based on the difference of the posture profile and the real posture of the TLWR.Based on the geometric structure of the TLWR in Fig. 3, the pendulum length can be calculated following the hip angle.The calibration 1 is utilized to compute the robotic height according to hip angle.The PID control law is presented as (8).

B. Linear Quaratic Regulator(LQR)
In the LQR controller, the optimal control gains, K, are computed based on the cost function (), which optimize states, () and control signal, () of the systems (9).The control signal, (), and the cost function, , are selected as in ( 9) and (10).
where  is solution of the differential equation of Riccati as (12).
Remark 2: The LQR controller performance is dependent on the selection of weight matrices and linearization matrices, A and B. As a result, different postures will give different optimal control gains,  1 ,  2 and  3 in the low, medium and high postures, respectively.Remark 3: When the height of the TLWR changes respect to the posture, the sensor plane will be titled at an angle correspondingly.The calibration 2 is used to compensate this titling angle of the sensor.The equation in the calibration 2 is calculated by applying the algebraic solution technique.The transformation matrix between the 6 th coordination system and the origin coordination can be calculated from equation (13).By implementing some manipulations, transformation matrix,  6 0 , will only depend on the hip angle.Because the height of two legs is adjusted simultaneously, the orientation matrix of the transformation matrix,  6 0 , is a rotation operation around the z-axis.As a result, this matrix can be presented as (14).The compensation angle for the sensor is calculated as (15).
The output of the calibration is presented as (16).
=  _ +   (16) C. Fuzzy Supervisor According to the robotic height estimated from the hip angles, the fuzzy supervisor will compute the control gains in the LQR, respectively.Fig. 6 presents the structure of the fuzzy supervisor, which includes an input and 8 outputs, control gains of the LQR.Three membership functions in the input are presented as Low, Medium and High in Fig. 7. Fuzzy rules of the fuzzy supervisor are given as follows: Where ℎ is the height of the robot;  (=1,2,3) are control gains of the low, medium and high postures, respectively.
The MAX -PROD aggregation method and "centroid" defuzzification method are utilized.The control gains can be computed in (17).

A. Test Bench Description
The practical TLWR robot shown in Fig. 8 includes a board Control, two-wheel motors with encoders, a hip motor, a hip encoder, and an IMU sensor.The control board developed form ATmega2560 is used to control the stability, posture and motion of the robot.Two-wheel motors are two DC motors, JGB37-520 with the speed of 333 revolution per minute (RPM), which are attached to incremental encoder with 11 pulses per revolution (PPR).Based on the control signals which are generated from the control board, they will keep the robot stable or drive the motion of the robot.In order to adjust the posture of the robot, a high torque 5840-31ZT motor and an encoder AMT332D-V are mounted in the hip.The IMU sensor, MPU9250, is utilized to compute the titling of the robot.The power of the whole system is supplied by a 12 V lithium battery.After practical measurements, the weight of the robot is 3.15 kg, and the battery life is about 2.5 h.The hardware connection diagram of the test bench is shown in Fig. 9.A graphic user interface, built by Visual studio C# on a laptop, acquires the robotic position, pitch, hip and yaw angles and control signals, and send the control gains to the robot through wireless communication in real-time through radio frequency (RF) transceiver, Zigbee C2530.The control board is constructed to conduct the proposed control from the information acquiring from IMU sensor and encoders.After the control signals are computed by the control board, they will be provided to the drivers of the hip motor and leg motor.Remark 4: The parameters of the TLWR, such as lengths, masses, moments inertia, and radius of wheels, in Table III are specified and calculated by using the mass properties in the SOLIDWORK.

B. Experimental Description
In order to verify the effectiveness of the proposed control, it is compared with a Fuzzy LQR control which is designed with two membership functions in the fuzzy supervisor named as fuzzy LQR control with two membership functions (FLQR with TMF).This control is designed based on the LQR controllers in the high and low postures.The control parameters of the PID and LQR control in the postures are shown in Table IV.Remark 6: Because the balancing of the robot cannot be remained during the posture of the robot change, when only the LQR in low, medium, high postures are applied independently.The fuzzy LQR control with two membership functions in fuzzy supervisor is used for comparison.
To evaluate the balancing and moving performances of the proposed controller with robot, two experiments are carried out with different scenarios to evaluate the superiority of the proposed control.In the first experiment, the robot keeps balancing in place while its height changes from high to low and from low to high during 60 seconds.In the second scenario, the robot keeps balancing, moving forward and backward, and changing its posture simultaneously during 60 seconds.The posture of the robot changes respect to time, which is illustrated in Fig. 10.

C. Experiment Results
In the first scenario, the experiment is conducted to verify of the proposed control in keeping the balancing of the robot with variant postures.The robot will stay in the high posture in the initially.Its posture will change to the low posture from 15 th second to 25 th second.Then this status will be kept in 15 seconds after it changes to the high posture again from 40 th to 50 th second.Finally, the robot will stay in this posture in the last time.During the posture of the robot changes, the robot is kept balancing in place.Fig. 11 shows the output responses of the robot, which are the robot position, pitch angle, rotation angle and the height of the robot with the black lines of the reference, blue lines of the FLQR with TMF and the red lines of the proposed control.The results show that two controllers keep the robot balancing well when the posture changes with respect to time.Additionally, the proposed control with fuzzy supervisor which is designed from the controllers of the LQR controllers in three postures gives better performance than the controller with the fuzzy supervisor designed from two LQR controllers in the high and low postures Fig. 12 presents error performances of the robot, which are the robot position, pitch angle, rotation angle and the height of the robot with the blue lines of the FLQR with TMF and the red lines of the proposed control.Fig. 13 presents the control signals of the controllers in the left, right and hip motor with the blue lines of the FLQR with TMF and the red lines of the proposed control.The chattering effect in the motors is significant.In the second scenario, the experiment is implemented to evaluate the effectiveness of the proposed control in keeping the balancing of the robot with variant postures when the robot moves forward and backward.The robot will stay in the high posture in the initial time, then it will begin decreasing its height to the low posture from the 10 th to the 20 th second.It will stay the low posture in 15 seconds and increase the height to high posture from the 35 th to the 45 th second.Finally, it will keep this status in the last time.Besides the posture change with respect to time, the robot also moves forward to the setpoint of 1.6 meter from the origin position from the the 10 th to the 20 th second.Then, it stays in this place in 15 seconds before moving backward to the origin position from the 35 th to the 45 th second.
Finally, it will stay at the origin position in the last time.Fig. 14 shows the output responses of the robot, which are the robot position, pitch angle, rotation angle and the height of the robot with the black lines of the reference, blue lines of the FLQR with TMF and the red lines of the proposed control.The results show that two controllers keep the robot balancing well when the robot moves forward and backward with variant postures.Additionally, the proposed control with fuzzy supervisor gives better performance than the FLQR with TMF.Fig. 15 presents error performances of the robot, which are the robot position, pitch angle, rotation angle and the height of the robot with the blue lines of the FLQR with TMF and the red lines of the proposed control Fig. 16 presents the control signals of the controllers in the left, right and hip motor with the blue lines of the FLQR with TMF and the red lines of the proposed control.The chattering effect in the motors is also significant in this case study.

V. CONCLUSION AND FUTURE WORK
This paper presented a fuzzy LQR PID control for a twolegged wheeled balancing robot for keeping its stability against the uncertainties and variant heights.The proposed control includes the fuzzy supervisor, LQR, and PID.The fuzzy LQR is conducted to control the stability and motion of the robot with the variant postures.The fuzzy supervisor is used to adjust the LQR control according to the robotic height.It consists of one input and one output.The input and output have three membership functions respectively to three postures of the robot.The PID control is used to control the posture of the robot.In order to verify the effectiveness of the proposed control, the practical robot was constructed and the proposed control were embedded in the control board.Two experiments were also conducted to verify the balancing and moving ability of the robot.In practice, when the posture of robot changes, the sensor mounting plane is tilting an angle with respect to the height of the robot.So, a calibration was carried out to compensate with the pitch angle which is computed from the IMU sensor.
Future works in this study will focus on; 1) Suppressing chattering effect; 2) improving the robotic test bench to control the length of two legs separately; 3) applying type-2 fuzzy system to manage the uncertainties in the system; 4) Investigating some advance navigation methods by using Lidar and CCD images.
described the fundamental design of Ascento, a Journal of Robotics and Control (JRC) ISSN: 2715-5072 613 Duc Thien Tran, A Fuzzy LQR PID Control for a Two-Legged Wheel Robot with Uncertainties and Variant Height

Fig. 1 .
Fig. 1.The CAD model of the robot

Fig. 2 . 5 qFig. 3 .
Fig. 2. Schematics of differential types of dynamic model of the robot (a) the two-legged wheeled robot, (b) The decoupled equivalent WIP model ) =    (  )    where   is the mass of the ith link,   = [  1 , . . .,  4 ]  is the actual angles,    = [  ,   ]  is the position coordinate of the equivalent CoM relative to the axle coordinate system,    is the position coordinate of the CoM of the ith link in the wheel axis coordinate system, and    is the position of the CoM of the ith link in the local coordinate system.Based on the coordinate of CoM, the pendulum length  and inclination angle of the inverted pendulum can be obtained as in equation (

Fig. 4 .Fig. 5 .
Fig. 4. Three postures of the TLWR III.CONTROL DESIGNAs presented in Fig.5, the structure of the proposed control includes the Fuzzy LQR control and Posture control.The posture control is designed from the PID control to adjust the hip angle of the robot.The height of the robot is calculated by the calibration 1 which presents the relationship between the hip angle and the height of the robot.The Fuzzy LQR control combines a fuzzy supervisor and a LQR control.The fuzzy supervisor includes one input and six outputs which are the control gains of the LQR control.The input fuzzy has three membership functions respect to the low, medium and high postures of the robot.With different postures, the center of mass of the robots are different so the dynamics of the robot is also changed.Because the control gains of LQR are dependent on the robotic dynamics, they are also different at each posture.The Fuzzy supervisor is designed to calculate the control gain of the LQR with respect to the height of the robot.When the posture of the robot changes, the inclination angle of IMU sensor also alters.As a result, inclination angles, calculated from IMU sensors, should be adjusted by the calibration 2. Based on the kinematic of the robot, the auxiliary angles are calculated with respect to the height of the robot.The input transformation matrix is used to convert the control inputs computed from the proposed control into the input voltage at each wheel motor.Posture control , A Fuzzy LQR PID Control for a Two-Legged Wheel Robot with Uncertainties and Variant Height

Fig. 8 .
Fig. 8. Two-legged wheeled robot can change height in practice

Remark 5 :
In this study, the proposed control is carried out on the practical two-legged wheeled robot.The steps taken in this study are summarized as follows: Step 1 selects devices from the requirements; Step 2 designs a two-legged wheeled robot; Step 3 constructs a real model; Step 4 evaluates the performances of the actuators, sensors and mechanical structure; Step 5 conducts the LQR controllers ISSN: 2715-5072 617 Duc Thien Tran, A Fuzzy LQR PID Control for a Two-Legged Wheel Robot with Uncertainties and Variant Height with different postures on the practical mode; Finally, step 6 implements the proposed control on the robot.

Fig. 11 .Fig. 12 .
Fig. 11.Output response of the two-legged wheeled robot with two controllers in (a) robot position; (b) pitch angle; (c) rotation angle; (d) height of robot Journal of Robotics and Control (JRC) ISSN: 2715-5072 618 Duc Thien Tran, A Fuzzy LQR PID Control for a Two-Legged Wheel Robot with Uncertainties and Variant Height

Fig. 13 .
Fig. 13.Control signals response of the two-legged wheeled robot with two controllers in (a) left motor; (b) right motor; (c) hip motor

Fig. 14 .
Fig. 14.Output response of the two-legged wheeled robot with two controllers in (a) robot position; (b) pitch angle; (c) rotation angle; (d) height of robot

TABLE I .
THE PARAMETERS OF THE TLWR 2 Position of CoM of the lower thigh  3 Position of CoM of the upper thigh  4 Position of CoM of the body Journal of Robotics and Control (JRC) ISSN: 2715-5072 614 Duc Thien Tran, A Fuzzy LQR PID Control for a Two-Legged Wheel Robot with Uncertainties and Variant Height

TABLE II .
DH-PARAMETERS OF THE TLWR

TABLE III .
PARAMETERS OF THE TWO-LEGGED WHEELED ROBOT

TABLE IV .
CONTROL PARAMETERS