Skip to content

Code to control an aeropendulum that reaches angular positions between 30 and -30 degrees.

License

Notifications You must be signed in to change notification settings

cychitivav/aeropendulum

Repository files navigation

Aeropendulum

This repository contains the development of an aeropendulum and the performance of various controllers to achieve angular positions between 30 and 30 ° .

I θ ¨ = W c l c cos θ + F h l m W b l b cos θ W n l n cos θ β θ ˙ θ ¨ = 1 I ( W cos θ β θ ˙ + F h l m )

Where

W = W c l c W b l b W n l n

To simplify the inertia, we define the term I 0 as the system inertia without counterweight and the term I as the system inertia with counterweight.

I = I 0 + m c l c 2

Where I 0 = I b + I n , to compute the bar inertia ( I b ), we use the parallel axes theorem:

I b = I b c m + m b l b 2 I b = 1 12 m b ( l 1 + l m ) 2 + m b l b 2

And the motor+nuts inertia ( I n ) is considered as a puntual load, i.e.

I n = m n l n 2

State-space model

To represent the state-space model of the system, we define the next state equations:

x 1 = θ x 2 = θ ˙

Therefore:

x ˙ 1 = x 2 x ˙ 2 = 1 I ( W cos x 1 β x 2 + F h l m )

Linearization

To design linear controllers, we need to linearize the system around the an equilibrium point.

f 1 ( x 1 , x 2 , u ) = x ˙ 1 f 2 ( x 1 , x 2 , u ) = x ˙ 2

X = [ x 1 x 2 ] U = F Z = Δ X = X X

Z ˙ = [ f 1 x 1 f 1 x 2 f 2 x 1 f 1 x 2 ] | X , F Z + [ f 1 u f 2 u ] | X , F u

Equilibrium points

For x 2 :

f 1 ( x 1 , x 2 , F ) = x ˙ 1 = 0 x 2 = 0

To x 1 :

f 2 ( x 1 , x 2 , F ) = x ˙ 2 = 0 1 I ( W cos x 1 β x 2 + F l m ) = 0 W cos x 1 β x 2 + F l m = 0 F = β x 2 W cos x 1 l m F = W cos x 1 l m

Finally:

Z ˙ = [ 0 1 W I sin x 1 β I ] | X , F Z + [ 0 l m I ] | X , F u Z ˙ = [ 0 1 W I sin x 1 β I ] Z + [ 0 l m I ] u

If you want x 1 = 0 , the thrust force is F = W l m and:

Z ˙ = [ 0 1 0 β I ] Z + [ 0 l m I ] u

Characterization

To find the B and F h parameters, we use the following methods:

  1. Damping coefficient ( B )
    This parameter was found using the simple pendulum model. First, we remove the counterweight from the system and drop the bar with the motor from 0 ° to 30 ° and take the curve of angle in the time. Then, we compute the damping coefficient B with the envelope of this signal.

    $$ \text{env}(t) = ae^{-bt} $$

    $$ B=2I_0b $$

  2. Thrust force ( F h )
    The objective of this identification is to find the thrust force F h that depends of voltage. Therefore, we take measurements of the voltage locating the system in an angle 0 with different counterweights. With this, we can calculate the thrust force F h that corresponds to the voltage V in the system making a torque summation.

    If we have:

    $$ \begin{gather*} B= \begin{bmatrix} 0\ K_f\frac{l_m}{I} \end{bmatrix} \end{gather*} $$

SMC

Define the next states:

x ˙ 1 = x 2 x ˙ 2 = 1 I ( W cos x 1 β x 2 + F h l m )

Can be written as:

x ˙ 1 = x 2 x ˙ 2 = 1 I [ W cos x 1 β x 2 + ( K f v + b f ) l m ]

  • h ( x ) = 1 I ( W cos x 1 β x 2 + b f l m )
  • f ( x ) = 1 I ( K f l m )

Now, we define an error:

x e = x 1 x r x ˙ e = x ˙ 1

and the next sliding manifold:

S = a x e + x 2

where its derivative is:

S ˙ = a x ˙ e + x ˙ 2 S ˙ = a x ˙ 1 + h ( x ) + f ( x ) v

and the signal control law is:

v = ρ   sign ( S )

To the system stability, we need to define the following:

ρ | a x 2 + h ( x ) f ( x ) | ρ | a x 2 + 1 I ( W cos x 1 β x 2 + b f l m ) 1 I ( K f l m ) |

Taken as limits x 2 π and, we get:

ρ a max x 2 + 1 min I ( max W + max β max x 2 + max b f l m ) 1 max I min K f l m ρ a π + 1 I 0 ( max W max β π + max b f l m ) 1 I min K f l m

MRAC (Model Reference Adaptive Control)

Considering the LTI system

x ˙ = A x + B u y = C x

where:

  • x R n : state vector
  • u R m : control input vector
  • y R p : output vector
  • A R n × n : state matrix (Unkonwn)
  • B R n × m : input matrix (Partially known)
  • C R p × n : output matrix (Known)

Now, we define a reference model such that in open loop the interesting signal follows the reference:

x ˙ m = A m x m + B m r y = C x m

  • r R p : reference vector

This model complies that:

  • A m = A + B K x
  • B m = B K r

Observer

Since not all states are accessible, a Luenberger observer is created as:

x ^ ˙ = A x ^ + B u + L ( y y ^ ) y ^ = C x ^

x ^ ˙ = A x ^ + B u + L ( y C x ^ ) x ^ ˙ = A x ^ + B u + L y L C x ^ x ^ ˙ = ( A L C ) x ^ + B u + L y

  • B K y = L

Observer error:

e l = x x ^ e ˙ l = x ˙ x ^ ˙ e ˙ l = A x + B u ( A L C ) x ^ B u L y e ˙ l = A x ( A L C ) x ^ L C x e ˙ l = ( A L C ) x ( A L C ) x ^ e ˙ l = ( A L C ) e l

Controller

Using the next control law:

u = K x x ^ + K r r + K y ( y y ^ )

The state estimate is:

x ^ ˙ = ( A m B K x ) x ^ + B ( K x x ^ + K r r + K y ( y y ^ ) ) + L ( y y ^ )

Error

Defining the error as:

e = x m x ^ e ˙ = x ˙ m x ^ ˙ e ˙ = A m x m + B m r A m x ^ + B K x x ^ B K x x ^ B K r r B K y ( y y ^ ) L ( y y ^ ) e ˙ = A m e + B K r r + B K x x ^ B K x x ^ B K r r B K y ( y y ^ ) + B K y ( y y ^ )

Defining:

  • K ~ x = K x K x
  • K ~ r = K r K r
  • K ~ y = K y K y

e ˙ = A m e B K ~ r r B K ~ x x ^ B K ~ y ( y y ^ ) e ˙ = A m e B K ~ r r B K ~ x x ^ B K ~ y C e l e ˙ = A m e B ( K ~ r r + K ~ x x ^ + K ~ y C e l )

To find the K , we choice the following Lyapunov candidate:

V = e T P e + trace ( K ~ x Γ x 1 K ~ x T ) + trace ( K ~ r Γ r 1 K ~ r T ) + trace ( K ~ y Γ y 1 K ~ y T ) V ˙ = e T P e ˙ + e ˙ T P e + 2 trace ( K ~ x Γ x 1 K ~ ˙ x T ) + 2 trace ( K ~ r Γ r 1 K ~ ˙ r T ) + 2 trace ( K ~ y Γ y 1 K ~ ˙ y T ) V ˙ = e T P ( A m e B K ) + ( A m e B K ) T P e + 2 trace ( K ~ x Γ x 1 K ~ ˙ x T ) + 2 trace ( K ~ r Γ r 1 K ~ ˙ r T ) + 2 trace ( K ~ y Γ y 1 K ~ ˙ y T ) V ˙ = e T P ( A m e B K ) + ( e T A m T K T B T ) P e + 2 trace ( K ~ x Γ x 1 K ~ ˙ x T ) + 2 trace ( K ~ r Γ r 1 K ~ ˙ r T ) + 2 trace ( K ~ y Γ y 1 K ~ ˙ y T ) V ˙ = e T P A m e e T P B K + e T A m T P e K T B T P e + 2 trace ( K ~ x Γ x 1 K ~ ˙ x T ) + 2 trace ( K ~ r Γ r 1 K ~ ˙ r T ) + 2 trace ( K ~ y Γ y 1 K ~ ˙ y T ) V ˙ = e T [ P A m e + e T A m T P ] e e T P B K K T B T P e + 2 trace ( K ~ x Γ x 1 K ~ ˙ x T ) + 2 trace ( K ~ r Γ r 1 K ~ ˙ r T ) + 2 trace ( K ~ y Γ y 1 K ~ ˙ y T )

V ˙ = e T [ P A m e + e T A m T P ] e 2 e T P B ( K ~ r r + K ~ x x ^ + K ~ y C e l ) + 2 trace ( K ~ x Γ x 1 K ~ ˙ x T ) + 2 trace ( K ~ r Γ r 1 K ~ ˙ r T ) + 2 trace ( K ~ y Γ y 1 K ~ ˙ y T )

  • e T P B K ~ r r = trace ( K ~ r r e T P B )
  • e T P B K ~ x x ^ = trace ( K ~ x x ^ e T P B )
  • e T P B K ~ y C e l = trace ( K ~ y C e l e T P B )

V ˙ = e T [ P A m e + e T A m T P ] e + 2 trace ( K ~ x [ x ^ e T P B + Γ x 1 K ~ ˙ x T ] ) + 2 trace ( K ~ r [ r e T P B + Γ r 1 K ~ ˙ r T ] ) + 2 trace ( K ~ y [ C e l e T P B + Γ y 1 K ~ ˙ y T ] )

K ~ i = K i K i K ~ i ˙ = K ˙ i K ˙ i K ~ i ˙ = K ˙ i

  • K ˙ x T = Γ x x ^ e T P B
  • K ˙ r T = Γ r r e T P B
  • K ˙ y T = Γ y C e l e T P B

About

Code to control an aeropendulum that reaches angular positions between 30 and -30 degrees.

Topics

Resources

License

Stars

Watchers

Forks

Languages