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
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.
 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
(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