Java Printing

Simple Inverted Pendulum Cart Dynamics
Lagrangian Development
by Jaspen Patenaude
Lagrange
We will start by writing an expression for the system's total kinetic energy (T) and for the system's
potential energy (V).
Kinetic Energy
T
1
M xdot2
2 c
thetadot2
1
M xdot2
2 c
1
M
2 p
xdot
1
M xdot
2 p
2
thetadot l
cos theta
2
2
1
thetadot l cos
2
1
Mp
2
thetadot l
sin theta
2
1
M thetadot2 l2 sin
8 p
2
2
1
2
1
M l2 thetadot2
24 p
1
Mp l2
12
(1)
Potential Energy
V
Mp g l
2
cos theta
1
M g l cos
2 p
The Lagrangian is defined as L
1
L :=
M xdot2
2 c
1
M xdot
2 p
T
1
thetadot l cos
2
(2)
V
2
1
M thetadot2 l2 sin
8 p
2
1
M l2 thetadot2
24 p
1
M g l cos
2 p
1
1
M xdot2
M
2 c
2 p
1
M g l cos
2 p
2
1
thetadot l cos
2
xdot
1
M thetadot2 l2 sin
8 p
Using the standard holonomic form of Lagrange's equation, d
dL
d qdot
dt
qeneralized coordinate vector
coordinate.
x
T
c
1
M l2 thetadot2
24 p
2
(3)
dL
= Qi where q is the
dq
i
and Qi is the generalized force corresponding to the generalized
Pendulum Equation of Motion
Evaluating the Lagrange equation's first term for thetadot gives us
simplify diff L, thetadot
1
M l
6 p
simplify diff
1
M l
6 p
3 cos
1
M l 3 sin
6 p
t
xdot t
d
dt
t
3 cos
t
xdot
(4)
2 thetadot l
2 thetadot t l , t
xdot t
3 cos
d
xdot t
dt
t
d
thetadot t
dt
2
(5)
l
while the second gives
simplify diff L, theta
1
M l sin
2 p
thetadot xdot
(6)
g
Combining the two terms and realizing that the generalized force in the theta direction is 0, we get
1
M l 3 sin
6 p
expand simplify
1
M l sin
2 P
1
l Mp sin
t
2
1
l MP sin
2
t
d
dt
t
d
dt
t
t
thetadot t xdot t
xdot t
g
3 cos
xdot t
2
d
thetadot t
dt
l
=0
1
l Mp cos
t
2
1
thetadot t xdot t
l MP sin
2
t
d
xdot t
dt
t
1
M
3 p
d
xdot t
dt
t
d
thetadot t
dt
l2
(7)
g=0
by simplification this can be written as
1
M l cos
2 p
t
d2
x t
dt2
1
d2
M l2
theta t
3 p dt2
1
M l sin
2 p
t
g =0
Cart Equation of Motion
Evaluating the Lagrange equation's first term for xdot gives us
simplify diff L, xdot
Mc xdot
simplify diff Mc xdot t
Mp xdot t
Mp xdot
1
M thetadot l cos
2 p
1
M thetadot t l cos
2 p
t
,t
(8)
Mc
1
M
2 p
d
d
xdot t
Mp
xdot t
dt
dt
1
M thetadot t l sin
t
2 p
d
dt
d
thetadot t
dt
l cos
(9)
t
t
while the second gives:
simplify diff L, x
(10)
0
Combining the two terms and realizing that the generalized force in the theta direction is F, we get
d
xdot t
dt
expand simplify M
c
Mc
p
1
M thetadot t l sin
t
2 p
d
d
xdot t
Mp
xdot t
dt
dt
1
M thetadot t l sin
t
2 p
1
M
2 p
d
xdot t
dt
M
d
dt
t
l cos
t
=F
1
M
2 p
d
dt
d
thetadot t
dt
d
thetadot t
dt
t
l cos
(11)
t
=F
by simplification this can be written as
Mc
d2
x t
dt2 c
Mp
1
M l cos
2 p
d2
dt2
t
1
Mp l sin
2
t
2
d
dt
t
t
=F
SUMMARY
Governing equation for the pendulum motion
0=
d2
dt2
1
M l2
3 p
1
M l sin
2 p
t
t
1
M l cos
2 p
g
d2
x t
dt2 c
t
Governing equation for the cart motion
F = Mc
d2
x t
dt2 c
Mp
1
M l sin
2 p
2
d
dt
t
t
1
M l cos
2 p
t
d2
dt2
t
The governing equations for the cart and pendulum can also be expressed in matrix form as
M
c
1
M l cos
2 p
M
p
1
M l cos
2 p
t
0
1
M l sin
2 p
dt2
F
t
g
=
dt2
d2
1
M l2
3 p
t
d2
0
x t
c
t
0
0
1
M l sin
2 p
t
0
d
dt
t
d
x t
dt c
d
dt
t