#### Abstract

In this paper, two controllers with a compound disturbance observer are proposed for a two-wheeled inverted robot (TWIR) with model uncertainty and unknown input disturbance. First, an equivalent linear model of the TWIR with uncertainty and input disturbance is proposed using the Taylor series expansion for the nonlinear model of the TWIR at an equilibrium point, in which the nonlinear part of the Taylor series and the model uncertainty are combined with unknown input disturbance as compound input disturbance. Then, the compound input disturbance is estimated by using the Newton method and reference model. As the estimated compound disturbance is used to compensate for the compound disturbance, the equivalent linear system becomes closely definite without compound input disturbance. Finally, two controllers are proposed using the equivalent linear system. Stability analysis of the proposed control methods is also given. To illustrate the proposed methods, some simulations for the TWIR are performed and compared with the existing methods. The main contribution of this work includes the following: (i) simple controllers based on compound input disturbance observer for trajectory tracking and balancing of TWIRs with unknown input disturbance and model uncertainty are proposed; (ii) the stability of proposed closed-loop control systems is proved; (iii) our proposed methods are simulated and compared with the existing methods.

#### 1. Introduction

TWIRs were widely studied in the literature and applied as vehicles in practice [1, 2]. Their nature is an unstable, underactuated, and nonlinear system, so it is very difficult to control them. There have been many controllers designed for TWIRs such as backstepping [3, 4], sliding mode control [5–7], nonlinear control [8–11], PID control [12, 13], PD controller with iterative learning [14], fractional PID [15], fuzzy control [16, 17], model predictive control [18], and nonlinear disturbance observer-based control [19].

In [3], an adaptive backstepping controller combined with two PD controllers was proposed for an electric scooter with model uncertainty, but the input disturbance was not considered. In [4], both model uncertainty and exogenous disturbance were addressed, but the proposed controller was complicated. In [5], sliding mode controllers were applied to dealt with model uncertainty, and experimental data based friction compensation models were built for a TWIR, so this is an disadvantage in design. In [6], adaptive sliding mode control in combination with direct fuzzy control was applied for balancing and trajectory tracking of the TWIR; however, no disturbance was considered. In [8], a nonlinear state transformation-based controller was proposed without considerations of model uncertainty and disturbance. A state-dependent nonlinear model-based LQR controller was designed in [9], which was robust to external disturbances but not dealing with model uncertainty. In [10], a passivity-based controller using the two-rule Takagi–Sugeno fuzzy model was proposed for the TWIR. In [11], a controller using the state-dependent Riccati equation was designed. A combination of two PD controllers and a time-delayed controller for fast movement of TWMR was proposed in [12], where the first PD controller was designed for the pitch angle, the other PD controller was applied for the orientation, and the time-delayed controller was synthesised for the position. In [13], a proposed control scheme consists of local controller and a global planner for the TWIR-based personal transportation vehicle, in which the local controller contains three PID controllers for the pitch angle, the yaw angle, and the position. In [16], an indirect adaptive fuzzy controller based on the trajectory planner was proposed for the TWIR with model uncertainty. Four interval type 2 fuzzy logic inference system-based controllers [17] were designed using the Takagi–Sugeno model for the TWIR with uncertainty and disturbance, but the controller is dependent on solving linear matrix inequalities. In [20], an optimal H-infinity controller was proposed by using Taylor series approximation at operating point, so it requires a lot of computations. Trajectory tracking control and control for obstacle avoidance of the TWIR with certain model and no disturbance were proposed in [18] and [21]. In [19], a nonlinear disturbance observer based dynamic surface controller was proposed, in which the observer is a complex differential equation to solve and the designed controller was also complicated when using a global change of coordinates and dynamic surface control technique and filters. This controller can only stabilize the pitch and yaw angles of the TWIR. Recently, an adaptive observer-based high gain controller was proposed in [22]. It requires a lot of integral calculations to estimate state variables and TWIR’s parameters. In [23], a hierarchical sliding mode control was proposed for controlling longitudinal and balancing motions of TWIR only. A control moment gyro [24] was used for keeping a small TWIR-balanced independence of moving control; this allows to perform the trajectory tracking problem separately from the balancing problem. Some new application directions of TWIRs were recently developed in [25–27].

Most of the mentioned above methods have not dealt with model uncertainty and unknown input disturbances; only few methods had done that, but they were very complicated for design and implementation. This motivates us to propose a simpler controller based on an input disturbance observer to concurrently overcome both model uncertainty and unknown input disturbance. In this work, our main contributions are to (a) convert the nonlinear model of TWIRs into an equivalent linear model, in which the uncertainty of nonlinear model and the unknown input disturbance are lumped as compound input disturbance, (b) prove the stability of the proposed TWIR control system, and (c) compare the proposed method with other existing methods through numerical simulations.

The remaining part of the work is organized as follows. The next section revisits a mathematical model of the TWIR and builds an exact linear model of TWIR with model uncertainty and unknown input disturbance by introducing the compound input disturbance. Two controllers with the disturbance observer are proposed for the TWIR and stability analysis is also provided in Section 3. In Section 4, some numerical simulations are carried out to illustrate the proposed method and compare it with the existing methods. The final section provides conclusions and future works.

#### 2. Mathematical Model of TWIR

In this work, a mathematical model of TWIR in [28] is used for the controller design and simulation. The schematic diagram of a TWIR is shown in Figure 1. The notations and parameters of the TWIR are shown in Table 1, where , , , and . The motion equations of the TWIR [28] are represented as in equations (1), (2), and (3):

Let us define state variables and inputs as follows:respectively. Then,where , , , , , and where with

System (5) is used to build a linear model with compound disturbance in Section 3.

#### 3. Proposed Controllers with Compound Disturbance Observer

##### 3.1. Exact Linear Model with Compound Disturbance

Let be an equilibrium point of system (5), then is the solution to the equation . Thus, , where “” are any values of and , which are the desired position and heading angle of the TWIR. Without loss of generality, it is assumed that “” is zero; this means .

Since , , and are linear functions, the first derivatives of first three variables can be expressed as follows:where , and .

Because the matrices and are constant, system (7) is certain and , , and are virtual inputs. In addition, since the matrix , system (7) is not directly affected by both the input and unknown input disturbances.

Since , , and are nonlinear functions, by using Taylor series expansion, they can be represented exactly as follows:where , having a size of , is the remainder of Taylor series for the functions , and at , and , in which , , , , , , , , and .

Since , the inverse of the matrix exists. So, can be rewritten as follows:where . In other words, is in the image space of .

As parameters of the TWIR are uncertain, system (8) can be represented as

This is equivalent towhere .

Similarly, we havewhere . In this case, also lies in the image space of .

From equations (7), (11), and (12), we obtainwhere , , and .

Thus, the uncertainty of system (13), also combined uncertainty of system (7) and system (11), is . Then, since . This means that . So, is in the image space of . It implies that the uncertainty of system (5) can be described as uncertain input disturbance .

As unknown input disturbance is applied to the TWIR, system (13) becomeswhere . Thus, the compound disturbance represents both the unknown input disturbance and the model uncertainty. System (14) is a linear model exactly representing the nonlinear system (5). In Section 3.2, the compound disturbance will be estimated.

##### 3.2. Compound Disturbance Observer

In this section, an input disturbance observer (a proposal in [29]) is presented and applied for system (14). By using the Euler method, we have an approximate discrete-time model of system (14) as follows:where , , and is the sampling time. A reference model will be used to estimate the disturbance as follows:where is the estimated disturbance at time instance . Then, system (15) with disturbance compensation is presented asand system (14) with approximated disturbance compensation becomes

Subtracting equation (16) from equation (17), we get

So, there exists a difference in equation (19), which is also the approximation error of equation (15) due to discretization process as follows:

Define a cost function . Then, an optimal estimate of is

Theorem 1. *(see [29]). If system (18) has , the measured state from system (18) is exactly represented by the following discrete-time model:with being suitably selected, the estimated disturbance (21) will satisfy that*

*Proof. *The proof was given in [29]. So, it is skipped here.

For the reference model (16), it is possible to choose for . So, equation (21) becomesThe correct value of the compound disturbance is . So, the estimation error isHowever, is proportional to because of the local truncation error [30]. Thus, the estimation error can be made as small as possible by decreasing the sampling time .

The estimated compound disturbance is used to complement system (14) as in equation (18), where and . Keep in mind that the estimated compound disturbance looks like a series of step functions.

In summary, the compound disturbance observer is implemented as follows:(1)Initialization: choose is sufficiently small. Assign . Measure the state of system (5) at time . Assign .(2)Perform the following calculations in forward order for :(a)Measure the state of system (5) at time .(b)Compute from equation (16) and calculate from equation (24).(c)Assign , go back to step .System (18) is applied to design state feedback and trajectory tracking controllers using the disturbance observer (24) in Section 3.3.

##### 3.3. Stability Analysis

In this section, the stability of system (18) with a state feedback controller is analyzed. Some assumptions are given as follows: Assumption 1. is continuous and is bounded. Assumption 2. There exists a state feedback controller satisfying that the matrix is Hurwitz (all real part of eigenvalues is negative).

Lemma 1. *With assumption 1, system (18) with a state feedback controller satisfying the assumption 2 is input to state stable (ISS).*

*Proof. *Let for and for . From equations (25) and (26), one gets . Since is proportional to due to the local truncation error [30], it is bounded. In addition, the compound disturbance and its first derivative are also bounded by assumption 1, and then, is bounded.

Let , where is a window function with for , , and for . Then, is also bounded.

Substituting and the controller into equation (18), we obtainDenote Since is Hurwitz by assumption 2, for and , the Lyapunov equationalways has a unique solution , which is symmetric positive definite. By using a Lyapunov function as follows,one haswhere denotes norm and is the smallest eigenvalue of the matrix .

As long as lies outside the domain , , thus containing the origin. Hence, system (27) is input to state stable [31]. This means that system (18) is ISS.

In conclusion, the state feedback controller with disturbance observer iswhere the gain matrix can be designed using existing methods in the literature such as LQR control, pole placement method, or even . The proposed controller is simple not only in design but also implementation. In addition, it can cope with model uncertainty and input disturbance of TWIRs. In Section 3.4, we propose a trajectory tracking controller for TWIRs with model uncertainty and input disturbance.

##### 3.4. Tracking Control for TWIR

Let be the desired trajectory for the TWIR. Define be tracking error of the TWIR. Taking the first derivative of the tracking error and using equation (18), we obtainwhere is previously defined in the proof of Lemma 1.

Theorem 2. *The tracking error holds that under the following control law:where satisfies the condition that is Hurwitz.*

*Proof. *Since , . In addittion, the matrices and have special forms as in equation (13), so ; this lies in the image space of . Thus, , where is unique due to . So, system (32) can be represented as follows:Substituting equation (33) into equation (34), we getThis system is similar to system (27), but the variable is in place of . Define a Lyapunov function aswhere . Then,where , , and is the minimum eigenvalue of the matrix . This means that whenever . Hence, is bounded.

Take the second derivative of to getwhere . Since is bounded, and are also bounded according to Lemma 1, is bounded. Using Barbalat’s Lemma, one gets .

In summary, the tracking controller isFor disturbance estimation, equations (16) and (24) will be applied, where is a constant matrix, which is previously computed one time. This is also true for computing the matrix Thus, the calculation of control signal involves only matrix/vector multiplication and addition, so it is simple to implement. This is an advantage of the proposed method in comparison with other methods in the literature such as works in [6, 20]. In [6], several integral computations involving adaptive laws have to be calculated to obtain control signals, and no input disturbance is mentioned in design process and simulation. In [20], the model linearization and Riccati equation solving are performed to obtain the control gain matrix at every sampling instance, so the computational load is very huge for implementation.

#### 4. Numerical Simulation

To illustrate the proposed method, a state feedback controller is designed using LQR method. However, there have been several other methods in the literature for designing the state feedback controller, thus the proposed method is very flexible in design. The linear model (18) is applied to design a LQR controller [32] such that the following cost function is minimum:where is a symmetric positive definite matrix and is a symmetric nonnegative definite matrix. The controller, which satisfies the cost function (40), is , whereand is the solution to the Riccati equation:

In this paper, the values of the TWIR’s parameters are given as follows: , , , , , , and and the sampling time is . Thus, following matrices are obtained:

The matrices of the cost function are chosen as and . From equations (41) and (42), the gain matrix of the LQR controller is obtained as follows:

*Remark 1. *Since the input to the LQR controller consists of state variable pairs , , and , the LQR output is similar to the sum of the three PD controllers’ output as in works [3, 12, 13], in which each state variable pair is the input to one PD controller.

For performance comparison, four cases are considered as follows:(i)Case 1: the model is certain, and there is no input disturbance(ii)Case 2: the model is certain, and there is unknown input disturbance, where(iii)Case 3: the model is uncertain, and there is unknown input disturbance, in which the unknown input disturbance is the same as in case 2; the model uncertainty is given as follows: , , , , and .(iv)Case 4: use the same simulation conditions as Case 3, but the desired trajectory is a circle with , , and , and the controllers (31) and (39) with the same matrix are applied.For the first three cases, setpoints for position, tilt angle, and heading angle are , , and , respectively. The initial values for position, tilt angle, and heading angle are , , and , respectively. The nonlinear model (5) is used to simulate the TWIR and the LQR controller with disturbance observer (31) being applied for these three cases. The disturbances and their estimated disturbances are shown in Figures 2(a), 2(b), 3(a) and 3(b).

It can be seen that for the case 1 the estimated disturbances are nonzero for a short time interval. This is caused by the Taylor approximation error in equation (8). For the case 2, it takes a little bit longer time for the estimated disturbances converging to the disturbances in comparison with the case 1. But for the case 3, it takes about 2 seconds for convergence with a small error. The position, tilt angle, and heading angle of robot are shown in Figures 4(a)–4(c). When there is unknown input disturbance, the proposed controller still guarantees the same performance as that in the case 1. This performance is little bit different as both unknown input disturbance and model uncertainty are applied. Thus, the proposed controller maintained well the control performance even though there were model uncertainty and unknown input disturbance. As the LQR controller is used without the compound disturbance observer, the control performance becomes worse than the proposed method, because there are oscillations of position and tilt angle and the divergence of the heading angle from the setpoint (see Case 3 without observer in Figure 4). So, the standard LQR controller fails to control the TWIR in the presence of model uncertainty and input disturbance.

For the fourth case, the nonlinear model (5) is also used to simulate the TWIR, and the tracking controller (39) and the state feedback controller (31) are compared to those in the work in [20]. Simulation results are displayed in Figures 5 and 6. It shows that all the tracking errors by the two proposed methods for position, tilt angle, heading angle, and their derivatives converge to zero quickly, the TWIR follows the desired trajectory closely, and control signals (provided by the tracking controller) are smooth. The tracking controller (39) provides better performance than that of the state feedback controller (30).

In comparison with [20] under the same desired trajectory type (circle, test 3 [20]), the proposed tracking controller (39) is better than the controller in the work [20] in terms of steady-static error and smoothness of control signals, since there was impulse type of control signal and there exists steady-static error of the tilt angle in [20].

**(a)**

**(b)**

**(a)**

**(b)**

**(a)**

**(b)**

**(c)**

**(a)**

**(b)**

**(c)**

**(d)**

**(a)**

**(b)**

**(c)**

**(d)**

#### 5. Conclusions and Future Works

In this work, the state feedback controller with compound disturbance observer (31) and the trajectory tracking controller with compound disturbance observer (39) were proposed for TWIRs with model uncertainty and unknown input disturbance, and the stability of the closed-loop control system with the proposed controller was also proved. The proposed controllers have advantages of simplicity in implementation and flexibility in design for the feedback gain matrix.

Numerical simulations were taken to illustrate the proposed methods and compare with the existing method in [20] and the classical LQR controller. The results show that the control performance was well maintained under model uncertainty and unknown input disturbance by using the proposed control methods, whereas the control performance becomes worse as the classical LQR controller was applied. The proposed tracking controller (39) provided better performance than the controller in [20] for the circular trajectory type, the state feedback controller (31), and also the LQR controller.

Future works focus on controller design methods for the exact linear model of TWIR (14) using different techniques and other existing observers and the further extension to other systems in the Lagrangian form.

#### Data Availability

No data were used to support this study.

#### Conflicts of Interest

The authors declare that there are no conflicts of interest regarding the publication of this paper.

#### Acknowledgments

This research was funded by the Hanoi University of Science and Technology (HUST) under project number T2018-PC-052.