4.1 Introduction

Although WIP systems are intrinsically nonlinear and their dynamics are described by nonlinear differential equations, it is often possible to obtain a linearized model of the system. Furthermore, if the system operates around an operating point, and the signals involved are small, a linear model that approximates the nonlinear system in the region of operation can be obtained. Several techniques for the design of controllers and analysis of nonlinear systems through linearization were applied before.

In [59], motion control was proposed using linear state–space model. In [56], dynamics were derived using a Newtonian approach and the control was design by the equations linearized around an operating point. In [106], the dynamic equations were studied, with the pendulum pitch and the rotation angles of the two wheels as the variables of interest, and a linear controller was designed for stabilization under the consider of its robustness in [107]. In [19], a linear stabilizing controller was derived by a planar model without considering vehicle yaw. However, the above control laws are designed on the linearized dynamics which only exhibits desirable behavior around the operating point, and do not have global applicability. In [75], the exact dynamics of two-wheeled inverted pendulum were investigated, and linear feedback control was developed on the dynamic model. In [103], a two-level velocity controller via partial feedback linearized and a stabilizing position controller were derived, however, the controller design is not robust with respect to parameter uncertainties.

Wheeled inverted pendulums are intrinsically nonlinear and their dynamics will be described by nonlinear differential equations. The presence of nonlinearities in systems complicates analysis. Despite this, for the case of controller design, it is often possible to obtain a linearized model of the system. If the system operates around an operating point, and the signals involved are small signals, a linear model that approximates the nonlinear system in the region of operation can be obtained. In this chapter, we first derive the linearized dynamic model. Then several techniques for the design of controllers and analysis techniques for linear systems can then be applied. The control methods applied here are the PID control and the Linear Quadratic Regulator optimization method used for obtaining an optimal feedback gain. Since the approach of H , optimal control has been widely discussed for robustness and its capability of disturbance attenuation in nonlinear systems. Therefore, by linearizing the dynamics of wheeled inverted pendulum and obtaining a precise knowledge of the structure of the entire plant model, robust H controls, including Riccati-like H , and LMI-based H , are applied to the linearized model with a small perturbation. The corresponding simulation examples are presented for each approach.

4.2 Linearization of the WIP Dynamics

Before the design of either controller, linear mathematical models must first be obtained. The linearization may be done by expanding the nonlinear function into a Taylor series about the operating point and neglecting the higher order terms of the expansion [100].

The nonlinear state space equations of the WIP can be written as

(4.1)
(4.2)
(4.3)

where x∈ℝ5, u∈ℝ2, and y∈ℝ5.

Considering (4.1), the equilibrium point of the system may be found by solving

(4.4)

The equilibrium points are found to be at (x 0,u 0)=(0,0). This is followed by doing a Taylor series expansion of (4.1) about the equilibrium point, which results in

(4.5)

The partial derivatives are evaluated at the operating point, and neglecting the higher order derivatives yields

(4.6)

It is noted that the matrix C in Eq. (4.3) is already constant and it therefore does not need to be linearized. The resulting linearized state space representation of the system is given by

(4.7)
(4.8)

where A and B are constant matrices defined as

(4.9)
(4.10)

Following the linearization of the system, the controllability and observability matrices of the resulting system given by M=(B AB A 2 BA 4 B) and O=(C CA CA 2CA 4)T are calculated using MATLAB. Both the matrices are found to have full rank of 4. This implies that the linearized system is both controllable and observable.

Using the dynamics model presented in Chap. 3, the dynamic model of the vehicle is linearized around the point \(\alpha=\dot{\alpha}=0\), \(\theta=\dot{\theta}=0\). Ignoring the nonholonomic constraints (x 0, y 0), we define the following 5-dimensional vector of state variables

(4.11)

Using the dynamic model, the linearized vehicle model can be expressed in the following state space form

(4.12)

where

The coefficients in the matrices in (4.12) are constant but known. The state–space model (4.12) of the vehicle consists of two decoupled subsystems—the first of these which comprises the first three equations is a “pendulum”-type system, and the second is rotation system. We assume that the state variables are measured and available for feedback control.

4.3 PD Control Design

Consider the linearized state system (4.7), let the desired state x d , and the actual state x, and define e=x d x, consider the control as

The control law is given by

(4.13)

where K is designed coefficient. A PD controller is used for each displacement and displacement rate pair of the WIP system, and the block diagram of the closed loop system is shown in Fig. 4.1.

Fig. 4.1
figure 1

Block diagram of PD controller with WIP

Introducing the control (4.13), the closed loop state space equation can be rewritten as

(4.14)

and the closed loop characteristic equation is

(4.15)

Therefore, for the closed loop system with poles at the desired pole locations defined by Eq. (4.15), the elements of K must be chosen such that the desired poles location is within the negative plane. Two conditions must be satisfied for the successful placement of all the closed loop poles. The first requires the ability to measure all the state variables in the system, or the capability of estimating certain states with the use of a state observer. The other requirement is for the system to be completely state controllable. This condition would allow the arbitrary placement of the closed loop poles. For the linear wheeled inverted pendulum system, it had been shown earlier that the system is both controllable and observable. This satisfies both of the conditions stated above.

4.4 LQR based Optimal Control Design

In the design of Linear Quadratic Regulator (LQR) controllers [100], it is necessary to be able to select appropriate values for the gain matrix K in the linear control law, such that a cost function is minimized. The control law and cost function for a system with real vectors are

(4.16)

The cost function can be described as

(4.17)

The cost function is a function of the matrix of states, e∈ℝn×1, and the matrix of inputs, u∈ℝm×1, in the MIMO case. Q∈ℝn×n and R∈ℝm×m are symmetric positive definite matrices. Matrices Q and R are chosen depending on the amount of cost the designer wants to attribute to each element of state or input. Allocating a larger cost for certain parameters (e and u) would imply that their performance would be placed at a higher priority over the others. For example, if the input is allocated a high relative cost factor, the controller would be optimized in a way such that the control task is attained with as little input as possible.

To solve for the matrix K, the following reduced matrix Riccati Equation is solved for the matrix P∈ℝn×m

(4.18)

where P is a positive definite matrix that always exists when the closed loop system is stable (i.e., the matrix (ABK) is stable), and R is positive matrix. With the solution for P, which, the matrix K may be obtained from

(4.19)

Then, the we can design the control from the above equation.

4.5 H Control

H is a robust control, which can realize disturbance attenuation. For the system (4.12), we can rewrite as

(4.20)
(4.21)
(4.22)

where ω is external disturbance vector, z is the performance signal, and D 1=0.

The objective of the control is list as follows:

(1) If x=0 is the close loop operation point, and for any initial state x(0)∈ℝ5, x(t)→0; (2) for any disturbance \(\omega \in L^{2}_{\infty}\), the close loop can realize disturbance attenuation, that is,

(4.23)

where q i ≥0, i=1,…,6, and p>0 is coefficient, let

$$ \everymath{\displaystyle} \begin{array}{c} C_1=\left [ \begin{array}{c@{\quad }c@{\quad }c@{\quad }c@{\quad }c@{\quad }c} \sqrt{q_1} & 0 & 0 & 0 & 0 \\ 0 & \sqrt{q_2} & 0 & 0 & 0 & 0 \\ 0 & 0 & \sqrt{q_3} & 0 & 0 & 0 \\ 0 & 0 & 0 & \sqrt{q_4} & 0 & 0 \\ 0 & 0 & 0 & 0 & \sqrt{q_5} & 0 \\ 0 & 0 & 0 & 0 & 0 & \sqrt{q_6} \\ 0 & 0 & 0 & 0 & 0 & 0 \end{array} \right ], \\ \noalign{\vspace{6pt}} D_2= \left [\begin{array}{c} 0 \\ 0 \\ 0 \\ 0 \\0 \\ 0 \\ \sqrt{p} \end{array} \right ] \end{array} $$
(4.24)

which is equivalent to

(4.25)

If we define the transfer function as T ω (s) for ω and z as

(4.26)

then the disturbance attenuation performance is equivalent to ∥T <1.

4.5.1 Riccati-Based H Control

Theorem 4.1

Consider the system (4.12), the control law is designed as follows:

(4.27)

where the symmetric positive definite matrix P satisfies the following Riccati-like equation

(4.28)

where γ is the attenuation levels, Q=Q T>0 is a prescribed weighting matrix and R is a gains matrix. Then the proposed control law can guarantee the global stability and robustness of the closed-loop system and achieve the following H tracking performance:

(4.29)

where λ min(Q) is the minimal eigenvalue of Q.

Proof

Choose a Lyapunov function as

(4.30)

The time derivative of V along the error trajectory is

(4.31)

In summary, by completing the squares and using the control input in (4.27) and the Riccati-like equation in (4.28) the derivative \(\dot{V}\) can be bounded as

(4.32)

Integrating the above inequality (4.32) yields

(4.33)

Since V(t)≥0, we obtain the following L 2 criterion:

(4.34)

The knowledge that Q is a positive definite matrix and the fact that λ min(Q)x T xx T Qx imply

(4.35)

Using Barbalat’s lemma, one can see that the tracking error converges to zero in an infinite time. □

Remark 4.2

The inequality (4.33) reveals that the integrated squared error of x is less than or equal to the sum of V(0) and the integrated squared error of x. Since the V(0) is finite, if x is squared integrable then we can conclude that x will approach to zero.

Remark 4.3

From (4.34), if the systems starts with the initial condition V(0)=0, i.e., x(0)=0, the L 2 gain must satisfy

(4.36)

where \(\|x\|^{2}=\int_{0}^{t} x^{T}x\, dt\) and \(\|\omega\|^{2}=\int_{0}^{t}\|\omega\|^{2} \,dt\). Inequality (4.35) indicates that when smaller attenuation levels γ is specified, a better tracking performance can be achieved.

4.5.2 LMI-Based H Control

The H state-feedback control objective is a synthesis of a state-feedback that renders the underlying system L 2-gain <γ. For this, we design the state-feedback controller of the form

(4.37)

where the gain matrix K is yet to be determined. Using (4.37) in (4.12), the closed-loop system admits the following

(4.38)

A solution to the tracking problem within the H control context amounts now to the determination of a gain matrix K which is stabilizing (internally) the closed-loop system, and in addition, achieves L 2-gain <γ.

The attenuation of external disturbances is guaranteed considering the H 1 performance related to the state x(t) as follows

(4.39)

The control law is based on the classical structure as

(4.40)

where K are gain matrices with appropriate dimension.

Theorem 4.4

Assume there is a gain-matrix K such that the closed-loop system (4.38) is dissipative with respect to the supply rate γ 2ω2−∥z2, with the energy function given by (4.31), that is,

(4.41)

Then the closed-loop system (4.38) is globally asymptotically (internally, i.e., ω=0) stable, and it has L 2-gain <γ.

Proof

Consider the following candidate Lyapunov function:

(4.42)

with P=P T>0, The stability of the closed-loop model (4.38) is satisfied under the H performance (4.39) with the attenuation level γ if

(4.43)

The condition (4.43) leads to

(4.44)

or equivalently

(4.45)

 □

4.6 Backstepping

Considering the linearized model (4.12), we can decouple the state–space model (4.12) into the rotation subsystem, which composes of the first two equations, and the pendulum-type subsystem, which consists of the left three equations. First, a control for the pendulum part of the system is designed. Consider the pendulum-subsystem of (4.12) for the tilt angle α as

(4.46)
(4.47)

where f(x 1) and b are known coefficients from (4.12). The control objective is to regulate the tilt angle α to zero. The procedure of backstepping control is design as:

Step 1

Define the state error as

(4.48)

where z d is reference signal. Then

(4.49)

Define a virtual signal as

(4.50)

where c 1>0. Define z 2=x 2α 1. Choose the Lyapunov function candidate as

(4.51)

Then, we have

(4.52)

Substitute (4.50) into (4.52), we have

(4.53)

If z 2=0, then \(\dot{V}_{1}\leq 0\).

Step 2

Define Lyapunov function as

(4.54)

Since

(4.55)

then

(4.56)

In order to \(\dot{V}_{2}\leq 0\), we choose

(4.57)

where c 2>0, then we have

(4.58)

The stability properties of (4.58) follows from (4.54). Since V 2 is positive definite and \(\dot{V}_{2}\) is negative semidefinite, we have that z 1, z 2 uniformly bounded, and also that z 1→0, z 2→0 as t→∞. Using (4.57), we conclude that the control (4.57) is also bounded. From (4.46) and (4.47), it follows that x 1 and x 2 are also bounded and converge to zero.

Remark 4.5

Once the tilt angle α has been stabilized, in order to drive the vehicle with a desired velocity v d , the vehicle speed can be stabilized, by completing the control (4.57) with an additional term, as follows

(4.59)

where K 1 is positive gains.

Remark 4.6

For the rotation subsystem, in order to drive the vehicle with a desired direction angle θ d , the vehicle rotation speed can be stabilized, the control input u 2 can be designed as

(4.60)

where K 2 is positive gains.

4.7 Simulation Studies

4.7.1 PD Control

From the model described previously, there are a number of dynamic parameters in the system, which will result in variations of the state matrices. To include the influences of parameter uncertainty into simulation. The linearized WIP with the initial conditions α(0)=−10 degree, \(\dot{\alpha}(0)=0\), v(0)=0, \(\theta(0)=\dot{\theta}(0)=0.0\), and M=10 kg, m w =0.5 kg, m=5.0 kg, 2l=0.5 m, d=0.5 m, r=0.5 m, I p =2.0 kg m2, it is easy to have the linear state equation as

$$ \everymath{\displaystyle} \begin{array}{c} A= \left[\begin{array}{c@{\quad }c@{\quad }c@{\quad }c@{\quad }c@{\quad }c} 0 & 1.0000 & 0 & 0 & 0 & 0 \\ 38.4000 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1.0000 & 0 & 0 \\ -3.0000 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1 \\ 0 & 0 & 0 & 0 & 0 & 0 \end{array} \right] \\[36pt] B= \left[ \begin{array}{c@{\quad }c} 0 & 0 \\ -0.2449 & 0 \\ 0 & 0 \\ 0.0816 & 0 \\ 0 & 0 \\ 0 & 0.5000\end{array} \right] \end{array} $$
(4.61)

In the simulation, A and BK are 6×6 matrices, there should be 6 poles, if we choose the pole point as [10−10i,−10+10i,−10,−20,−10,−20], it is easy to obtain K=[−1.0592×1.0e 4,−0.1723×1.0e 4,−1.8027×1.0e 4,−0.4507×1.0e 4,400,60]T, the initial condition of x(0)=[−10/57.3,0,0.20,0,0.5,0]T, then, we can obtain the response of the system output shown in Figs. 4.24.6.

Fig. 4.2
figure 2

The tile angle and its velocity

Fig. 4.3
figure 3

The rotation angle and its velocity

Fig. 4.4
figure 4

The position and its velocity

Fig. 4.5
figure 5

The input u 1

Fig. 4.6
figure 6

The input u 2

From the simulation plots, it was observed when matrices A and B are constants over time, the system is stable and able to follow the reference inputs despite the longer settling time. However, it is obvious that the system will be stable only when the uncertainties vary over a small range of values, and the stability of the controller to perform according to the desired specifications will then depend on whether the uncertainties stay within certain bounds.

4.7.2 LQR Control

A controller based on LQR design is used for the linearized WIP, with the initial conditions α(0)=−10 degree, \(\dot{\alpha}(0)=0\), v(0)=0, \(\theta(0)=\dot{\theta}(0)=0.0\), and M=10 kg, m w =0.5 kg, m=5.0 kg, 2l=0.5 m, d=0.5 m, r=0.5 m, I p =2.0 kg m2, the friction coefficient μ=0.005. In order to examine the effects of having different performance indices on the system response, the simulation is performed for Q and R, using LQR design, we select \(Q = \operatorname{diag}[100, 10 ,1 ,1, 1, 1 ]\), R=0.1, using (4.19), we have K=[−352.4578,−58.3972,−3.1623,−11.6735,3.1623,4.7591]T. The response of the system to each set of Q and R’s are shown in Figs. 4.74.11.

Fig. 4.7
figure 7

The tile angle and its velocity

Fig. 4.8
figure 8

The rotation angle and its velocity

Fig. 4.9
figure 9

The position and its velocity

Fig. 4.10
figure 10

The input u 1

Fig. 4.11
figure 11

The input u 2

4.7.3 H -Like Riccati Control

For the linearized WIP, with the initial conditions α(0)=30 degree, \(\dot{\alpha}(0)=0.2~\mbox{degree/s}\), v(0)=0, \(\theta(0)=\dot{\theta}(0)=0.0\), and M=4 kg, m w =0.5 kg, m=2.0 kg, 2l=0.5 m, d=0.5 m, r=0.5 m, I p =2.0 kg m2. From (4.23), we choose q 1=q 2=⋯=q 6=1.0, and p=1. For solving Riccati equation (4.28), we choose B=[B 1,B 2], and

$$B_1=\left [\begin{array}{c} 0 \\ 0\\ 0.1\\ 0.1\\ 0\\ 0.1 \end{array} \right ],\qquad B_2= \left [\begin{array}{c@{\quad }c} 0 & 0\\ -0.2449 & 0\\ 0 & 0 \\ 0.0816 & 0\\ 0 & 0 \\ 0 & 0.5000\end{array} \right ] $$

and \(R=\operatorname{diag}[-1,1,-1,1]\), we can obtain the gain as K=[185.1260,2.0189,31.0858,11.7312,−0.7217,−1.8783]T, then the corresponding responses are listed in Figs. 4.124.16.

Fig. 4.12
figure 12

The tile angle and its velocity

Fig. 4.13
figure 13

The rotation angle and its velocity

Fig. 4.14
figure 14

The position and its velocity

Fig. 4.15
figure 15

The input u 1

Fig. 4.16
figure 16

The input u 2

4.7.4 LMI-Based H Control

For the linearized WIP, with the initial conditions α(0)=30 degree, \(\dot{\alpha}(0)=0.2~\mbox{degree/s}\), v(0)=0, \(\theta(0)=\dot{\theta}(0)=0.0\), and M=10 kg, m w =0.5 kg, m=5.0 kg, 2l=0.5 m, d=0.5 m, r=0.5 m, I p =2.0 kg m2. From the system parameters chosen above, we can solve (4.45) using the LMI toolbox in the MATLAB and obtain K=[1175.8,10.8,192.4,55.5,−1.0258,−1.9419], therefore the system output are listed in Figs. 4.174.21.

Fig. 4.17
figure 17

The tile angle and its velocity

Fig. 4.18
figure 18

The rotation angle and its velocity

Fig. 4.19
figure 19

The position and its velocity

Fig. 4.20
figure 20

The input u 1

Fig. 4.21
figure 21

The input u 2

4.7.5 Backstepping Control

Consider the linearized WIP (4.12), choose the desired trajectory of α as z d =0.1sin(πt), the control parameters c 1=c 2=35, using the control (4.57), we can achieve the following output in Figs. 4.224.25.

Fig. 4.22
figure 22

The tile angle and its velocity

Fig. 4.23
figure 23

The rotation angle and its velocity

Fig. 4.24
figure 24

The input u 1

Fig. 4.25
figure 25

The input u 2

4.8 Conclusion

In this chapter, we first present the linear model of wheel inverted pendulum, then PD, LQR, H and backstepping controllers have been implemented for WIP. There are several ways to design a PD controller. In this chapter, the pole placement method was used. This technique allows the designer to specify the response of the closed loop system, but lacks the insight into robustness performance of the system. The response of the single WIP system is also examined for the case when its dynamics parameters vary with time. Comparisons are made between the performance of an LQR controller and PD controller. Finally, H and backstepping controllers are employed to verify the effectiveness of the linear control approaches.