source code in HTML
source code in PDF

LQR Control of inverted pendulum on moving cart with friction

Nasser M. Abbasi

April 16, 2012 compiled on — Wednesday July 06, 2016 at 08:28 AM
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 x′(t) = Ax (t) + Bu (t)  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 x = 0  .

When only viscous friction is present, LQR brings the pendulum to the upright position since viscous friction is included in the A  state matrix, while Coulomb friction is included in neither the A  nor the B  matrix.

A standard friction model is used and is described below. The eigenvalues of the closed loop state matrix A − BK  (where K  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.