A COMPLEX OVERVIEW OF THE ROTARY
SINGLE INVERTED PENDULUM SYSTEM
1
ELEKTRO 2012
SINGLE INVERTED PENDULUM SYSTEM
Ing. Slávka JADLOVSKÁ
prof. Ing. Ján SARNOVSKÝ, CSc.
Department of Cybernetics and Artificial Intelligence
Faculty of Electrical Engineering and Informatics
Technical University of Košice
13. 10. 2012
13. 10. 2012
2
Inverted Pendula Systems – a class of mechanicalsystems significant for control theory
I. mathematical modeling and simulation of the rotary inverted pendulum system
▫ automatic derivation of motion equations
▫ open-loop dynamical analysis
13. 10. 2012
3
Main Points of the Presented Problem
II. stabilization of the rotary single inverted pendulum via state-feedback control techniques
▫ automatic linear approximation of the system
▫ state-feedback control with a state estimator
▫ state-feedback control with permanent disturbance compensation
III. conclusion and evaluation of the achieved results
Inverted Pendula Modeling and Control - IPMaC(Simulink block library)
13. 10. 2012
4
simulation models of inverted pendula
state-feedback control
direct-current motor
input/output blocks
demonstrations of the block functionality
direct-current motor
swing-up into the upright position
GUI applications
A.
13. 10. 2012
5
A.Mathematical Modeling and Simulation
of the Rotary Single Inverted Pendulum
A.Inverted Pendula Model Equation Derivator(automatic derivation of motion equations)
13. 10. 2012
6
initiates the process of mathematical model derivation
selection of system type & number of pendulum links
generated motion equations
A.Generalized approach to inverted pendula modeling
13. 10. 2012
7
( ) ( ) ( ) ( )( )Tn tttt θθθ …10=θ
cart/arm position pendula angles
System description:
system of n classical inverted pendula system of n rotary inverted pendula
13. 10. 2012
8
( ) ( ) ( ) ( )ttDtLtLd *Q=∂+∂−
∂
Lagrange equations of the second kind:
( ) ( ) ( ) ( )( )Tn tttt θθθ …10=θ
Vector of generalized coordinates:
A.General procedure of mathematical model derivation for
inverted pendula systems – brief outline
13. 10. 2012
invpenderiv.m
( )( )
( )( )
( )( ) ( )tt
tD
t
tL
t
tL
dt
d *Qθθθ
=∂∂+
∂∂−
∂∂
ɺɺ
MATLAB functions which derive the motion equations for a system with a given number
of pendulum links
rotinvpenderiv.m
( )( ) ( ) ( ) ( )( ) ( ) ( )( ) ( ),t t t t t t t+ + =M θ θ N θ θ θ P θ Vɺɺ ɺ ɺRearrangement into standard minimal ODE
form:
Inverted Pendula Modeling and Control
A.Simulation models of selected inverted pendula systems
(dynamic-masked Simulink library blocks)
13. 10. 2012
9
Inverted Pendula Models
A.Rotary single inverted pendulum system –
scheme and generated mathematical model
13. 10. 2012
10
( ) ( )
( )( )( )
( ) ( ) ( ) ( )
( ) ( )( )( )
( )
22 2 20 1 1 1 1 1 0 1 1 10 1 0 1 1 1 1 0 1 1
0 0
21 11 1 0 1 11 0 1 1 1
1 11 1sin2 sinsin cos
4 24 211
sin2cos82
0
1sin
ml t t ml l t tJ ml ml t ml l tt t
t tml t tml l t J
m gl t
δ θ θ θ θθ θ θ θθ θθ θ δθ
θ
+ −+ + + + −
+ −
ɺ ɺɺɺ ɺ
ɺɺ ɺɺ
( )0
M t = ( )1 1 1
1sin
2m gl tθ
+ −
0=
0 1
0 11 1
0 1
0,5 0,2750,6 0,50,3 0,011458
m kg m kgl m l m
kgs sδ δ− −
= == == =
( )M t
( )1 tθ
( )0 tθrotary single inverted
pendulum systemtorque model
4dfi1dt pendulum angular velocity
3
2fi1 pendulum angle
1fi0 arm angle
dfi0/dtf i1
M
fi1
f i0
dfi0/dt
1M external torque
11
Rotary Single Inverted Pendulum function block
13. 10. 2012
A.Rotary single inverted pendulum system –
library block structure
3dfi0dt arm angular velocity
d2fi0/dt2
dfi1/dt
d2fi1/dt2
Pendulum
dfi1/dt
d2fi/dt2
dfi0/dt
d2fi0/dt2
Arm
pendulum subsystemrotary arm subsystemrotary arm subsystem
Inverted Pendula Modeling and Control
A.Demo Simulations I: Open-loop dynamical analysis for
nonlinear force-torque models of inverted pendula systems
13. 10. 2012
12
A.Rotary single inverted pendulum (torque model) –
open-loop dynamical analysis
13. 10. 2012
13
Scoperad2deg
M external torque
fi0 arm angle
fi1 pendulum angle
Impulse
Scoperad2deg1
Rotary Single Inverted Pendulum
0 2 4 6 8 10 12 14 16 18 200
10
20
30
40
50
60
70
80
90
Simulation time [s]
Arm
ang
le [d
eg]
Rotary Single Inverted Pendulum (Torque Model)Open-loop Analysis - Arm Angle
Arm angle
0 2 4 6 8 10 12 14 16 18 20-300
-250
-200
-150
-100
-50
0
Simulation time [s]
Pen
dulu
m a
ngle
[deg
]
Rotary Single Inverted Pendulum (Torque Model) - Open-loop Analysis - Pendulum Angle
Pendulum angle
A.Simulation model of actuating mechanism (DC motor) for
inverted pendula systems (Simulink library block)
13. 10. 2012
14
Inverted Pendula Motors
Inverted Pendula Modeling and Control
A.DC motor model in form of a voltage-to-torque
conversion relationship
13. 10. 2012
15
rotary single inverted pendulum
torque model
( )0 tθ
( )1 tθ
( )aV t
( ) ( ) ( )2 2
0m g m g r
aa a
k k k kM t V t t
R Rθ= − ɺ
( ) ( ) ( )2 2
02m g m g c
aa a
k k k kF t V t t
R r R rθ= − ɺ
rotary single
inverted pendulum
system:
classical single inverted pendulum
system
1
A.Demo Simulations II: Open-loop dynamical analysis for nonlinear voltage models of inverted pendula systems
13. 10. 2012
16
Inverted Pendula Modeling and Control
A.Rotary single inverted pendulum (voltage model) –
open-loop dynamical analysis
13. 10. 2012
17
Scope2
Scope
Scoperad2deg2
Scoperad2deg1
Scoperad2deg
M external torque
fi0 arm angle
fi1 pendulum angle
dfi0dt arm angular velocity
dfi1dt pendulum angular velocity
Impulse
V motor voltage
dfi0dt arm angular velocity
M torque induced on the cart
DC Motor for Inverted Pendula Systems
0 2 4 6 8 10 12 14 16 18 200
5
10
15
20
25
30
Simulation time [s]
Arm
ang
le [d
eg]
Rotary Single Inverted Pendulum (Voltage Model)Open-loop Analysis - Arm Angle
Arm angle
0 2 4 6 8 10 12 14 16 18 20-300
-250
-200
-150
-100
-50
0
Simulation time [s]
Pen
dulu
m a
ngle
[deg
]
Rotary Single Inverted Pendulum (Voltage Model)Open-loop Analysis - Pendulum Angle
Pendulum angle
Scoperad2deg3Rotary Single Inverted Pendulum
B.Stabilization of the Rotary Single
13. 10. 2012
18
Stabilization of the Rotary Single Inverted Pendulum via State-Feedback
Control Techniques
19
B.Control techniques for inverted pendula systems supported
by the IPMaC block library
13. 10. 2012
Control Objective
Stabilization of the pendulum in the upright position
Swing-up into the upright position
IPMaC Derivator
Inverted Pendula Models
• pole-placement algorithm
• linear quadratic optimal control method (LQR)
• PID/PSD algorithm
upright position
Linear state-space pendulum model
Nonlinear state-space pendulum model
• state-dependent Riccatiequation
• input-output linearization
• artificial intelligence
Nonlinear state-space pendulum model
• energy-based methods
• artificial intelligence
LinearizatorModels
Inverted Pendula ControlInverted Pendula
Swing-up
B. 1)Inverted Pendula Model Linearizator & Discretizer
13. 10. 2012
20
selection of system type & number of pendulum links
system parameters
motor
matrices of the linearized system
matrices of the discretized system
parameters
B. 1)State-space description of inverted pendula systems
13. 10. 2012
21
( ) ( ) ( )( )Tttt θθx ɺ= state vector
Standard minimal ODE form
( )( ) ( ) ( ) ( )( ) ( ) ( )( ) ( )( ) ( )( )( ) ( ) ( ) ( )( ) ( ) ( )( )( )tttttVtt
ttttttt
θθθθθθ PNM
VθPθθθNθθM
+−=
=++− ɺɺɺɺ
ɺɺɺɺ
,
,1
( ) ( )( )( ) ( )( )ttutt
ttutt
,,)(
,,)(
xgy
xfx
==ɺ
nonlinear state-space
description
B. 1)Linear approximation of inverted pendula systems
(upright position)
( ) ( ) ( )( )Tttt θθx ɺ=
13. 10. 2012
22
( ) ( )( )( ) ( )( )ttutt
ttutt
,,)(
,,)(
xgy
xfx
==ɺ
TS =x 0
state vector
( ) ( ) ( )( ) ( ) ( )t t u t
y t x t du t
= +
= +
x Ax b
C
ɺ
( ) ( )( ) ( ) ( ) ( )( )( ) ( )( ) ( ) ( )( )
( ) ( )( )S
u
ikSk
u
n
k k
iSSii utu
tu
tutfxtx
tx
tutfuftutf
SSSS
−∂
∂+−∂
∂+≈ ∑+
= ,,
22
1
* ,,,,
xx
xxxx
matrices_single.m
matrices_double.m
matrices_rotary.m
B. 1)Linearized (continuous-time) and discretized (discrete-time) state-space description of rotary single inverted pendulum
13. 10. 2012
23
[A,B,C,D] = matrices_rotary([0.5 0.6 0.275 0.5 0.3 0.011458],'up','m')
0 0 1 0
0 0 0 1
0 14,3243 3,5435 0,2434
= − −
A1 0 0 0
0 1 0 0
=
C
0
0
0,1288
0,2318
= −
b0
0
=
d
Ts=0.01[F,G]=c2d(A,B,Ts)
0 55,2138 6,3783 0,938 −
0,2318 −
1 0,0007 0,0098 0
0 1,0027 0,0004 0,01
0 0,1402 0,9652 0,0017
0 0,5456 0,0624 0,9935
− = −
F
0,000006
0,000011
0,0013
0,0023
− = −
g 1 0 0 0
0 1 0 0
=
C0
0
=
d
Inverted Pendula Modeling and Control
B. 2)Software support for state-feedback controller design
(Simulink library blocks)
13. 10. 2012
24
Inverted Pendula Control
feedforward component
B. 2)State-feedback control – basic control scheme
13. 10. 2012
25
disturbance input
( )tw
( )tdu
( )tu ( )ty( ) ( ) ( )tutxtx bA +=ɺ
( ) ( )ff ffu t k w t=
( )ffu t
ffk
feedback component
( ) ( ) ( )tutxtx bA +=ɺ
( ) ( )txty C=
k
( )tx
( ) ( ) ( ) ( ) ( ) ( ) ( )R ff u ff uu t u t u t d t t k w t d t= + + = − + +kx
( ) ( )Ru t t= −kx
( )Ru t
ffk
B. 2)Library block State-Feedback Controller with FeedForward Gain
continuous-time state-space model
13. 10. 2012
26
Computation of the feedback gain vector k
a) using the pole-placement algorithm
discrete-time state-space model
B. 2)Library block State-Feedback Controller with FeedForward Gain
13. 10. 2012
27
Computation of the feedback gain vector k
2) using the linear quadratic optimal control method (LQR)
( ) ( ) ( ) ( ) ( )( )1 T TJ t t t u t ru t dt∞
= +∫ x Qx ( ) ( ) ( ) ( ) ( )1N
T TLQR R RJ i i i u i ru i
−= +∑ x Qx
continuous-time state-space model discrete-time state-space model
( ) ( ) ( ) ( ) ( )( )02
T TLQR R RJ t t t u t ru t dt= +∫ x Qx ( ) ( ) ( ) ( ) ( )
0LQR R R
k
J i i i u i ru i=
= +∑ x Qx
1
r= Tk g P
1
r= Tk b P
10
r+ − + =T TA P PA Pb b P Q ( ) 1
0−
− + + =T T T TF PF F Pg r g Pg g PF Q
B. 2)Library block State-Feedback Controller with FeedForward Gain
– supported control objectives
• Initial deflection of the pendulum (nonzero
initial conditions)
• Time-constrained and permanent
13. 10. 2012
28
disturbance input compensation
( )
• Tracking a desired reference trajectory by the
cart or arm
0≠ud
( ) 11
1ffk −
−=−c A bk b ( )( ) 1
1
1ffDk −=
− −2n+2c I F gk g
B. 2)State-feedback control with a discrete-time state estimator
13. 10. 2012
29
ffDk ( ) ( ) ( )1i i u i+ = +x Fx g
( ) ( )i i=y Cx
( )w i ( )y i( )ud i
( )u i
( )u i( )ffu i
Dk
( ) ( ) ( ) ( ) ( )( )ˆ ˆ ˆ1i i u i i i+ = + + −x Fx g L y Cx( )Ru i
( )x̂ i
( ) ( ) ( ) ( ) ( ) ( ) ( )ˆR ff u D ffD uu i u i u i d i i k w i d i= + + = − + +k x
B. 2)Library block Luenberger Estimator
pole-placement algorithm optimal control method (LQR)
13. 10. 2012
30
Computing the state estimator matrix L
B. 2)Demo Simulations III: State-feedback control for nonlinear force-torque / voltage models of inverted pendula systems
13. 10. 2012
31
Inverted Pendula Modeling and Control
B. 2)Rotary single inverted pendulum (voltage model) –general simulation setup for state-feedback control
13. 10. 2012
32
Model already linearized and discretized using default parameters.Use Linearizator to obtain modified matrices if a change in parameters occurs. --->>>
xe(i+1)=Fxe(i)+Gu(i)+L(y(i)-ye(i))u
yxe
Luenberger Estimator
Linearizator
Inverted Pendula ModelLinearizator and Discretizer
[arm1]
x
wuState-Feedback Controller
xu
State-Feedback Controller with Feedforward Gain1
Signal 1
Signal Builder1
Scoperad2deg1
Scoperad2deg
M external torque
fi0 arm angle
fi1 pendulum angle
dfi0dt arm angular velocity
Rotary Single Inverted Pendulum[ref]
Goto3
[pend1]
Goto2
[arm1]
Goto1
-K-
Gain
[pend1]
From5
[arm1]
From1
[ref]
From
V motor voltage
dfi0dt arm angular velocityM torque induced on the cart
DC Motor for Inverted Pendula Systems
0
Constant
B. 2)Rotary single inverted pendulum –
simulation results for LQR control compared to pole-placement
13. 10. 2012
33
• control objective:▫ the arm should rotate for a total of half a circle and stop every quarter-turn to
stabilize before returning to its initial position;
▫ the pendulum should be kept upright all the time
• state-feedback control designed using continuous-time & discrete-time LQR and continuous-time pole-placement
0 2 4 6 8 10 12 14 16 18 20-50
0
50
100
150
200
Simulation time [s]
Arm
ang
le [d
eg]
Rotary Single Inverted PendulumReference Trajectory Tracking by Arm Angle (LQR vs. Pole-Placement)
Arm angle referenceLQR - discretePole-placementLQR - continuous
0 2 4 6 8 10 12 14 16 18 20-20
-15
-10
-5
0
5
10
15
20
Simulation time [s]
Pen
dulu
m a
ngle
[deg
]
Rotary Single Inverted Pendulum Pendulum Angle Stabilization (LQR vs. Pole-Placement)
Pendulum angle referenceLQR - discretePole-placementLQR - continuous
and continuous-time pole-placement
B. 2)Rotary single inverted pendulum –
evaluation of the impact of weight matrices on system performance
13. 10. 2012
34
• tuning the functional weight matrices enables us to stress one of the two contradictory control objectives:
▫ bringing the rotary arm into the desired position in the shortest time possible
▫ stabilization of the pendulum in the upright position with the lowest possible overshoot
0 5 10 15 20 25 30 35-50
-25
0
25
50
75
100
125
150
175
200
Simulation time [s]
Arm
ang
le [d
eg]
Rotary Single Inverted Pendulum Weight Matrices Comparison - Arm Angle
Arm angle referenceLQR with Q
1 weight matrix
LQR with Q2 weight matrix
0 5 10 15 20 25 30 35-40
-30
-20
-10
0
10
20
30
40
Simulation time [s]
Pen
dulu
m a
ngle
[deg
]
Rotary Single Inverted Pendulum Weight Matrices Comparison - Pendulum Angle
Pendulum angle referenceLQR with Q
1 weight matrix
LQR with Q2 weight matrix
B. 2)State-feedback control with permanent disturbance compensation using a summator – control scheme
13. 10. 2012
35
–
( ) ( ) ( )1i i u i+ = +x Fx g
( ) ( )i i=y Cx
2k
∑2k 1
z
( )ud i
( )w i ( )y i( )u i( )1v i + ( )v i
( )ffu i
– ( ) ( )i i=y Cx
( ) ( ) ( ) ( ) ( )( )ˆ ˆ ˆ1i i u i i i+ = + + −x Fx g L y Cx
1k 1c
z
( )Ru i
36
B. 2)Library block State-Feedback Controller with a Summator
Control objectives:
B. 2)Demo Simulations IV: State-feedback control with a
summator for nonlinear force-torque / voltage models of inverted pendula systems
13. 10. 2012
37
Inverted Pendula Modeling and Control
B. 2)Rotary single inverted pendulum –
simulation results for LQR control with a summator
13. 10. 2012
38
• control objective: to track the reference trajectory & keep the pendulum upright with a constant disturbance input present▫ the conventional LQR controller fails to track the reference trajectory
without producing steady-state error
▫ permanent disturbances are successfully compensated by a LQR algorithm with a summator included in the control structure
0 2 4 6 8 10 12 14 16 18 20-50
0
50
100
150
200
Simulation time [s]
Arm
ang
le [d
eg]
Rotary Single Inverted PendulumPermanent Disturbance Compensation - Arm Angle
Arm angle referenceLQR with summatorLQR without summator
0 2 4 6 8 10 12 14 16 18 20-30
-20
-10
0
10
20
30
Simulation time [s]
Pen
dulu
m a
ngle
[deg
]
Rotary Single Inverted PendulumPermanent Disturbance Compensation - Pendulum Angle
Pendulum angle referenceLQR with summatorLQR without summator
with a summator included in the control structure
13. 10. 2012
39
• comprehensive approach to modeling and control of the
rotary single inverted pendulum system
• custom-designed Simulink block library Inverted
Conclusion and Evaluation of Results
• custom-designed Simulink block library Inverted
Pendula Modeling and Control
▫ software framework for all covered issues (model derivation,
open-loop analysis, linearization, state-feedback controller design)
▫ provides suitable library blocks and original GUI
applications to support every step of the process
13. 10. 2012
40
Thank you for your attention.