A neural network combined with sliding mode controller for the two-wheel self-balancing robot

Received Dec 21, 2020 Revised May 4, 2021 Accepted May 20, 2021 This article presents the sliding control method combined with the selfadjusting neural network to compensate for noise to improve the control system's quality for the two-wheel self-balancing robot. Firstly, the dynamic equations of the two-wheel self-balancing robot built by Euler–Lagrange is the basis for offering control laws with a neural network of noise compensation. After disturbance-compensating, the sliding mode controller is applied to control quickly the two-wheel self-balancing robot reached the desired position. The stability of the proposed system is proved based on the Lyapunov theory. Finally, the simulation results will confirm the effectiveness and correctness of the control method suggested by the authors.


INTRODUCTION
There has been much research on the two-wheel self-balancing (TWSB) robot in recent years because its application is expanding and developing [1]. Control models and algorithms are also optimized and become an open source for researchers. Especially, manufacturer Segway has also designed and produced a variety of TWSB vehicles for commerce.
There are many effective control methods available for the TWSB robot with nonlinear kinetics, such as the method using a proportional integral derivative (PID) controller [2], the optimal controller based on the linear-quadratic regulator (LQR) [3], [4], the robust-adaptive control [5], the backstepping control [6], [7], the sliding mode control [8], the fuzzy logic control structure [9] and the control system based on a neural network [10]. However, there is a lot of noise during outdoor operation that negatively affects the control system's quality. Therefore, to improve the control system's quality, in this research, the authors will propose a sliding control method combined with artificial neural (NN) networks to eliminate the noise.
In research studies [11]- [13], the authors have suggested two control methods for TWSB robots, such as PID and LQR. The authors made simulations and compared these methods, then conclude that LQR gives better results than PID. However, these studies did not mention disturbance components due to friction or uncertain interference from the environment. The simulation results also show that the control system's overshoot is relatively high, and the control quality at the start-period has not achieved the desired results. Meanwhile, the study [14] compared four control methods: the pole-control, the PID control, the backstepping control, and the sliding mode control. The simulation results show that the backstepping Int J Artif Intell ISSN: 2252-8938 A neural network combined with sliding mode controller for the two-wheel… (Duc-Minh Nguyen) 593 method and the pole-control have better results. However, in controlling the angle of rotation, the extended noise still cannot be eliminated. With the proposal using fuzzy-logic [15], [16], the authors used fuzzy-laws to control the balance and position of the TWSB robot. The system has a fast response and limited interference. However, with variability and uncertainty disturbance, the ability to reject interference is still low. To overcome those disadvantage problems mentioned above, in this study, the authors will develop from experiences in building control systems and noise compensation in previous articles [17]- [19] for the construction of the controller of TWSB robot with a nonlinear dynamic structure and uncertainty disturbance. This study's main contributions include designing a sliding mode controller combined with adaptive neural networks with online self-aligning parameters to eliminate the noise and uncertain components in the TWSB robot with nonlinear kinetics, and determination of the uncertainty parameters. The remaining content of this article includes as shown in: Section 2 presents the equations of control object for TWSB robot; in section 3, the authors build the neural network to compensate for the disturbance and prove the stability of the system; the results and discussion are presented in section 4, and the conclusions are presented in section 5.

BUILDING THE EQUATIONS OF CONTROL OBJECT FOR TWSB ROBOT 2.1. The model of the TWSB robot
The model of the TWSB robot is shown in Figure 1. The TWSB robot is a three-degrees-freedom robot with three joint variables: moving x, turning angle θ, and tilting variable .
where K is the total kinetic energy and U is the total potential energy.

Lagrange equations
The TWSB robot is an object with nonlinear kinetics. Therefore, we ignore external forces and the friction between the body and two-wheels to simplify the kinetic modeling process. These friction components and external forces will be added to the general equations and will be discussed in the next section. The total kinetic energy in the system is calculated as shown in: where K1 is the translational kinetic energy of the wheel: K2 is the rotational kinetic energy of the wheel: K3 is the kinetic energy of the pedestal: K4 is the kinetic energy of the pendulum: where: , are displacement of left wheel, right wheel along x-axis, respectively. mw is the mass of the wheel. θ L , θ R are the rotation angle of the left wheel and the right wheel relative to the z-axis. Jwy is the inertia moment of the wheel along y-axis. m1, m2 are the mass of the pendulum, the mass of the pedestal, respectively. Jc is the inertia moment of the pedestal around y-axis. Jv is the inertia moment of the pedestal and the pendulum around the z-axis. Jp is the inertia moment of the pendulum around the y-axis. l is the distance from the base to the center of the pendulum.
is the tilt angle of the pendulum.
Since the potential of the wheel and the pedestal are zero, the total potential of the system is as shown in: Where: Replacing (7) into (3) and replacing (2)-(6) into (1) we get the Lagrange equation of the system according to the total kinetic energy and the total potential energy as shown in:

The forward kinematic of TWSB robot
To calculate the forces in the system affected by the joint variables, we use the following general kinetic: in which, is the forces effected by the joint variables. The variable qi is a component of the joint variable vector. Applying in (9) with the displacement (xL) of the left wheel along x-axis, we get: With is the total moment of the system effected on the left wheel of the robot. Executing in (10) based on the (8), we obtain: Int J Artif Intell ISSN: 2252-8938 A neural network combined with sliding mode controller for the two-wheel… (Duc-Minh Nguyen) 595 Applying in (9) with the displacement (xR) of the right wheel along x-axis, we get: with is the total moment of the system effected on the right wheel of the robot. Executing in (12) based on the (8), we obtain: Executing in (9) with the tilt angle variable ( ) of the pendulum, we obtain: Executing in (14) based on (8), we have: We have relationships between the variables as shown in: Adding (11) and (13), then replacing variables as in (16), we get: Taking (11) minus (13), then replacing variables as in (16), we get:

The mathematical model of the control object
The general kinetic equation system for robots has the following general form [20], [21]: where ( ) ∈ is the asymmetric and positive definite matrix ( ,̇) ∈ is the centrifugal and Coriolis forces. (̇) ∈ is the friction. ( ) ∈ is the gravity force. ∈ is a general nonlinear disturbance. ∈ represent the torque input controls vector. ,̇,̈∈ denotes the angle, velocity, and acceleration vector of the link, respectively. Because the TWSB robot is a three-degrees of freedom robot with three variables such as the moving variable x, the turning angle variable θ, and tilt angle variable , we have the vector variables of the joints: Rewriting (17), (18), and (15) according to (19) we get the following coefficient matrices: Demonstration of property 2: The derivative of matrix D: Replacing (22) and (23) in (20), we get: Thus, based on the results in (24) with the matrix parameters in (21) and (22), the TWSB robot kinetic equation has the property as (20).

BUILDING THE NEURAL NETWORK TO COMPENSATE FOR DISTURBANCE
Commonly, the sliding mode control method [22]- [24] includes defining the sliding surface as the system state functions and proving the trajectories of the closed-loop system reach this surface in a finite time based on stability theory. To solve the disadvantages in the common sliding mode control, we add a neural network. The neural network and sliding mode controller's learning algorithm is constructed relying on the Lyapunov theorem to ensure the system's stability.
To build the kinetic model [25] of the robot, we ignore some external forces that affected the system. After making the general equations, we will add these external forces. In (19), (̇) is the composition of friction on the two wheels. It includes FL, FR -friction force impact on the left-wheel and right-wheel; -the external force impacts the two wheels.
has fL , fR -the interaction force between the left and right wheel and pedestal; f dL , f dR -the external force impact on the left wheel and right wheel. Setting: In the nonlinear kinetic system, noise and friction are the leading causes of control quality loss. Therefore, to increase control quality, the authors will build a neural network for compensation for the disturbances and uncertainty parts in this study.
In studies on robust adaptive control, NN in [17], [26], [27] are mostly used for the unknown nonlinearities as approximation models because of their inherent capabilities of approximation. A simple artificial neural network structure for approximating function may be rewritten as: ( ,̇,̈, ) = ( ) = + (26) where ε denotes the approximation error and ̄ is the limit of ε, (| | ≤). σ denotes the Gaussian function. We define the weights to construct an approximated neural network, so the (9) could be rewritten as: The Gaussian function is as shown in: where Si= [Si1,Si2,…,Sin] T denotes the input of Radial Basis Function (RBF) network, ci=[c1,c2,…,cn] T is the centers of the basic function and is the widths of the basic function, freely chosen. We set a Lyapunov function V(t). Basing on the Lyapunov stability theory, if we make a control law so that the time derivative of V(t) is negative, then the agent's trajectory will converge to the sliding surface = 0in a finite time and keep them on the sliding surface. Setting the Lyapunov function as shown in: It is easy to see that this function is positive definite: Differentiating in (29) concerning time, we get: According to dynamic in (19), both ( ,̇) and ( ) satisfy Property 2: The matrix(̇− 2 ) is symmetric. This characteristic ensures the system unaffected by the force is defined by ( ,̇)̇. Therefore, from (30) and (31), we have: Setting the sliding surface structured with PD and neural network (26) to cling to the reference trajectory of the Euler -Lagrange system (19) with the deviation of e equal to 0, we propose the following control law: The learning algorithm: where K is a symmetric positive matrix and , > 0. Theorem 1 consider the Euler-Lagrange system (19), sliding mode control s = ė+ Λe (35), approximating neural network defined in (27) with Gaussian function described in (28), the proposed state feedback control law (33), and learning algorithm (34). All the system signals are limited, and the tracking error congregates to sliding surfaces in a limited time.
Basing on (27) and (28), the last part in (39) can be rewritten to the following: In (39) is rewritten as shown in: From (41) we can see that ̇( ) < 0 for all ≠ 0and ̇( ) = 0 if and only if = 0. So, with the sliding surface (35), control law (33), learning algorithm (34), and neural network (26), the agent will be tracking the desired trajectory with the error → 0.

RESULTS AND DISCUSSION
Firstly, we run the neural network to identify the robot with the sample period time Tsp = 0.01. After training, we get the following results. The mse deviation between NN model output and object output is 2.5 *10 -12 . The biggest deviation between NN model output and robot output is 6 * 10 -5 . The number of training is 1350. The neural network used for identification as (17), the Gaussian function is described in (28) Learning rate = 0.1and = 2. The input/output responses of the reference model, the output responses of the object, and the responses of the controller reference model are shown in Figure 2 and Setting the sinusoidal random noise, the force acting on the two wheels are as shown in: The torque response on the two wheels is shown in Figure 5.  The system responses are shown in Figures 6 and 7, respectively. Figure 6(a) shows the position response and Figure 6(b) shows speed response of the robot. Figure 7(a) shows the angle response and Figure 7(b) shows angle rate response of the robot. The results show that the system is well-stabilized, matched the proven theoretical with high efficiency. The parameters of position, speed, angle, and angular velocity quickly return to the equilibrium position after no more than 10 seconds. Therefore, we can confirm that the control method proposed by the authors has worked effectively.

CONCLUSION
In this paper, based on the neural network structure combined with the sliding mode controller with PD-surface, the authors have designed a TWSB robot controller that can compensate for noise in an uncertain environment. The authors have taken the advantage of two methods: the neural network has a high adaption and the sliding mode controller has a fast response. The neural network parameters are always defined and updated online to ensure stability in varying noise. Compared to previous approaches, this method's advantage is that the noise detection and filtering system can compensate for any disturbance and ensure the system's stability quickly. The results of this study will be the foundation for the authors' further studies in improving the quality of the consensus control system for many TWSB robots.