Underactuated Cart-Pendulum system
Here is the gist of the cart-pendulum system used for the project from the robotics lab of the Cleveland State University, Cleveland, OH, USA

Simulation model for LOR controller using Simulink
Using this Simulink model, real-time friction can be modeled. The interpreter MATLAB function block includes all the physical constants in it and has the control as input. All the initial conditions for the D-H table have been set and the LQR controller gain was tuned successfully.

Switching criteria
In this part, we give slight velocity to the pendulum so the energy pumping controller works and gives energy to the pendulum to reach to equilibrium point. As soon as the pendulum reaches approximately 0.25 radians away from the equilibrium point switch becomes active and switches from the Energy pumping controller to the LQR controller and the pendulum becomes stable around an unstable equilibrium point.

Derived D-H parameters of the Cart-pendulum system
The transition from the zeroth frame to frame 1 is obtained by the linear transition of the Z-axis with a length of q1 and a rotation of the X-axis around negative π/2 degrees. The transition from frame 1 to frame 2 is obtained by rotating the Z-axis around q2 degrees. The q2 = 0 corresponds to the pendulum horizontal and with the free end closest to the motor. The target upright balancing position corresponds to q2 = π/2. Thus, q2 increases clockwise. q1 is positive towards the motor. The zero reference for q1 is unimportant, as it doesn’t appear in the dynamic equations.

Simulation model for Energy injection using Simulink
The LQR controller simulation was modified, updated with appropriate initial conditions, and tuned such that the pendulum oscillates with growing amplitudes while maintaining the control.

Final simulation result of switching from energy pump to LQR
The swing up and switch from energy pumping to LQR involve several steps to balance the pendulum in an upright position and maintain stability. The swing-up phase involves the process of injecting energy into the system to bring the pendulum from a stable hanging position to an upright position. Once the pendulum is swung up, the system can transition from energy pumping to LQR control. The LQR control enables the cart-pendulum system to maintain stability and desired behavior around the upright position. The swing-up and switching to LQR control provide an effective and efficient approach to stabilizing and controlling the cart-pendulum system.

