You are on page 1of 13

See

discussions, stats, and author profiles for this publication at: https://www.researchgate.net/publication/313975571

Inverted Pendulum: A system with


innumerable applications

Conference Paper March 2017

CITATIONS READS

0 509

2 authors:

Ioannis Kafetzis Lazaros Moysis


Aristotle University of Thessaloniki Aristotle University of Thessaloniki
10 PUBLICATIONS 10 CITATIONS 32 PUBLICATIONS 21 CITATIONS

SEE PROFILE SEE PROFILE

All content following this page was uploaded by Lazaros Moysis on 24 February 2017.

The user has requested enhancement of the downloaded file.


Inverted Pendulum: A system with innumerable applications

Ioannis Kafetzis, Lazaros Moysis


School of Mathematical Sciences, Aristotle University of Thessaloniki, Thessaloniki, Greece,
54124

Abstract
The inverted pendulum is one of the fundamental problems in the theory of systems and control, due to
its theoretical value, along with its practical applications. The first step in this work is to determine the
equations of motion for the inverted pendulum, using the Euler-Lagrange equations. The next step is to
find a linearized model that approximates the original nonlinear systems behavior around the
equilibrium located on the upright vertical position. The behavior of the linearized system is simulated
using Matlab. The final step is the computation of an optimal control law for the linearized system,
using the Linear Quadratic Regulator method.

1. Introduction
Automatic control is a branch of mathematics and engineering that studies the
behavior of systems, both natural and artificial, and the manipulation of
certain parameters in order to force the system to have a desired behavior.
Control systems are found everywhere in the world around us; in nature,
everyday life and industry. Some very common examples include the human
body that performs a series of functions, both conscious and unconscious,
throughout its interactions with its surroundings. Another example is driving
a car, where the control is applied through the driver who is the one affecting
the systems inputs, which are the speed and direction, aiming for a safe drive.
Also, in every industrial facility each part of the production line functions
under the supervision of digital controllers that ensure that each engine works
properly according to specific control and design specifications [5].
One of the fundamental engineering problems is the inverted pendulum
[1,2,4,6-8,12,15]. For the inverted pendulum problem shown in Figure 1 the
goal is to determine a control law, that is a suitable input, such that the cart
stabilizes the rod in the upright vertical position. The next goal, after
balancing the rod, is to render the cart able to move while keeping the rod in
the upright vertical position. The importance of this system arises both from
its theoretical and practical applications.
The theoretical value of the inverted pendulum comes from the fact that it
is a nonlinear system, meaning that its equations of motion are nonlinear
differential equations. This makes the computation of an appropriate control
law a difficult task. Furthermore, the model can be simplified, under certain
circumstances, into a linear system around the equilibrium located on the

9th International Week Dedicated to Maths. Thessaloniki, Greece, March 2017.


upright vertical position, making it is possible to apply linear system methods
in order to balance it. This flexibility makes this system a great example for
teaching and studying both linear and nonlinear courses, since many different
theories and methods can be presented through it.
The numerous practical applications of the inverted pendulum make its
study even more interesting and important. In robotics, balancing systems are
developed using inverted pendulums. These find application in transport
machines that need to balance objects, in systems that support walking for
patients, in robots that are used in domestic and industrial use and in object
transport using drones [7]. Even large scale constructions such as buildings
are modeled as inverted pendulums [1]. Finally, one of the most famous
applications of the inverted pendulum that is commercially available is the
Segway [4,6].
The above applications along with many more render the inverted
pendulum a system of great importance for engineers. This is the main reason
why the inverted pendulum is chosen frequently for testing new control
methods [2-4,8,9,12,13]. There exist a great number of methods used in
controlling the inverted pendulum. These methods include optimal control,
PID control, fuzzy control, control through neural networks, bang-bang
control, predictive control or even hybrid methods that are combinations of
the methods stated above. In addition, since the construction of such a model
in a university laboratory is relatively easy and cheap, many universities
afford the necessary equipment for testing the above methods in real time,
making it easier for students to engage in the problem. Overall, it can be seen
that the inverted pendulum systems is a problem that is highly applicable in
everyday applications.
The rest of this work is structured as follows. In Section 2, the equations
of motion for the inverted pendulum are presented. In Section 3 the system is
linearized around the equilibrium located on the upright vertical position. In
Section 4, Matlab is used to obtain simulations for the systems behavior. In
Section 5 some extensions that arise from this problem are discussed and
Section 6 concludes this paper.

2. Modeling the Inverted Pendulum


Consider the system consisting of a cart with a rod placed on its center as
shown in Figure 1.
Figure 1: The inverted pendulum.

This system consists of two bodies, the cart of mass 0 and the rod of mass
1 and length 1 . We denote by 0 the distance of the carts center from the
wall located on the left, by 1 the angle of deviation of the rod from the
vertical axis and by the force applied on the cart. Moreover, denote by the
moment of inertia of the rod with respect to its center of mass, located in the
middle of the rod. The gravitational constant is denoted by . Finally, we
make the assumption that there is no friction between the cart and the floor or
the cart and the rod.
Our goal is to determine the equations that describe the systems motion.
The method to obtain these equations is not unique. In this paper the equations
of motion are obtained using Lagrange Equations [3,8,9,13]. Define the
Lagrangian function as the difference of the systems kinetic and potential
energy. The systems kinetic energy equals the sum of the kinetic energy
for each of the systems two bodies, the cart and the rod. The systems
potential energy is the sum of the potential energy of the cart and the rod.
The level of the cart is considered the zero potential energy level for the
system. Hence:
= (1)
Denoting by 0 , 0 , and 1 , 1 the kinetic and potential energy of the cart and
the rod respectively, we obtain
= (0 + 1 ) (0 + 1 ). (2)
Applying the basic laws of physics leads to the formulas for the kinetic
and potential energy for each of the systems bodies as follows:
1
0 = 2 0 0 ; 0 = 0 (3)
2 2
1 1
1 = 1 [(0 + 1 cos(1 )) + ( 1 sin(1 )) ] + 1
2 2 2 2
1 2 2 2 2 2 1 2
= 1 [0 + 2 0 1 cos(1 ) + ( ) 1 2 (1 ) + ( ) 1 2 (1 )] + 1
2 2 2 2 2
1 2 2 2 1 2
= 1 [0 + 2 0 1 cos 1 + ( ) 1 ] + 1
( )
2 2 2 2
1 2 1 2
1 = 1 0 + 1 0 1 cos(1 ) + [1 + ] 1 (4)
2 2 2 2

1 = 1 (1 ) (5)
2
Substituting the above into the Lagrangian (2) gives:
1 2
= 2 (0 + 1 )0 + 1 2 0 1 cos(1 )+
2
(6)
1
+ 2 [1 2 + ] 1 + 1 2 (1 )

Define the vector = [ 0 ] and the matrix = [ ]. Then the Lagrange
1 0
equations can be written as:

( ) = (7)

Calculating the partial derivatives using the chain rule gives:

=0
0

= (0 + 1 )0 + 1 1 (1 )
0 2
2
( ) = (0 + 1 )0 + 1 1 (1 ) 1 1 (1 )
0 2 2

= 1 0 1 (1 ) 1 (1 )
1 2 2
2

= 1 0 (1 ) + [1 ( ) + ] 1
1 2 2
2
( ) = 1 0 (1 ) 1 0 1 sin(0 ) + [1 ( ) + ] 1
1 2 2 2
Substituting these quantities in (7) leads to:
2 (8)
= (0 + 1 )0 + 1 1 (1 ) 1 1 (1 )
2 2
2
0 = 1 0 (1 ) [1 ( ) + ] 1 + 1 (1 ) (9)
2 2 2
Equations (8) and (9) describe the systems motion. For the sake of simplicity,
these equations can be written in matrix form using the column vector
defined above. Thus, (8)-(9) can be written equivalently as
() + ( , ) + () = (10)
where the matrices (), ( , ), () and () are time varying and

0 + 1 1 cos(1 )
2
() = , (, ) = [0 1 2 1 cos(1 )]
2
1 cos(1 ) 1 ( ) + 0 0
[ 2 2 ]
(11)
0
1
() = ( ), =[ ]
1 sin(1 ) 0
2
and the moment of inertia equals to = 1 2112, see [3]. Observe that the
system is strongly nonlinear since there exist products of different states and
states appear as arguments of trigonometric functions. This makes the system
hard to control.
Observe now that the matrix () is invertible for every , since its
determinant is always positive for all . Indeed, the determinant is
2 2
(()) = 1 2 ( ) [1 cos 2 (1 )] + (0 + 1 ) + 0 1 ( ) > 0
2 2
The next goal, after finding the equations of motion, is to define an
equivalent system that consists of first order differential equations. Such
systems are called state space models. Define the column vector
= [
] = [0 1 0 1 ] (12)
Using the model description (1) and multiplying from the left by the inverse
of (), equation (10) is written as
0 2 0 0
= [ ] + [ 1 ] + [ 1 ] (13)
0 1
In (13) the matrices are denoted only by name without mentioning the
variables on which they depend. This was made for the sake of brevity, but
the dependence of each matrix form the variables still holds as before.
3. Linearization
The equilibrium points of a dynamical system described by = () are
defined as the points 0 for which the derivative is equal to zero, that is
(0 ) = 0. So we are looking for points for which the states of the system do
not change. Equilibrium points are classified as stable or unstable, depending
on how the system behaves when it starts from 0 or is close to 0 . The
inverted pendulum system has two equilibria, one stable and one unstable and
their difference is easy to understand.
The first equilibrium is the point of complete rest, where the pendulum is
lowered down, on an angle 1 = 180. This is an asymptotically stable
equilibrium, because starting from any initial condition, the rod will always
return to its resting lowered down state. If for example we were to knock the
pendulum rod with our hands, the system will return to rest after a small
oscillation. Consequently, no input is required from any outside source to
drive the system to this equilibrium. On the other hand, the second
equilibrium corresponds to the upright vertical position, with an angle 1 =
0. At this point, the pendulum is balanced, but the smallest disturbance will
cause it to diverge from this state, oscillate and end up resting at the lowered
position. Therefore, for the second equilibrium point, it is clear that there is a
need to apply a constant control law in order to maintain the pendulum in the
upright position.
The system can be linearized around its upright equilibrium. This means
that it is possible to obtain a simplified linear version of the system that
describes its behavior around this point. Thus, we can work with this
simplified version in order to design a control law, which when applied to the
system, will be able to keep it balanced on the upright position. For the
nonlinear system described by = (, ), the upright equilibrium is the
point
= [0 1 0 1 ] = [0 0 0 0] (14)
For small deviations from this point, the angle 1 is very small, so we can
2
make the approximations sin(1 ) = 1 , cos(1 ) = 1 and 1 = 0, see [13].
Under these approximations the system becomes

0 + 1 1 0 0
2
[ ] + [ ] =
2 0 1
1 1 ( ) + 2
2 2

= 1 + 1
Or equivalently in state space form
= + (15)
where
0 0 1 0 0
0 0 0 1 0
2 1 2 4I + 2 1
= 0 2 + 4I( + ) 0 0 , = 2 + 4I( + )
0 1 0 1 0 1 0 1
21 (0 + 1 ) 21
0 2 0 0
[ 0 1 + 4I(0 + 1 ) ] [ 2 0 1 + 4I(0 + 1 )]

This system is linear and the matrices A and B are time invariant.

4. Simulation
It is easy to simulate the above linear model in Matlab, a programming
software with a wide range of functions created for simulating control
systems [5,10,11]. In the code provided below, we define the linearized
system (15) as a state space system, where the output and states are the same,
() = (). Subsequently, using the linear quadratic regulator method, we
determine a feedback control law of the form () = (), that maintains
the pendulum in the upright position. This LQR method is based on
minimizing the cost function

() = () () + () () (16)
0

where and are symmetric, positive semidefinite and positive definite


weight matrices respectively (usually diagonal), that are used to assign cost
in the states for which we have the strictest requirements. In our example,
since we do not want the cart to move far away on the x-axis and because we
do not want large deviations of the rod from its equilibrium (because this will
lead to a loss of linearity), we will choose larger values for the corresponding
entries of the matrix . The entries of corresponding to the cart velocity
and the angular velocity are set to zero, since we assume they do not pose any
limitations for this particular example. As initial conditions we choose the
position and velocity of the cart to be zero, a 5 angle for the rod and an
angular velocity of 5 . Simulation results can be seen on Figure 2. We
can see that for different values of the matrix the solution of the system is
significantly different. Putting a higher cost on the rod displacement, we
obtain smaller oscillations and the system returns to the equilibrium faster.
% Linear model for inverted pendulum
m0=1.5; m1=0.5; L =0.5; I=m1*L^2/12;g=10;
D0=[m0+m1, m1*L/2; m1*L/2, m1*(L/2)^2+I];
H=[1;0];
A=[zeros(2),eye(2);0,g*L^2*m1^2/(L^2*m0*m1+4*I*(m0+m1)),0,0;0
,-2*g*L*m1*(m0+m1)/(L^2*m0*m1+4*I*(m0+m1)),0,0];
B=[0;0;(4*I+L^2*m1)/(L^2*m0*m1+4*I*(m0+m1));-
(2*L*m1)/(L^2*m0*m1+4*I*(m0+m1))];
C=eye(4);
pend=ss(A,B,C,0) % the pendulum state space system
R=1; Q=diag([1,20,0,0]); %different values can be chosen
k=lqr(pend,Q,R); % compute the feedback law u=-K*x
pendnew=ss(A-B*k,B,C,0) % define the new system
[y,t,x]= initial(pendnew,[0;deg2rad(5);0;deg2rad(5)],10);
y(:,2)=rad2deg(y(:,2)); %transform from rad to degrees.
y(:,4)=rad2deg(y(:,4));

for i=1:4
subplot(2,2,i)
plot(t,y(:,i))
end

Figure 2: LQR in the linearized model with matrices Q=diag[1,2,0,0] and Q=diag[1,20,0,0].

5. Model variations
There are many variations of the inverted pendulum model that arise from
different applications and each one is of special interest. Their modeling
follows similar steps with the ones presented above. Nonetheless, in each
case additional parameters or constraints are added that must be taken into
account. Some variations are given in Figure 3.
Notable examples include the double inverted pendulum, used in modeling
human balance [12, 14-17]. In this model, on the end point of the first rod, a
second one is placed and again the aim is the balance of the system. A
specialized version of this model is when the joints between the 1st rod and
the cart and the 1st and 2nd rods can be locked to a fixed angle, allowing for
the system to have multiple equilibria, as seen in Figure 4. This is useful in
modeling the human foot in a study to construct applications for gait support
[14-17]. Another interesting example is a system where two rods are mounted
on the same cart on two different points. A similar problem is the study of all
the above systems for the case when the cart is on an inclined surface. Lastly,
another special case is the rotational inverted pendulum. In this case the
pendulum is placed on a rotating base.
In all of the above examples, it is possible for the states of the system to
be subjected to constraints. For example, the cart may have limited space to
move, or the rod may not be allowed to fall below a specific level. In each
case, these constraints impose radical changes in the computation of the
optimal solution.

Figure 3: Inverted pendulum variations.


Figure 4: Gait system.

6. Conclusions
In conclusion, it is clear that the inverted pendulum is a system with many
variations that render it a fundamental control problem. Apart from its
variations, its analysis and control can be studied using a plethora of different
techniques, as mentioned in the introduction. The system can be controlled
using various optimization techniques. Predictive control techniques can be
applied, which aim at determining a series of future control actions that will
balance the system. Adaptive control techniques can also be used. Such
methods are useful when certain parameters of the system change during its
simulation. Such methods are used for example when the cart goes through a
different terrain and the friction coefficient changes or when an object is
suddenly placed on the end of the rod, changing its center of gravity. Overall,
the inverted pendulum is a system that helps engineers test the efficacy of
new control methods and for that matter it works as a bridge between
theoretical approaches and their application to real life problems.

References
[1] Anh, N. D., Matsuhisa, H., Viet, L. D., & Yasuda, M. (2007).
Vibration control of an inverted pendulum type structure by
passive massspring-pendulum dynamic vibration
absorber. Journal of Sound and Vibration, 307(1), 187-201.
[2] Anderson, C. W. (1989). Learning to control an inverted pendulum
using neural networks. IEEE Control Systems Magazine, 9(3), 31-37.
[3] Bogdanov, A. (2004). Optimal control of a double inverted pendulum
on a cart. CSEE, OGI School of Science and Engineering, OHSU, Tech.
Rep. CSE-04-006.
[4] Boubaker, O. (2013). The inverted pendulum benchmark in nonlinear
control theory: a survey. International Journal of Advanced Robotic
Systems, 10.
[5] Dorf, R. C., & Bishop, R. H. (2011). Modern control systems (12th Ed).
Pearson.
[6] Grasser, F., D'arrigo, A., Colombi, S., & Rufer, A. C. (2002). JOE: a
mobile, inverted pendulum. IEEE Transactions on industrial
electronics, 49(1), 107-114.
[7] Hehn, M., & D'Andrea, R. (2011, May). A flying inverted pendulum.
In Robotics and Automation (ICRA), 2011 IEEE International
Conference on (pp. 763-770). IEEE.
[8] Jadlovsk, S., & Sarnovsk, J. (2013). Modelling of classical and rotary
inverted pendulum systemsa generalized approach. Journal of
Electrical Engineering, 64(1), 12-19.
[9] Jadlovsk, S., & Sarnovsk, J. (2012, January). Classical double
inverted pendulumA complex overview of a system. In Applied
Machine Intelligence and Informatics (SAMI), 2012 IEEE 10th
International Symposium on (pp. 103-108). IEEE.
[10] Moysis, L., Azar, A. T., Kafetzis, I., Tsiaousis, M., & Charalampidis,
N. (2017). Introduction to Control Systems Design Using Matlab.
International Journal of System Dynamics Applications (IJSDA). (to
appear).
[11] Moysis, L., Tsiaousis, M., Charalampidis, N., Eliadou, M., &
Kafetzis, I. (2015). An Introduction to Control Theory Applications
with Matlab. Retrieved from http://users.auth.gr/lazarosm/ .
[12] Pathak, K., Franch, J., & Agrawal, S. K. (2005). Velocity and position
control of a wheeled inverted pendulum by partial feedback
linearization. IEEE Transactions on robotics, 21(3), 505-513.
[13] Qian, Q., Dongmei, D., Feng, L., & Yongchuan, T. (2011, August).
Stabilization of the double inverted pendulum based on discrete-time
model predictive control. In Automation and Logistics (ICAL), 2011
IEEE International Conference on (pp. 243-247). IEEE.
[14] Sasagawa, S., Shinya, M., & Nakazawa, K. (2014). Interjoint dynamic
interaction during constrained human quiet standing examined by
induced acceleration analysis. Journal of neurophysiology, 111(2),
313-322.
[15] Sugihara, T., Nakamura, Y., & Inoue, H. (2002). Real-time humanoid
motion generation through ZMP manipulation based on inverted
pendulum control. In Robotics and Automation, 2002. Proceedings.
ICRA'02. IEEE International Conference on (Vol. 2, pp. 1404-1409).
IEEE.
[16] van der Spek, J. H., Veltink, P. H., Hermens, H. J., Koopman, B. F., &
Boom, H. B. (2003). A model-based approach to stabilizing crutch
supported paraplegic standing by artificial hip joint stiffness. IEEE
transactions on neural systems and rehabilitation engineering, 11(4),
443-451.
[17] Winter, D. A. (1995). Human balance and posture control during
standing and walking. Gait & posture, 3(4), 193-214.

View publication stats

You might also like