Académique Documents
Professionnel Documents
Culture Documents
Abstract
The inverted pendulum is frequently used to benchmark control strategies.
This paper applies the solution of
Euler-Lagrange equations supplemented by Pontryagin's Principle in order to optimally swing up an inverted
pendulum on a cart in arbitrarily fixed final time.
The solution of the two-point boundary value problem generated by
Euler-Lagrange equation is then solved numerically, and thus the optimal trajectory is found.
The advantage of using
this method is that it is a direct approach to find an optimal trajectory for a given dynamical system.
1. Introduction
The inverted pendulum is one of the most commonly studied systems in the control area. It is quite
popular because the system is an excellent test bed for learning and testing various control techniques. It is
an under-actuated mechanical system and inherently open loop unstable with highly non-linear dynamics.
The applications range of the inverted pendulum is wide: from robotics to space rocket guidance
systems. The inverted pendulum can be used to model the yaw and the pitch of a rocket when center of drag
is before the center of gravity causing aerodynamic instability. Originally, these systems were used to
illustrate ideas in linear control theory such as the control of linear unstable systems. Their inherent nonlinear nature helped them to maintain their usefulness along the years and they are now used to illustrate
several ideas emerging in the field of modern non-linear control [1].
In this paper, the swing up of a single pendulum in a cart and its stabilization in the unstable
equilibrium position is addressed: the swing up is done by finding an optimal trajectory that minimizes the
control effort required to bring the pendulum from the downward stable equilibrium position to the upward
unstable equilibrium position. The trajectory is based on the numerical solution of Euler-Lagrange equations,
supplemented by Pontryagin's Principle, a necessary condition for an optimal control law in a non-linear
system [2]. The solution obtained for the control law has the drawback of being open loop and therefore is
very sensitive to modeling errors and noise, so it should be restricted to situations where the modeled system
is very close to the real system.
After the pendulum is successfully brought to the upward position, it is stabilized by a linear
quadratic regulator, which gives a full state feedback optimal control for the linearized system around the
equilibrium position [3].
2. Inverted Pendulum System
The inverted pendulum on a cart system is graphically depicted on figure 2.1.
Figure (2.1)
The equations of motion for the system were derived using Lagrange equations
d L L D
+
=Q i (2.1)
dt q i qi q i
where L=T-V is the Lagrangian, D is the dissipation function and Q is a vector of generalized forces acting
on the direction of the generalized coordinates not accounted for in the formulation of the kinetic energy T,
potential energy V and dissipation function D. The kinetic and potential energy is given by the sum of
energies from the individual components (the cart and the pendulum), which are written in respect to the
coordinates x and , representing the displacement of the cart and the angle of the pendulum in respect
to the vertical axis, respectively:
V 0 =0
V 1=m g l cos
V =V 0+V 1
1
T 0= m0 x 2
2
1
1
T 1= m1 [( x +l cos )2 +(l sin )2 ]+ I 2 =
2
2
1
1
= m1 x 2 + (m1 l 2+ I 1 ) 2+m1 l x cos
2
2
T =T 0+T 1
D= D0+ D1
1
D 0= c0 x 2
2
1
D1= c 1 2
2
where
m0
m1
I
c0
c1
g
l
It is assumed that the only dissipative forces are due to the viscous damping c 0 and c1. Moreover, the
center of mass for the pendulum is considered to coincide with the geometrical center, and the mass is
uniformly distributed along its dimension.
From the Lagrange scalar equations, with respect to x and ,
d L L D
+
=u (t)
dt x x x
(2.2)
d L L D
+
=0
dt
(2.3)
the non-linear equations of motion for the system are obtained:
(2.5)
Those equations can then be rewritten as a system of first order differential equations:
x 3=
x4 =
x1=x 3
x 2=x 4
2
2
3 g l m1 cos x 2 sin x 2+4 l u4 c0 l x 3+6 c 1 cos x 2 x 4+2 l m1 sin x 2 x 4
2
(2.7)
The equations are linearized around the unstable equilibrium position x 1=0, x 2=0 which will be
used for obtaining a linear feedback control law that renders the system stable at that position:
x = Ax+Bu
(2.8)
with:
( f ( x)+g (x )u (t))
x
( f ( x)+g (x )u (t)) (2.9)
B=
u
A=
3. Control equations
The control of the pendulum is divided in two parts: first, the control effort required to bring it from
the downward position to the upward position, which can be obtained using Euler-Lagrange equations
supplemented by Pontryagrins Principle [3], acts on the system; second, when the position of the pendulum
is close enough to the upward position, a feedback control law stabilizes the pendulum by means of a linear
quadratic regulator.
3.1. Swing up Using Trajectory Optimization
In order to obtain a control action that generates an optimal trajectory in a specified time, the
following finite horizon optimization problem is considered:
tf
(3.1)
x = f ( x)+ g (x ) u(t ).
where
now introduce H, referred to as the Hamiltonian, also called the Pontryagin H function [3]:
(3.3)
H (3.4)
T
(t)=
x
H
=0 (3.5)
u
subject to the boundary conditions:
x (0)= x 0 (3.6a)
T (t f )=
[ x ]
tf
(3.6b)
x (t f ) ,
(t , x ( t))= T ( x (t )) (3.6c)
with
which is accounted in the weight function by using an algebraic Lagrange multiplier . The function
(t) is called costate, and must be solved simultaneously with the equations of the dynamic system. The
control action u *(t ) is given by:
The differential equations (3.2) and (3.3) together with the optimality condition given by (3.4) and
the boundary conditions given by (3.5) constitute a non-linear two-point boundary value problem. In contrast
with an initial value problem (IVP), a two-point boundary value problem (TVP) might have no solution or
multiple solutions [4]. The most common approaches to solve it numerically are by using a Shooting
Method, a Finite Difference Method or Collocation Method. Unfortunately, both methods may fail to
converge, even if if there is a solution. Due to these characteristics, solving a TVP is considerably more
difficult than solving a IVP.
Unfortunately, the obtained control action cannot take into account eventual disturbances in the
system and deviations from the model.
3.2 Stabilization of the Pendulum Using Linear Quadratic Regulator
Consider the following linear time-invariant system:
J=
1 T
[ x ( t)Qx (t)+uT (t ) R u (t)]dt (3.9)
2
0
We have to determine the optimal control feedback law u (t) *=k * x (t) that minimizes J.
From optimal control theory, the optimal control law that minimizes equation (functional) is given by [3]:
1 T
u *(t )=R B Px * (t) (3.10)
where P, the nn constant, positive definite, symmetric matrix, is the solution of the nonlinear, matrix
algebraic Riccati equation (ARE) :
1
J * = x * T ( t) Pbx * (t)
(3.13)
2
x (0)=[0 pi 0 0]
(t f )=[0 0 0]T
x 2 (t f )=0
The figure 5.1 shows the numerical solution obtained for u(t) with t f =1.5 seconds. Figure 5.2
and figure 5.3 shows the comparison between simulated results and the experimental results. In figure 5.2 we
can see that the results obtained were very close to each other. This can be attributed to the fact that the
choice of time for the swing up was short enough to reduce the effects of uncertainties in the system that
could significantly change the final result. It must noted that those results might not be satisfactorily close for
a open loop controller acting over a larger time span.
Figure 5.1
Figure 5.2
Figure 5.3
6. Conclusions
This paper showed that using Euler-Lagrange equations to obtain a trajectory for a highly non-linear
unstable system like the pendulum in a cart can be viable. It offers the advantage of being a direct approach
to find an optimal trajectory a system, while it has the drawback of being considerably difficult to solve
numerically. It should be also noted that the obtained solution is in open loop form, and thus would require
either a very accurate model of the system or a compensator over the trajectory.
Bibliography
[1] Optimal regulator for the inverted pendulum via EulerLagrange backward integration
Thomas Holzhuter
Automatica 40 (2004) 1613 1620