The purpose of this page is to show the derivation of the linearized dynamics for the highly non-linear cart-pole system and to propose an algorithm to calculate the optimal balancing input using a LQR controller. This system is classically studied in non-linear controls.
A LQR controller is used to stabilize the cart-pole system around its unstable equilibrium with the cart at the origin and the pole in its upright position.The cart-pole is described by the following dynamics:
This may be put into standard form with :
Where the above matrices are defined as:
The linearized dynamics are found by performing a Taylor expansion around the fixed point of interest:
With the linearized dynamics a stable LQR controller may be calculated using the cost function:
The optimal solution to this cost function may be found using techniques in dynamic programming and is of the form:
The following code may be used in MATLAB to converge on the optimal gain matrix:
For the given system, the optimal gain matrix can be found to be:
With the Qand R weights as follows:
And the optimal control input can be calculated.
This policy can be empirically shown to balance the pendulum at its upright position: