#### Abstract

A novel iterative learning control (ILC) algorithm for a two-wheeled self-balancing mobile robot with time-varying, nonlinear, and strong-coupling dynamics properties is presented to resolve the trajectory tracking problem in this research. A kinematics model and dynamic model of a two-wheeled self-balancing mobile robot are deduced in this paper, and the combination of an open-closed-loop PD-ILC law and a variable forgetting factor is presented. The open-closed-loop PD-ILC algorithm adopts current and past learning items to drive the state variables and input variables, and the output variables converge to the bounded scope of their desired values. In addition, introducing a variable forgetting factor can enhance the robustness and stability of ILC. Numerous simulation and experimental data demonstrate that the proposed control scheme has better feasibility and effectiveness than the traditional control algorithm.

#### 1. Introduction

Two-wheeled self-balancing mobile robots [1–3] are naturally unstable systems with characteristics such as nonlinear, multivariable, time-varying, and incomplete under-actuativity, and these characteristics can be used to study variable control algorithms. As the abovementioned robots have advantages in terms of different aspects of strong environmental adaption, low cost, and stable operation, these robots have many applications in many areas. Kazuo Yamafuji first introduced the concept of a two-wheeled self-balancing robot in the nineteen eighties. Since then, scholars have investigated numerous kinematic models and control algorithms for two-wheeled self-balancing mobile robots. Grasser [4] developed the DSP-based wheeled balancing robot “Joe”, which achieved good mobility through decoupling motion and simplified control but poor interference resistance. Miasa [5] designed the self-balancing robot “Equibot”, but it was only good for moving on flat ground and could fall over on uneven ground and thus has high requirements for road conditions. Additionally, the adaptability of the controlled object is undesirable. Thao [6] used the PID inverse step method to control a robot; a reverse step controller maintained the balance of the system, and a PID controller controlled the motion direction. However, the algorithm is too complex to implement in practical applications. Wu [7] applied a state feedback controller and a fuzzy controller to a robot. Experiments showed that the combination of these two control algorithms could achieve a good control effect. Because of its small capacity, feasible rotation and strong ability to adapt to terrain changes, this combined algorithm is widely used in many fields[8–10], such as traffic, survey, rescue and entertainment. However, this method is cost prohibitive and time consuming because of its fuzzy rules.

Determining how to maintain balance and realize perfect tracking under the correlated interference condition is absolutely critical to research about two-wheeled self-balancing mobile robots. However, conventional modern control methods, including sliding mode control and intelligent control, need accurate knowledge of the robot dynamics and physical parameters of the system to ensure consistency and convergence. Thus, we introduced a novel iterative learning control (ILC) algorithm. The basic idea behind ILC [11–13] is that the controller should learn from previous executions and perform better every cycle. The idea of ILC is that a skill can be improved and subsequently perfected through constant practice. An ILC algorithm has already been designed for mobile robots in [14–16], Kyung [14] used ILC path-tracking algorithm to control mobile robot under state disturbances and state errors, but its trajectory tracking accuracy is not very ideal. Chong [17] adopted ILC with predictive, current, and past learning items to achieve high precision trajectory tracking. However, the tracking performance of this algorithm is poor in the real experimental environment with interference. There are quite a few other learning control methods. Zhou [18] design a robust observer-based learning control method with a prescribed H∞ disturbance rejection for modified repetitive-control system to compensate the system delay. Zhou [19] presents an estimation and compensation learning control of state-dependent nonlinearity for EID-based modified repetitive-control system to improve the tracking performance.

This algorithm is extended to include the open-closed-loop PD-ILC scheme [20–22] for two-wheeled self-balancing mobile robot systems to improve the performance of the algorithm. Open-closed-loop PD-ILC not only ensures system stability but also improves tracking performance and vibration control. To reduce buffeting caused by robot system uncertainty and disturbances, this control law has been improved by the introduction of a variable forgetting factor, which can dynamically and precisely compensate for system errors. This combination not only stabilizes the robot's balance but also maintains the motion of the robot to track the desired trajectory.

The remainder of this paper is organized as follows. In Section 2, a mathematical model of a two-wheeled self-balancing mobile robot is derived from Newton's laws and Lagrangian mechanics. Section 3 describes the design of the proposed ILC controller schemes. A robust convergence analysis is performed in Section 4. In Section 5, simulations are presented and discussed. Section 6 illustrates the experimental results for the control system. The paper is concluded in Section 7.

#### 2. Two-Wheeled Self-Balancing Mobile Robot System Model

##### 2.1. System Description of the Two-Wheeled Self-Balancing Mobile Robot System

As shown in Figure 1, the mechanical part of the two-wheeled self-balancing mobile robot [23–25] basically consists of two wheels and a body. The parameters of the two wheels of the robot are the same in terms of mass, diameter and rotational inertia; additionally, these wheels are coaxially installed and independently driven. The body moves in an upright fashion and maintains balance through two rounds of rotation. The fundamental equation and derivation of the robotic mathematical model use Newton’s laws of motion and Lagrangian mechanics. Based on the model, an open-closed-loop controller, in combination with ILC, is deployed for equilibrium stability and drive control.

When the two wheels move at different speeds, the robot body can change its direction and rotate around its center by setting different rotation directions for the two wheels. The steering principle is exactly the same as the tank steering principle shown in Figure 2.

##### 2.2. Dynamic Modeling of the Two-Wheeled Self-Balancing Mobile Robot System

According to Newton's second law of motion and the momentum balance, the following differential equation is obtained after force analysis of the robot body and two-wheeled bottom in the horizontal direction:

The following differential equation is obtained by analyzing the force and momentum balance of the robot body in the vertical direction:

Formulas (1) and (2) are the mathematical model in the form of the system's nonlinear differential equations. Since keeping the robot in balance is the primary purpose of control under appropriate external conditions, the exact model is treated as follows:

The linearization of the equation of motion is as follows:

After taking the Laplace transform [26, 27], the transfer function is as follows:where .

According to formulas (4) and (5), the equation of state in which the displacement , velocity , pitch angle , and angular velocity of the robot are state variables is

The output equation with the displacement and pitch angle of the robot as the output variables iswhere is the displacement of the robot, is the velocity of the robot, is the acceleration of the robot, is the angle between the robot body and the vertical upward direction, is the input, is the mass of the two-wheeled bottom part of the robot, is the upper body mass of the robot, is the coefficient of friction between the robot's bottom wheel and the ground, is the linear distance between the axis of the robot's bottom wheel and the center of its body mass, and is the upper body inertia of the robot.

Formulas (8) and (9) can simplify the system state equation as follows:where is the state matrix, is the input matrix, is the output matrix, and is the feedforward matrix.

#### 3. Designed Controller and Variable Forgetting Factor

The designed control algorithm, which includes the tracking error of previous iterations and current iterations, as shown in Figure 3, iswhere indicates the iteration number; is the open-loop differential learning gain matrix; is the closed-loop differential learning gain matrix; is the open-loop proportional learning gain matrix; is the closed-loop proportional learning gain matrix; and are the control variable; is the initial value of the input; and .

Scholars generally use a fixed forgetting factor, but cannot vary with changes in the system features. In this article, is a multivariable forgetting factor that is introduced to the designed controller. This multivariable forgetting factor can vary automatically according to changing system deviation. The factor is used to balance perfect learning and robustness, which can increase the robustness of ILC against uncertainty, disturbance, initialization error, and fluctuation of system dynamics:where coordinates gain changes and is used to control the rate at which approaches 1. The smaller the value of , the better the system tracking performance.

#### 4. Convergence Analysis

*Assumption 1. *Function is uniformly Lipschitz with respect to ,where is the Lipschitz constant and is a nonlinear function.

*Assumption 2. *The initial value of the system satisfies the following criterion:

*Assumption 3. *For , unique and exist that satisfy the following equations:where is a nonlinear function, is the desired control input, and is the desired state.

*Assumption 4. *The uncertainty, disturbance and their derivatives are bounded.Letwhere is the desired state of the system and indicates a formula that is defined as another formula.

Let us consider nonlinear multivariable systems [28, 29] with uncertainty and disturbances as follows:where and are the number of iterations and the running time, respectively. is the state variable, is the control variable, is the system output, and are the uncertainty item and interferential term, respectively, and is a nonlinear function.

Theorem 5. *The sufficient convergence conditions of the ILC algorithm are**Then, we choose a sufficiently large constant to reach the conclusion of this theorem: the error approaches uniformly bounded with [0, T] by ILC.*

*Proof. *From (11) and (18), we obtainInserting (21) into (20) yieldsUsing Assumption 1 yields the following:Let us take the norm on both sides of (24), where -norm is defined to simplify the formula as follows:Then, (24) implies the following.Multiplying both sides of (13) by and taking the -norm yieldwhere , , and .

From Assumption 2, we obtainTaking the norm yieldsUsing the Bellman-Gronwall Lemma condition givesMultiplying both sides of (30) by to compute the -norm, we haveThe same lesson applies as follows:Substituting (31) and (32) into (27) givesWe haveThis equation means thatwhere .

We choose a sufficiently large constant to satisfy and , and we can reach the conclusion . Thus, it is concluded that the error approaches uniformly bounded with [0, T] by ILC.

#### 5. Simulation

In the simulation, open-closed-loop PD-ILC is used for comparison to verify the effectiveness of the proposed algorithm. The physical parameters of the two-wheeled self-balancing mobile robot are displayed in Table 1. The desired trajectory is . The interference terms are

. The data used in the simulation are chosen as , , and .

The simulation results are shown in Figures 4–6. Substantial error reductions take place over 40 iterations. Figure 4 shows the trajectory tracking of the wheeled self-balancing mobile robot in the process of iterative operation, and this tracking can illustrate the effectiveness of ILC laws. The angle and position are converged after 30 iterations.

**(a)**

**(b)**

**(a)**

**(b)**

**(a)**

**(b)**

**(c)**

**(d)**

The maximum tracking errors of the mobile robot are presented in Figure 5. It is obvious that the errors greatly decrease with an increasing number of iterations. In addition, this figure shows that the proposed algorithm has very small and monotonically decreasing tracking errors, and the convergence rate of this algorithm is much greater than that of the traditional open-closed-loop PD-ILC controller. The dynamic performance of the system can be greatly improved.

Figure 6 shows the pitch angle of the mobile robot. These graphs show that the pitch angle decreases as the number of iterations increases. The controlled object is a two-wheeled self-balancing robot. To maintain the balance in the dynamic movement, pitch angle cannot be zero. Compared to traditional algorithms, the proposed algorithm has a smaller pitch angle. This contribution is due to the multivariable forgetting factor. Thus, the work developed and reported in this paper forms the basis of the design and development of open-closed-loop PD-ILC with variable forgetting factor algorithm schemes for output trajectory tracking and self-balancing control of robot systems and can be extended to and adopted in practical applications.

#### 6. Experiment

The self-balancing robot is shown in Figure 7. We choose STM32 MCU [30–32] as the main control unit. To verify the reliability and advantages of the proposed algorithm, two groups of experiments are conducted to compare the control performance of the two algorithms with the same conditions in a real two-wheeled self-balancing mobile robot.

The motion trajectory of the robot is shown in Figures 8 and 9 indicate the desired and actual position trajectories in the last iteration and the pitch angle is shown in Figure 10. The self-balancing mobile robot travels roughly along the black line of the road, especially while turning. The results of the experiment show that the proposed algorithm can effectively track the desired trajectory and yaw angle and stabilize the pitch angle.

**(a)**

**(b)**

**(c)**

**(d)**

The comparative results indicate that, with the same parameters, the performance of open-closed-loop PD-ILC with a variable forgetting factor is better than that of traditional open-closed-loop PD-ILC in terms of robot control. Figures 9 and 10 indicate that the designed control algorithm for two-wheeled self-balancing mobile robot systems has better trajectory tracking control ability, faster convergence speed and maintains variation in the lower pitch angle despite a variety of disturbances. The proposed algorithm has potential value for practical applications.

#### 7. Conclusions

After adopting an ILC strategy combining open-closed-loop PD and a variable forgetting factor, a new iterative approach that can effectively solve two-wheeled self-balancing mobile robot kinematics is constructed in this paper. The self-balancing robot is a complicated dynamic system that has highly nonlinear and coupled characteristics. Acceptable trajectory tracking control and self-balancing features have been achieved with both control strategies. Simulation and experimental results validate the effectiveness and feasibility of the designed algorithm. In the future, we will apply this algorithm in other control fields.

#### Data Availability

All data and metadata used to support the findings of this study are included within the article.

#### Conflicts of Interest

The authors declare that they have no conflicts of interest.

#### Authors’ Contributions

Jian Dong designed the experiment. Jian Dong and Gang Li were involved in designing and conceiving the article. Bin He and Gang Li performed the experiment. Chenghong Zhang crunched the data. Jian Dong wrote the paper. Chenghong Zhang and Gang Li revised the paper.

#### Acknowledgments

This work was supported by the National Natural Science Foundation of China under Grants nos. 61801330, 61825303, 2018YFB1305300, and U1713215. It was supported by key innovation team program of innovation talents promotion plan by MOST of China (no. 2016RA4059).