Stabilizing a Rotary Inverted Pendulum Based on Logarithmic Lyapunov Function

The stabilization of a Rotary Inverted Pendulum based on Lyapunov stability theorem is investigated in this paper. The key of designing control laws by Lyapunov controlmethod is the construction of Lyapunov function. A logarithmic function is constructed as the Lyapunov function and is compared with the usual quadratic function theoretically. The comparative results show that the constructed logarithmic function has higher numerical accuracy and faster convergence speed than the usual quadratic function. On this basis, the control law of stabilizing Rotary Inverted Pendulum is designed based on the constructed logarithmic function by Lyapunov control method. The effectiveness of the designed control law is verified by experiments and is compared with LQR controller and the control law designed based on the quadratic function. Moreover, the system robustness is analyzed when the system parameters contain uncertainties under the designed control law.


Introduction
The Rotary Inverted Pendulum, which was proposed by Furuta et al. [1], is a well-known test platform to verify the control theories due to its static instability.Rotary Inverted Pendulum has also significant real-life applications, for example, aerospace vehicles control [2,3] and robotics [4][5][6].Considering the mentioned facts, Rotary Inverted Pendulum is selected as the controlled system and lots of control problems are concerned by researchers, such as stabilizing the pendulum around the unstable vertical position [7][8][9], swinging the pendulum from its hanging position to its upright vertical position [10][11][12][13], and creating oscillations around its unstable vertical position [14,15].
For the swing-up and stabilizing control of Rotary Inverted Pendulum, a variety of control methods had been applied.Jose et al. [16] and Akhtaruzzaman and Shafie [17] all used proportional-integral-derivative (PID) and linear quadratic regulator (LQR) to balance the pendulum in its upright position, while PD cascade scheme was applied to the switching-up control of the pendulum and fuzzy-PD regulator to the stabilizing control of the pendulum by Oltean [18].Besides, Hassanzadeh and Mobayen used particle swarm optimization (PSO) method to search and tune the controller parameters of PID in the control of balancing the pendulum in an inverted position [19].
Except these classical control techniques, several advanced control methods are also used to design controllers to stabilize the pendulum in upright vertical position.For example, Chen and Huang proposed an adaptive controller to bring the pendulum close to the upright position regardless of the various uncertainties and disturbances [20].Hassanzadeh and Mobayen applied evolutionary approaches which include genetic algorithms (GA), PSO, and ant colony optimization (ACO) methods to balance the pendulum in inverted position [21].Hassanzadeh et al. also proposed an optimum Input-Output Feedback Linearization (IOFL) cascade controller utilized GA to balance the pendulum in an inverted position, in which GA method was used to search and tune the controller parameters [22].Furthermore, the fuzzy logic control [23], -∞ control [24], and sliding mode control [25] are all used to achieve the same control objective.
On the other hand, the inverted system can be underactuated and nonholonomic systems.Yue et al. used indirect adaptive fuzzy and sliding mode control approaches to achieve simultaneous velocity tracking and tilt angle stabilization for a nonholonomic and underactuated wheeled inverted pendulum vehicle [26].Different from [26], some researchers focus on the study of the general classes of underactuated and nonholonomic systems.For example, Mobayen proposed a new recursive terminal sliding mode strategy for tracking control of disturbed chained-form nonholonomic systems whose reference targets are allowed to converge to zero in finite time with an exponential rate [27].Mobayen also proposed a recursive singularity-free, fast terminal sliding mode control method, which is able to avoid the possible singularity during the control phase, which is applied for a finite-time tracking control of a class of nonholonomic systems [28].
Among various control methods, Lyapunov control method is a simple method of designing control laws and can be applied to linear systems and nonlinear systems.Particularly, the analytic expression of designed control laws can be obtained, which help to analyze the control performances and system characteristics.Thus we use Lyapunov control method to achieve stabilizing control of Rotary Invert Pendulum in this paper.The key point of Lyapunov control method is the construction of the Lyapunov function.Aguilar-Ibanez et al. [8] and Türker et al. [9] all selected energy function as Lyapunov function from the quadratic function and used Lyapunov's direct method to stabilize Rotary Inverted Pendulum.Energy function considered the physical system and was constructed from physical standpoint, which leads to the application of constructed energy function confined to the considered physical system.For different physical systems, the energy functions are different and need to be constructed respectively.Instead of energy function, we construct the Lyapunov function from mathematical standpoint.Based on the quadratic function and Taylor series, a logarithmic function is constructed and as Lyapunov function, which is applicable to not only Rotary Inverted Pendulum but also the physical systems with the linear or nonlinear models.Based on the logarithmic Lyapunov function, the control laws of stabilizing Rotary Inverted Pendulum are designed by Lyapunov method in this paper, that is, balancing the pendulum in its upright position.In order to describe the properties of the constructed logarithmic function, the relationships between the usual quadratic function and the constructed logarithmic function are compared in numerical value and convergence speed.The comparative results show that the logarithmic function has higher numerical accuracy and faster convergence speed, which will be also verified in experiments.Furthermore, the experiment results also show that the designed control law by Lyapunov method in this paper can also achieve swing-up control of Rotary Inverted Pendulum.Based on these results, the system robustness is analyzed when the system parameters contain uncertainties under the designed control law.Thus, the main construction of this paper is to construct a logarithmic function as Lyapunov function and prove that the logarithmic function has higher numerical accuracy and faster convergence speed.
The remaining of this paper is organized as follows.Section 2 introduces the mathematical model of Rotary Inverted Pendulum and describes the control objective.The construction and analysis of logarithmic Lyapunov function as well as the design of control laws and robustness analyses are shown in Section 3. The experiments in Section 4 are used to verify the effectiveness of the designed control laws and the analyzed conclusions of logarithmic Lyapunov function as well as the system robustness.Lastly, Section 5 concludes the paper.

Mathematical Model of Rotary Inverted Pendulum
Rotary Inverted Pendulum is composed of a rotating arm which is driven by a motor and a pendulum mounted on arm's rim, whose structure is shown in Figure 1.The pendulum moves as an inverted pendulum in a plane perpendicular to the rotating arm. and  are employed as the generalized coordinates to describe the inverted pendulum system.The pendulum moves a given  while the arm rotates with an angle of .By applying Newton method or Lagrange method [29], one can get the nonlinear mathematical model of Rotary Inverted Pendulum [24,30]: where  is voltage and  is torque and given as The parameters in (1) and ( 2) are described in Table 1, which is the same as [24].This paper considers the problem of stabilizing Rotary Inverted Pendulum; thus  and  are all relatively small in most of the control time.For small  and , cos() ≈ 1 and sin() ≈ .Placing the approximate expressions into (1) and solving (1), the state space model of Rotary Inverted Pendulum can be written as where with Obviously, vertically upward position ( = 0) and vertically downward position ( = ) of pendulum are all equilibrium position for an arbitrary fixed ; that is, system (3) has more than one equilibrium state.In order to solve this problem, the states feedback technique, whose block diagram is shown in Figure 2, is used to make system (3) only have one equilibrium state ( = 0,  = 0).If the feedback control is noted as , then (3) becomes where  is the gain vector of state feedback and  =  +  =  + .
In the rest of this paper, we focus on the system model ( 6) instead of (3).The aim of this paper is to design feedback control  by Lyapunov control method so that Rotary Inverted Pendulum can be stabilized at the equilibrium position  = 0 and  = 0 from arbitrary position.The control law  or input voltage  can be calculated from  easily based on  =  +  and  = .

Design of Control Laws
For linear control systems, lots of methods can be used to design control laws.In this paper, the control laws of stabilizing Rotary Inverted Pendulum are designed by Lyapunov control method, whose motivations are as follows: (i) the procedure of designing control laws is simple; (ii) the analytic expression of control laws can be obtained; (iii) the control laws designed by Lyapunov method can guarantee the system stability.Based on Lyapunov stability theorem, the control laws can be designed as follows: (1) Construct a function (, ) which satisfies the conditions of Lyapunov function; that is, (, ) is once continuously differentiable for , (, ) ≥ 0 and "=" holds if and only if  =   which   is the equilibrium state.

Construction of Logarithmic Lyapunov Function.
In classical literatures [31][32][33], the quadratic function   is usually selected as Lyapunov function; that is, where  is a nonnegative matrix.
In order to obtain higher numerical accuracy and faster convergence speed, a logarithmic function   from quadratic function   and Taylor series is constructed as Lyapunov function; that is, To illustrate   is better than   , the relationships of numerical value and convergence speed between   and   are shown as follows: (i) Numerical value: the Taylor series of   (, ) is from which one can see that   (, ) is the first item of the Taylor series of   (, ), while   (, ) contains the quadratic term, cubic term, and higher order terms of    relative to   (, ).Thus,   (, ) has a higher numerical accuracy than   (, ).
which means  2 (Γ) is a monotone decreasing function, and thereby, is the constructed logarithmic Lyapunov function, so V (, ) ≤ 0 for  ̸ = 0 through designing control laws.Taking into account (11), one can get that which means   / V >   / V for  ̸ = 0; namely   has faster convergence speed than   .
According to the above analysis,   has higher numerical accuracy and faster convergence speed than   , so the control laws of stabilizing Rotary Inverted Pendulum are designed based on   by Lyapunov control method in this paper.
Moreover, the constructed   can be used in nonlinear system due to the applicability of Lyapunov control method and can be as performance function in optimal control to obtain better control effect due to the higher numerical accuracy and faster convergence speed.Therefore   has a greater range of applications, not limited to Rotary Inverted Pendulum and linear systems.

Design of Control Laws via Lyapunov Method.
In order to design the control laws under the condition of V (, ) ≤ 0 at any time, we need to calculate the first-order time derivative of   (, ) where  =   ( Ã  +  Ã) and  = 2  ,  = 1/(1 +   ).
To ensure V (, ) ≤ 0, the feedback control is designed as Placing ( 17) into (16), it is easily got that Similarly, the first-order time derivative of   (, ) is and the control law is designed as so that V (, ) = − 2 < 0 for  ̸ = 0. Comparing (17) and (20), the first items of   and   are the same while the second item of   contains parameter  and   does not contain .In Section 4, whether the control law   can stabilize Rotary Inverted Pendulum will be verified by experiments, based on which the control performances of   ,   , and a LQR controller will be compared.

Robustness
Analyses.The actual system is usually affected by the perturbations from environment or other sources, so that the system parameters contain uncertainties.It is reasonable to request that the designed control laws can resist the variation of parameters and the effect of perturbations to the greatest extent, so the controlled systems need stronger robustness under the control laws.In this subsection, we will investigate the system robustness under the designed control law   .We focus on the effects of  and  caused by the perturbations.
If the perturbations make  become  + Δ  , that is, Ã + Δ Ã, which lead to that  becomes +Δ  , according to (17), the designed control law   becomes which means the difference between the real control law r and the theoretic control law   is Δ  / when the perturbations affect .
If the perturbations make  become  + Δ  , which lead to that  becomes  + Δ  , according to (17), the designed control law   becomes which means the difference between the real control law r and the theoretic control law   is Δ  (1 − /( + Δ  )) when the perturbations affect .From ( 21) and ( 22), the two items of   are all affected when the perturbations affect , while only one item of   is affected when the perturbations affect , which means the system robustness is better in the most cases when  contains uncertainties.However, it should be noted that the real control law is the same as the theoretic control law when  = ( + Δ  ), and the system robustness is best in this case.

Experiments
In this section, the values of parameters will be given and the characteristics of Rotary Inverted Pendulum will be analyzed.Then, three experiments are used to investigate the control law   : (i) The initial position of Rotary Inverted Pendulum is set to  0 = [1  1 0]  , which verifies that   can make the pendulum from vertically downward position to vertically upward position.
(ii) The initial position of Rotary Inverted Pendulum is set to  0 = [1 1 1 0]  ,   ,   , and LQR controller  lqr are used to stabilize Rotary Inverted Pendulum, respectively, and then the control performances of   ,   , and  lqr are compared.
(iii) In order to investigate the system robustness under the designed control law, let the system parameters The key of state feedback is to calculate the gain vector .In this section, the desired closed-loop poles are set to {−1, −2, −3 + 3, −3 − 3}; then the closed-loop characteristic equation is so Then, the gain vector  can be calculated as [34]  = [0 0 0 1] where  is calculated by solving the Lyapunov equation   +  = −.The experiment results are shown in Figure 3, in which Figures 3(a)-3(d) are the curves of control law , feedback control , function   =   , and system state , respectively.The results in Figures 3(a) and 3(b) show that  and  all tend to zero, while the Lyapunov function   in Figure 3(c) is less than 10 −3 which is close to zero.One can see from Figure 3(d) that the system state converges to zero under the designed control, that is, achieving the control task.Integrating all results, the position of pendulum is from vertically downward position to vertically upward position under the control law, which realizes not only stability control but also swing-up control.

Comparison of 𝑟
where The control laws   ,   , and  lqr are all used to stabilize Rotary Inverted Pendulum, and the results are shown in Figure 4, in which Figure 4(a) is the curves of system states under   ; Figure 4(b) is the curves of system states under   and  lqr ; Figures 4(c) and 4(d) are the curves of control laws  and energies ∫   0  2 , respectively, while the curves of   =    under the three control laws are given in Figure 4(e).
From Figures 4(a) and 4(b), one can see that   ,   , and  lqr can all stabilize Rotary Inverted Pendulum, but the convergence time of system states under   is less than that under   and  lqr .The comparison result of   and   is consistent with the theoretical analysis in Section 3.1.The results in Figures 4(c) and 4(d) show that the control amplitude and energy consumption of  lqr are the maximum in the three control laws.The control amplitudes of   and   are close while the energy consumption of   is even less, which mean   can stabilize Rotary Inverted Pendulum faster with less energy.It should be noted that if  and  in (27) are set as other values, the energy consumption of  lqr may be less than that of   , but the control amplitude of  lqr is more than that of   .Considering the control amplitude and energy consumption comprehensively,   is the more recommended control law to stabilize Rotary Inverted Pendulum.In other words, the control law   has the same and even better control effect than LQR controller.According to the results in [24], the control performance of LQR controller is similar to PID controller and better than  infinity controller in the stability control of Rotary Inverted Pendulum.The designed control law   has the same comparative result as LQR controller based on the above analyses.In addition, Rojas-Moreno et al. used a FO (Fractional Order) based-LQR controller to stabilize Rotary Inverted Pendulum in [35], from which the FO LQR-based controller has the similar control time and control accuracy to LQR controller but more ability to reject disturbances, which is the advantage of the FO LQR-based controller.Instead of better robustness, the designed control law   in this paper can ensure the system stability, which is the property of Lyapunov control method.
In Figure 4(e), the function   under   converges faster and has higher accuracy than that under   , which are also consistent with the results in Figures 4(a) and 4(b) and the analysis in Section 3.1.When the time is less than 5, the convergence speed of   under  lqr is faster than that under   , while the convergence speed of   under   is faster when the time is more than 5.The accuracy comparison results have the same conclusion.Comparing Figure 4(c) with Figure 3(a), the control amplitude in Figure 3(a) is more than that in Figure 4(c) and the control time in Figure 3(a) is more than that in Figure 4(c), which means swing-up control requests more control amplitude.Simultaneously, comparing Figure 4(a) with Figure 3(d), the curves of system state in Figure 4(a) converge to zero before time 10 while that in Figure 3(d) converges to zero after time 25, which mean the control process containing swing-up control takes more time.In particular, the curve of parameter  which is the difference between   and   is shown in Figure 5, from which one can see that  is time-dependent and from 0 to 1 in control process.If  = 1,   =   , which means control law   has more flexibility than control law   .
From Figure 6, the analyses are drawn as follows: (1) Control performances are better in the cases of  32 ,  33 ,  42 , and  43 with uncertainties than those  3 and  4 with uncertainties, which is consistent with the robustness analyses in Section 3.3.
(2) For the case of  33 , when  > 0, the control performances are worse than that when  = 0, while the convergence speed is faster at first and slower than that when  = 0; when  < 0, the control performances are better than that when  = 0, while   is not monotone convergence.
(3) For the case of  43 , the control performances of   and the convergence performances of   when  > 0 and  < 0 are the opposite of that in the case of  33 .
(4) For the case of  3 , when  > 0, the control performances are better than that when  = 0, while the convergence speed is lower at first and then faster than that when  = 0; when  < 0, the control performances of   are worse than that when  = 0, while   is not monotone convergence.
(5) For the case of  4 , the control performances of   and the convergence performances of   when  > 0 and  < 0 are the opposite of that in the case of  3 Therefore, when the different system parameters contain uncertainties, the system robustness is also different under the control laws designed by Lyapunov control method.The better system robustness is in the following two cases: (1) The actual θ is more than the theoretical θ ; that is, the cases of  33 and  3 contain uncertainties with  > 0.
(2) The actual α is less than the theoretical α ; that is, the cases of  43 and  4 contain uncertainties with  < 0.
These are consistent with intuition and experience.If the analytical results can be considered in designing control laws, the designed control laws are expected to have better control performance.

Conclusions
The control law of stabilizing Rotary Inverted Pendulum is designed based on Lyapunov stability theorem.A logarithmic function is constructed as the Lyapunov function, based on which the control law is designed by Lyapunov control method.In particular, the relationships between the constructed logarithmic function and the usual quadratic function in numerical value and convergence speed are analyzed in theory.The results show that the logarithmic function has higher numerical accuracy and faster convergence speed than the quadratic function, which is also verified in experiments.Moreover, the control law designed can also achieve the swing-up control of Rotary Inverted Pendulum.On this basis, the system robustness when different system parameters contain uncertainties is investigated.The further works can be considered as follows: (1) Lyapunov control method is applicable to nonlinear system, so the nonlinear mathematical model of Rotary Inverted Pendulum, which is more accurate to describe system characteristics than linear model, can be considered as the controlled system, and the stabilizing control laws can be designed by Lyapunov method; (2) the constructed logarithmic function in this paper can be used in other control methods, such as the logarithmic function which was selected as the performance function in optimal control; (3) the research results for the general classes of the underactuated and nonholonomic systems, such as [27,28], are applied to Rotary Inverted Pendulum systems.

Figure 3 :
Figure 3: Results of stability control for vertically downward initial state.

Figure 5 :
Figure 5: Curve of  in control law   .

Table 1 :
Descriptions of physical parameters.

Table 2 :
[24]es of physical parameters.The values of the parameters in Table1are given in Table2, which is the same as in[24].Substituting the values into  and  in (3), then the eigenvalues of  are {0, −17.8671, 7.5266, −4.9783}, which means  is singular and system (3) is unstable with more than one equilibrium state due to zero eigenvalue and positive eigenvalues.The rank of the controllability matrix   = [   2   3 ] is 4, that is, full rank, (6)tain uncertainties; that is, the elements   in  or   in  become ã = (1 + )  and b = (1 + )  where  represents the uncertainties.Then, the control performances with uncertainties are compared with the case without uncertainties.4.1.System Parameter Settings.whichmeansthe system is controllable.By applying state feedback technique, system (3) becomes system(6), which is controllable and stable and has only one equilibrium state.