0% found this document useful (0 votes)
59 views31 pages

Homework Presentation

This document provides an overview of modeling, representing, and simulating an inverted pendulum system. It begins with the physical modeling using Lagrangian mechanics to derive nonlinear differential equations of motion. It then covers linearizing the system around two equilibrium points to obtain state-space representations. Transfer functions relating input force to cart position and pole angle outputs are derived. Finally, it discusses analyzing the stability of the linearized systems using eigenvalues of the Jacobian matrices.

Uploaded by

oussama sadki
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views31 pages

Homework Presentation

This document provides an overview of modeling, representing, and simulating an inverted pendulum system. It begins with the physical modeling using Lagrangian mechanics to derive nonlinear differential equations of motion. It then covers linearizing the system around two equilibrium points to obtain state-space representations. Transfer functions relating input force to cart position and pole angle outputs are derived. Finally, it discusses analyzing the stability of the linearized systems using eigenvalues of the Jacobian matrices.

Uploaded by

oussama sadki
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 31

Homework 1: representation and

simulation of Inverted Pendulum

Eduardo Fernandes Montesuma


Universidade Federal do Ceará
[email protected]

17 de abril de 2018
Outline
Modeling
Introduction
Physical modeling
Mathematical Analysis

Representation
Linearization
State space and Transfer Functions
Stability

Simulation
Free Response
Impulse Response
Step Response
Introduction

This presentation wants to cover the topics of Homework 1, of


the discipline of advanced control, namely,
I Mathematical Modeling of the system,

I Linearization and system representation,

I Stability analysis.

The physical system which we will analyze is called "Inverted


Pendulum".
I Codes and further explanation are available in
https://github.com/eddardd/Control-Theory/
tree/master/Advanced-Control
Intuition

Figura: The physical schematic of our system

The system we have chosen is composed by a cart, with mass


M, with a pole of length ` attached to it, with a ball of mass
m at its extrema.
Intuition

The study of such system encounters applications, for


example, in the development of devices called "Segways",

Figura: An example of a segway


Physical modeling

In order to describe the motion of our system, we shall adopt


the Lagrangian formalism. To that effort, we need to define

L=T −V

which accomplishes for the total energy in the system. Once


we have it, we know it satisfies, for each degree of freedom,
the Euler-Lagrange equation,

d ∂L ∂L
− =0
dt ∂ q̇ ∂q
Physical Modeling

Analyzing the system, we recognize two degrees of freedom:


I The cart’s position, x ,

I The pole’s angle, θ

Being so,
1 1
I T = (M + m)ẋ 2 − m ẋ θ̇`cos(θ) + (m`2 + I)θ̇ 2
2 2
I V = mg`cos(θ)
Physical Modeling
With the last equations, and taking derivatives, we can write
the Euler-Lagrange equations twice,

d ∂L ∂L
− = F − bx ẋ
dt ∂ ẋ ∂x
d ∂L ∂L
− = −bθ θ̇
dt ∂ θ̇ ∂θ
These expressions leads to a system of (non-linear) equations,

(M + m)ẍ − m`cos(θ)θ̈ = F + m`sin(θ)θ̇ − bx ẋ


(m`2 + I)θ̈ − m`cos(θ)ẍ = mg`sin(θ) − bθ θ̇
Physical Modeling

Those equations can be solved by using Cramer’s Rule,


yielding the following,

(m`2 + I)(F + m`θ̇sin(θ) − bx ẋ ) + m`cos(θ)(mg`sin(θ) − bθ θ̇)


ẍ =
(M + m)(m`2 + I) − m2 `2 cos 2 (θ)
(M + m)(mg`sin(θ) − bθ θ̇) + m`cos(θ)(F + m`θ̇sin(θ) − bx ẋ )
θ̈ =
(M + m)(m`2 + I) − m2 `2 cos 2 (θ)

which are the non-linear equations that govern the system


dynamics.
Mathematical Analysis
Since we have equations for ẍ and θ̈, we notice that,

ẋ = f1 (t, x , ẋ , θ, θ̇, u)
ẍ = f2 (t, x , ẋ , θ, θ̇, u)
θ̇ = f3 (t, x , ẋ , θ, θ̇, u)
θ̈ = f4 (t, x , ẋ , θ, θ̇, u)

That is, by defining x = (x , ẋ , θ, θ̇), f = (f1 , f2 , f3 , f4 ), we have,

ẋ = f(t, x, u)
Mathematical Analysis
Indeed, we have defined a (non-linear) vectorial field over R4 .
A quick simulation using numerical integration gives us the
following results,

Figura: Step-response of the system


Mathematical Analysis

Indeed, two points are of our interest,


I The upward point, xsp = (0, 0, 0, 0), which yields, by
inspection, f(t, x) = 0.
I The downward point, xsp = (0, 0, π, 0), which yields, by
inspection, f(t, x) = 0.
These points gives rise of what we call singular trajectories,
since for every t, with those initial conditions, f(x) = 0.
Stability

Assuming xsp being a stationary point, we informally define


stability as,
I Stable stationary points are those whose, after applied a
disturbance, tends to get back to the original point.
I Unstable points are those whose, after applied a
disturbance, tends to go away from the original point.
Under those definitions, we notice that (0, 0, 0, 0) is a unstable
point, while (0, 0, π, 0) is a stable one, matching our common
sense.
Linearization
I Linearization is a local technique analysis, which permits
us to transform the nonlinear equation ẋ = f(x, u) into a
linear one,
I By Taylor’s Expansion,

∂f ∂f
f(xsp , u) = (x − xsp ) + u
∂x ∂u
∂f
in which we identify as the Jacobian matrix of f. This
∂x
gives us the following state-space representation,

ẋ = Ax + Bu
State Space equations

For xsp = (0, 0, 0, 0), we calculate the partial derivatives of f ,


to achieve:

 
0 1 0 0
 (m`2 + I)bx (m`)2 g −m`bθ 
0 −
 

A=
 α α α 
0 0 0 1


 
 m`bx (M + m)mg` −(M + m)bθ 
0 −
α α α
with α = (M + m)(m`2 + I) − (m`)2 .
State Space equations

For xsp = (0, 0, π, 0), we calculate the partial derivatives of f ,


to achieve:

 
0 1 0 0
 (m`2 + I)bx (m`)2 g m`bθ 
0 − −
 

A=
 α α α 
0 0 0 1


 
 m`bx (M + m)mg` (M + m)bθ 
0 − −
α α α
with α = (M + m)(m`2 + I) − (m`)2 .
State Space equations

For B, we have:

   
0 0
2 2

 m` +I


 m` +I

   
B0 = 
 α 
Bπ = 
 α 
0 0
 
   
 −m` 
   
 m` 
α α
Transfer Function

The transfer functions of the system can be encountered by


transforming the State-Space equation to frequency, and
Y
solving for , to do so, we need,
U
I To define an choice for input, which in our case is unique,
that is, the force F .
I To define an choice for output, which in our case we shall
define y = x and y = θ.
Therefore, we use linearize the equations from physical
modeling to derive two transfer functions, Tx and Tθ
Transfer Function
Calculating and solving for each variable yields, for
xsp = (0, 0, 0, 0).
X (s) (m`2 + I)s 2 + bθ s − mg`
=    
U(s)
αs 4 + (M + m)bθ + (m`2 + I)bx s 3 + bθ bx − (M + m)mg` s 2 − mg`bx s

Θ(s) m`s 2
=    
U(s)
αs 4 + (M + m)bθ + (m`2 + I)bx s 3 + bθ bx − (M + m)mg` s 2 − mg`bx s

similar results can be done for xsp = (0, 0, π, 0):


X (s) (m`2 + I)s 2 + bθ s + mg`
=    
U(s)
αs 4 + (M + m)bθ + (m`2 + I)bx s 3 + bθ bx + (M + m)mg` s 2 + mg`bx s

Θ(s) −m`s 2
=    
U(s)
αs 4 + (M + m)bθ + (m`2 + I)bx s 3 + bθ bx + (M + m)mg` s 2 + mg`bx s
Stability analysis in linear systems

The following theorem states the equivalence between stability


of stationary points in non-linear and linear systems,
Lyapunov-Perron Theorem
Let xsp be a stationary point of a field f : Rn → Rn . Thus, xsp
is a stable stationary point of f if, and only if J|x=xsp has only
eigenvalues with negative real part.
I This indeed allows us to substitute the analysis of stability
of ẋ = f(x) by ẋ = Jx
Linear stable systems

We begin by noticing that the solution of _ x = Jx relies on the


spectra of J,
I If J is diagonalizable, then the solution is

n
ξ i e λi t
X
x(t) =
i=1

for eigenvalues λi and eigenvectors ξi .


I If any λi has positive real part, then the solution diverges
on at least one of its coordinates.
I The system is thus, unstable.

This is the criteria for Linear Stability.


Responses

Figura: Linearized step response for θsp = 0. Observe how it is


unstable.
Responses

Figura: Linearized step response for θsp = π. Confirming our claim


that π is a stable stationary point.
Poles of linearizations

The later responses can be understood by looking at the


eigenvalues of each linearized matrix, A:

Eigenvalue A0 Aπ
λ1 0 0
λ2 -4.423 -1.0819
λ3 -0.9469 -0.126 + 4.218i
λ4 4.0349 -0.126 - 4.218i
Tabela: System’s Eigenvalues

Since A0 has a pole (or eigenvalue) with positive real part, we


conclude that it is an unstable stationary point.
Methodology

To simulate our system, we have used Python language,


I The linearization were simulated using the Control
package,
I We have used a hard-coded numerical ODE solver to
obtain the non-linear results,
I The animations were done using Matplotlib’s functions.
Free Response
We have simulated the free response of our system to an
initial condition slightly moving in the anti-clockwise direction,

Figura: Linear and non-linear free-responses to initial conditions


Free Response

Those plots shows us that,


I The linearization response resembles the non-linear
response for the angle, although for the cart’s position,
the behavior does not capt the original response,
I The angle tends to go to the stable point, that is, π.
I The cart’s position response is stable. After a few
oscillations, the pole movement amplitude is small, and
the cart settles in a fixed position.
Impulse Response
We have simulated the impulse response of our system to
initial conditions (0, 0, π, 0), that is, the upward position.

Figura: Linear and non-linear free-responses to an impulse input


Impulse Response

Those plots shows us that,


I Again, we have the same phenomena that the cart’s
position has a strange linear behavior.
I The angle still settles in π,
I Although given an initial force to the right, the pole’s
oscillations compensate the driving force to the right,
making the cart to settle as the time goes by.
Step Response
We have simulated the step response of our system to initial
conditions (0, 0, π, 0), that is, the upward position.

Figura: Linear and non-linear free-responses to a step input


Step Response
From the last figure, we can draw the following comments,
I That time, the linear response approximates quite well the
cart’s position behavior.
I If we have a continuous driving force to the right, on the
cart, no compensation can stop the position to grow
without bounds.
Still, we can estimate empirically some time-domain
information,
Measure Linear Nonlinear
tr (seconds) 0.25 0.60
ts (seconds) 22.88 12.51
Mp 91.60% 67.83%
tp (seconds) 0.74 2.06
Tabela: Time domain response information summary

You might also like