Global asymptotic stabilization of a pendulum using a single Lyapunov proportional bang-bang control strategy

The existence of a Lyapunov function is known to ensure either local or global stability of a system’s equilibrium state. Inspired by the control-Lyapunov method, we here construct a Lyapunov candidate function by analyzing a pendulum system’s total energy and then applying appropriate control actions such that the conditions of a Lyapunov function are met. More specifically, our controller evaluates the Lyapunov function’s time derivative at each time step, and applies control torque such as to ensure that the Lyapunov function decreases for each step toward the goal upright state. Unlike the control-Lyapunov method, which aims to select control input as to minimize the Lyapunov function’s time derivative, our method provides up front the satisfactory conditions that yield a globally stable controller by using a rigorously designed proportional bang-bang control strategy. We show how to derive the controllers evaluation function, and how the controller is implemented in code. We further demonstrate the effectiveness of our method through numerical simulations. The result of our approach is a globally stable upright pendulum using a single-controller strategy.


Introduction
The simple pendulum and the cart-pendulum system's are benchmark problems in the field of control. 1 These system's are fairly simple to define yet non-trivial to control given their underactuated nature. Methods for locally and optimally stabilizing the inverted pendulum in the upright position are well established using linearized dynamics 2 and LQR. 3 In order to globally stabilize the inverted state, this local linear strategy is often paired with a swing-up controller. 4,5 Another common and well established method is that of energy-pumping. 5 In this method, by pumping energy into the system, the system will continuously move to higher energy states. Among these is the state where the pendulum is inverted. This inverted state is however not an energy maximum as one can continue to increase the system's energy infinitely beyond this point by increasing the system's angular velocity. However, by switching control strategy to the locally linear method when the pendulum is close to inverted, the system can be made globally stable. This type of system thus requires two different controllers and a rule for when to switch between them, such as defining a switching boundary in state-space. The problem with such an approach is defining this state-space boundary, and the potential of chattering 6,7 whenever the state is close to said boundary. In addition, such an approach also creates a discontinuous switch in control method which makes it more difficult to apply Lyapunov theory for proving global stability.
Given the potential downsides of multi-controller strategies, there is incentive to create a single-controller strategy that can yield global stability. Such methods have been explored in several instances. Shiriaev et al. 8,9 inspired several subsequent methods by implementing a strategy based on energy considerations for the cart-pendulum. In their 1998 8 paper a discontinuous time-invariant state feedback was designed in order to achieve global attractivity of the upright position. In their 1999 9 paper the upright position was stabilized by means of continuous feedback, enabling almost all initial conditions be attracted to the upright position. David Angeli 10 extended the Shiriaev et al. 8,9 papers and reported an almost globally stable method by adding positive and negative dissipation to the system. Srinivasan et al. 11 created a globally stable method by use of input-output linearization, energy control, and singular perturbation theory. Fujimoto and Sakamoto and Sakamato 12 formulated an optimal control problem including input saturation, and used the stable manifold algorithm to achieve global asymptotic stability and local exponential stability under actuator saturation. Magni et al. 13 used a model-predictive controller (MPC) with good results, however this method is more computationally expensive than the other approaches mentioned above. Aguilar-Iban˜ez et al. 14,15 used a Saturation Function Approach to make a cartpendulum system globally stable in the upper half plane.
We present here a method for global inverted stability of the simple pendulum using a single-controller strategy. To the best of our knowledge, the approach is novel in its methodology and arguably simpler than many of the approaches seen previously. By not requiring switching between controllers we forego the mentioned downsides of a multi-controller strategy. We will be using the terms Lyapunov function and value function. A Lyapunov function has a strict definition as presented in section Lyapunov function's below, while a value function is any function that assigns a single scalar value to a system state. In this paper, we will be creating a value function and turning this into a Lyapunov function by appropriate selection of actuation. Our method involves designing a value function which we turn into a Lyapunov function by selecting appropriate control values at each state. The method is inspired by the control-Lyapunov method, 16 but uses instead a single proportional bang-bang controller 17 evaluated on said value function which is known to yield good or even optimal results.

Lyapunov function's
Lyapunov function's are function's that may be used to prove the stability of an ordinary differential equation's (ODE) equilibrium. 18 For certain classes of ODEs, the existence of a Lyapunov function is a necessary and sufficient condition for stability. There is no general technique for constructing Lyapunov function's for ODEs, but in some specific cases the construction of Lyapunov function's is however known. One often well suited method for physical system's is to construct a Lyapunov candidate function through conservation laws, such as the conservation of energy. 18 By definition a Lyapunov function is a scalar function that satisfies the following conditions: where V is the Lyapunov function, q = ½u, _ u is the state vector, q g is the state vector at the goal (or equilibrium) state, and _ V is the Lyapunov function time derivative defined as: Here f(q(t), u(q(t)) is the system model with state q(t) and control input u(q(t)) which is dependent on the state. We are thereby designing a state feedback controller. It is sometimes preferred that one has the Lyapunov function and its derivative be positive and negative definite, respectively. However, as we shall see, this strict criterion is not necessary for the method presented here.

Method
We will be using sympy 19 which is a Computer Algebra System (CAS) for symbolic calculations. For simulating our system with control input, we use the initial value problem solver solve_ivp() from scipy. 20 The pendulum model The system we will be working with is a classic benchmark system in underactuated control 1 ; the underactuated inverted pendulum. As can be seen in Figure 1, the pendulum is comprised of a rod of length l with a point mass m at one end while being attached to a fixed rotating actuator at the other. The actuator is oriented horizontally such that the pendulum can be rotated in the vertical plane, where gravity g acts on the pendulum. Furthermore, the actuator does not have enough torque to simply rotate the pendulum to its upright state, and must instead exploit the system dynamics and use momentum to achieve said state. This system is well suited to present our method considering it only has two state variables which allows us to visually demonstrate the results by 2D and 3D plots. The method is however applicable to higher order system's. We derive the state-space model for this system by first defining the x and y coordinates of the point mass: Since x and y depend only on u we let u represent our generalized coordinate system. We let q = ½u, _ u represent our state variable, u represent our input torque and the inertia of the pendulum be I = ml 2 . 21 The kinetic and potential energy of the system is then: (1 À cosu) ensures the potential energy is zero when the pendulum angle is zero according to our coordinate system in Figure 1. The Lagrangian is defined as L = K À P, and to obtain the equations of motion we solve the Eular-Lagrange equation: It is easy to see that: and Plugging equations 6 and 7 into 5 and solving for € u we obtain the following state-space formulation 8: Defining V: a candidate Lyapunov function based on the system's total energy As mentioned earlier, for physical system's a good strategy for creating a Lyapunov candidate function, in this case our value function, is to first define a suitable conservation law such as the system's total energy. For our pendulum this energy is: Here, the energy is the lowest when the pendulum is in the downright position with zero velocity q = ½0, 0. For our Lyapunov function, we want the upright position to have the lowest value, where the energy is 2mgl (since the height of the pendulums mass is 2l). We can accomplish this by subtracting 2mgl from the total energy to give the upright zero velocity state ½6p, 0 a value of 0.
In doing so, we now have a value function with negative values for certain states, which we do not want if this is going to become a Lyapunov function. To ensure that V50, we can take the 2-norm of the current value function to obtain the following equation: Now V(p, 0) = 0 when the pendulum is upright. Note that V is not strictly positive definite as its value may be zero anywhere on the passive attractor of (p, 0). This can be seen from Figures 2 and 4, where the former is a plot of V and the latter shows the system's vectorfield with red lines indicating where V = 0 as shown in equation 11. We see how these lines terminate at our goal state ½6p, 0. This attractor comes about due to our value function being derived from the system's natural dynamics.
By creating a controller that is able to move the system state to these attractor lines from any initial state, it is possible to create a globally stable controller for the upright state. Defining _ V and the control input u We have now met our first condition for a Lyapunov function, which is to make V(q)50. Now, the goal is to make its derivative negative. Intuitively, since our value function is based on the concept of energy, we can approach control of the system by finding the policy that continuously decreases the system's ''energy'' (here value function). We accomplish this task by utilizing a bang-bang controller, and selecting the sign of u such to fulfill _ V40. _ V is defined as: Using sympy, we plug in _ u and € u from equation 8 and find the following equation for _ V: Now that we have an equation for _ V, we wish to find the value of u which satisfies _ V \ 0. We do this by again using sympy, in this case the solve(dV \ 0, u) method, which produces the following inequality: We see that the direction of the inequality sign is dependent on whether the left hand side denominator den is positive or negative. The right hand side is the numerator num, which in this case is just equal to 0. To select the sign of u, we must simply check the denominators sign: u . num when den . 0 u \ num when den \ 0 ð15Þ Figure 3 shows the selection of sign for u according to the above rule. We must further verify that this condition always holds such that we satisfy the conditions of equation 1, and to ensure the controller is true globally for the entire state-space. By simple inspection, we see that this condition is always satisfied as long as ju sat j . 0 which, assuming there is control input, it naturally is. Our control action will therefore always yield _ V40, and we have thereby turned our value function into a globally applicable Lyapunov function.

Creating a proportional controller
Pure bang-bang controllers that switch solely between maximum saturation values can cause chatteringundesirable high frequency control oscillations-which in turn can lead to a lot of wear on mechanical parts, as well as heat loss in electrical power circuits. 22 To circumvent this issue, we make our control input proportional to the Euclidean distance from the goal state (6p, 0): c = 0:75 is the proportional constant and was found experimentally. The control input must still obey the saturation limits, and selection of u is done according to the following rule: ifden . 0 and u e \ u sat Àu e , ifden \ 0 and À u e .Àu sat u sat , ifden . 0 and u e . u sat Àu sat , ifden \ 0 and À u e \Àu sat We implement this in the following Python example function:

Results
We simulated our system in scipy with a number of different initial state configurations and parameters l, m, u sat . Input saturation's were selected such that they were not sufficiently high as to design a fully actuated controller. In all cases our controller efficiently brought the system to its goal upright state. Figures 4 and 5 show the results of four of these simulations with different parameter combinations as seen in Table 1. The former figure being the state-space trajectory, while the latter shows the time trajectories of the system states and the control input. Figure 4 shows how the controller forces the system states to the passive attractor illustrated by the red lines. The saturation values naturally effected the system's response time in reaching the goal, i.e. high saturations allowed the system to reach the goal state faster. Also, large m and l yield slower dynamics. The time it took to get to the goal can be seen in Figure 5, and accordingly we see in Figure 4 that the simulations with low u sat need to swing far more times back and fourth in order to gain enough momentum to invert the pendulum. Either way, the resulting controller efficiently utilizes momentum to move the system from any initial state to the upright equilibrium in a globally stable manner.

Comparing proportional control vs without
In Figure 6, we have performed the same simulation as in Figure 5, but without using the proportional part of the controller as in equation 17. As we can see, pure bang-bang control leads to considerable chattering which is alleviated with our proportional controller. Especially when we get close to the goal state, the pure bang-bang controller uses considerably more force than necessary to stabilize the inverted pendulum. This leads to constant chattering at this point

Conclusion
We have here designed a proportional bang-bang control strategy which selects the sign of its control input by evaluating a modified energy derived value function.  Table 1. The horizontal axes represent u, and the vertical axes _ u. The blue lines are the trajectories, all ending up in the upright pendulum state ½u, _ u = ½6p, 0. The arrows display the system's vectorfield, while the red lines (defined in equation 11) are plotted to show the system's unforced goal state attractor lines which terminate at the upright state. These lines also corresponds to V = 0, hence the controller pushes the states toward the attractor lines in order to utilize the system's natural dynamics. The green vertical lines are situated at u = 6p.
We have proved the conditions that need to be met by our saturated controller in order to make this value function a Lyapunov function as defined in section Lyapunov function's. This was done by ensuring sufficient input torque as to satisfy the inequality 15. This also proved the controller to be globally applicable, since this condition is always satisfied as long as we have an u sat . 0. The control strategy is furthermore asymptotically stable as we are either decreasing the Lyapunov function, or in the case where this function is zero but not yet at goal state, all trajectories tend toward the unstable equilibrium. We showed this by the way the controller forces the system states to the passive attractor lines which terminate at state ½6p, 0. Finally, we demonstrated the need for proportional control in order to alleviate chattering. The result of all this is a novel globally stable control strategy for an underactuated system, without requiring switching between multiple control strategies. The results from testing showed fast system response and good overall performance for any initial condition and parameter combination.  Table 1. The top plots are the state-time trajectories. We see that u ends up at 6p (upright state) and _ u at 0 as desired. The bottom plots show the control input scaled depending on the input saturation. Compare these results with Figure 6 and we find that the proportional controller removes chattering in most cases.   Table 1. The top plots are the state-time trajectories. We see that u ends up at 6p (upright state) and _ u at 0 as desired. The bottom plots show the control input scaled depending on the input saturation. Without proportional control we find excessive chattering.