Linear Quadratic Regulator Control of an Inverted Pendulum with Friction
Requires a Wolfram Notebook System
Interact on desktop, mobile and cloud with the free Wolfram Player or other Wolfram Language products.
The linear quadratic regulator (LQR) method is used to generate a control force that brings an inverted pendulum from an initial condition back to the upright position in an optimal way. The state space is used to represent the dynamics of the system. Static and Coulomb friction forces act as external disturbances. Coulomb friction causes an oscillation of the cart position around the equilibrium position (). When only viscous friction is present, LQR brings the pendulum to the upright position since viscous friction is included in the state matrix, while Coulomb friction is included in neither the nor the matrix. A standard friction model is used and is described below. The eigenvalues of the closed-loop state matrix (where is the gain vector generated by LQR) are all located in the left side of the complex plane, showing that the resulting system is stable.
Contributed by: Nasser M. Abbasi (May 2012)
Open content licensed under CC BY-NC-SA
Let be the mass of the cart, the mass of the pendulum bob, and the length of the pendulum. The kinetic energy of the system is and the potential energy is . Hence the Lagrangian is and the equation of motion for the cart is , where is the applied force and is the force due to friction. The equation of motion for the bob mass is .
The friction model used is the following: let be the static, Coulomb (kinetic), and viscous friction coefficients, respectively. Let be the normal force, which is . When the speed of the cart is zero and then the friction force is , and when , then the friction force is . When the speed of the cart is not zero, then . The value of is normally less than . You can use the sliders to change the values of these coefficients.
The applied force is found by using the LQR (linear quadratic regulator) method. This force is applied in order to bring the cart to the position with the pendulum in the upright position.
The table at the top of the display shows simulation information. The field labeled "" is the applied force (the state feedback control force found by LQR), the field labeled is the Coulomb friction force, and the field labeled is viscous force, with all units in Newtons. The sign indicates the direction of the force at that moment of the simulation.
You can adjust the weights used by LQR by adjusting the slides that represent the entries in the matrix diagonal. The documentation for Mathematica's built-in function LQRegulatorGains (link below) explains more about the Q matrix.
You can change the initial angle position of the inverted pendulum and the initial cart position using the sliders.
For more information on the derivation of the equations of motion, see the author's report on inverted pendulum.
 R. Soutas-Little and D. Inman, Engineering Mechanics Dynamic, New Jersey, Prentice–Hall, 1999.
 D. Guida, F. Nilvetti, and C. M. Pappalardo, "Dry Friction of Bearings on Dynamics and Control of an Inverted Pendulum," Journal of Achievements in Materials and Manufacturing Engineering, 38(1), 2010 pp. 80–94.
 S. Campbell, S. Crawford, and K. Morris, "Friction and the Inverted Pendulum Stabilization Problem," Journal of Dynamic Systems, Measurement, and Control, 130(5), 2008.