DBPEN-LIN.mws

Dynamic Equations for the
Linear Double Inverted Pendulum (DBIP) Experiment

©  2012 Quanser Consulting Inc.

URL: http://www.quanser.com

NOTE: This worksheet presents the general dynamic equations modelling a Double Inverted Pendulum mounted on a linear cart.

Description

The Quanser_Tools  Package

Worksheet Initialization

>    restart: interface( imaginaryunit = j ):

>    with( LinearAlgebra ):

>    libname := "C:/Program Files/Quanser/Maple Repository", ".", libname:

>    with( Quanser_Tools );

HTM deriveA deriveB deriveF kinetic_energy lagrange_equations moment_of_inertia n_norm potential_energy write_ABCD_to_Mfile

environment variable representing the order of series calculations

>    Order := 2:

IP02 Parameters

>    IP02_PARAM := { M[c] = 0.7031, J[m] = 3.9e-7, K[t] = 0.0077, Eff_m = 1, r[mp] = 0.0063, B[eq] = 4.3, K[g] = 3.71};

IP02_PARAM := {K[g] = 3.71, B[eq] = 4.3, r[mp] = .63e-2, Eff_m = 1, K[t] = .77e-2, J[m] = .39e-6, M[c] = .7031}

Notations

Generalized Coordinates: q[i] 's

The generalized coordinates are also called Lagrangian coordinates.

x[c](t)  =  driving cart (i.e. HFLC) linear position

Relative Pendulum angles:

α  = Lower inverted pendulum position angle about the vertical: the zero angle [mod 2*pi] is defined when the IP is in the perfect upright position.

θ t  = Upper inverted pendulum position angle about the vertical of the lower pendulum: the zero angle [mod 2*pi] is defined when the IP is in the perfect upright position w.r.t. to the lower pendulum.

Np = number of links (i.e. pendulums)

>    Np := 2:

>    q := [ x[c](t), alpha(t), theta(t) ];

q := [x[c](t), alpha(t), theta(t)]

Nq = number of Lagrangian coordinates

Nq is also the number of position states.

>    Nq := nops( q ):

qd = first-order time derivative of the generalized coordinates, e.g. position and angular velocities

>    qd := map( diff, q, t );

qd := [diff(x[c](t),t), diff(alpha(t),t), diff(theta(t),t)]

Transformation Matrices

Translation from the base to cart position.

>    T[0,c] := HTM('trans',q[1],0,0);

T[0,c] := Matrix(%id = 136610524)

Rotation about α  joint.

>    R[alpha] := HTM('rot','Z',q[2]);

R[alpha] := Matrix(%id = 137147752)

Translation to pendulum 1 cog.

>    T[p1] := HTM('trans',0,l[p1],0);

T[p1] := Matrix(%id = 137148272)

Translation to hinge.

>    T[ph] := HTM('trans',0,L[p1],0);

T[ph] := Matrix(%id = 137148704)

Cart to pendulum 1 cog.

>    T[c,1] := Multiply(R[alpha],T[p1]);

T[c,1] := Matrix(%id = 137149136)

Cart to hinge

>    T[c,h] := Multiply(R[alpha],T[ph]);

T[c,h] := Matrix(%id = 137149556)

Rotation about θ .

>    R[theta] := HTM('rot','Z',q[3]);

R[theta] := Matrix(%id = 137149996)

Translation to cog 2.

>    T[p2] := HTM('trans',0,l[p2],0);

T[p2] := Matrix(%id = 137150440)

Hinge to cog 2

>    T[h,2] := Multiply( R[theta], T[p2] );

T[h,2] := Matrix(%id = 137151032)

Cart to cog 2.

>    T[c,2] := Multiply( T[c,h], T[h,2] );

T[c,2] := Matrix(%id = 137151480)
T[c,2] := Matrix(%id = 137151480)
T[c,2] := Matrix(%id = 137151480)
T[c,2] := Matrix(%id = 137151480)
T[c,2] := Matrix(%id = 137151480)
T[c,2] := Matrix(%id = 137151480)
T[c,2] := Matrix(%id = 137151480)

Base coordinate system to cog 1.

>    T[0,1] := Multiply( T[0,c], T[c,1] );

T[0,1] := Matrix(%id = 137151912)

Base coordinate system to hinge.

>    T[0,h] := Multiply( T[0,c], T[c,h] );

T[0,h] := Matrix(%id = 137152344)

Base coordinate system to the cog 2.

>    T[0,2] := Multiply( T[0,c], T[c,2] );

T[0,2] := Matrix(%id = 137152776)
T[0,2] := Matrix(%id = 137152776)
T[0,2] := Matrix(%id = 137152776)
T[0,2] := Matrix(%id = 137152776)
T[0,2] := Matrix(%id = 137152776)
T[0,2] := Matrix(%id = 137152776)
T[0,2] := Matrix(%id = 137152776)

Cartesian Coordinates of the Pendulum's Centre Of Gravity

conventions:

1) α = 0 θ = 0  corresponds to both pendulums perfectly vertical, pointing downswards.

2) positive rotation is CCW  when facing the cart.

x[p,i]  = x-coordinate of each pendulum's Centre Of Gravity (COG) absolute Cartesian position

y[p,i]  = y-coordinate of each pendulum's Centre Of Gravity (COG) absolute Cartesian position

>    x[p,1] := T[0,1][1,4];
y[p,1] := T[0,1][2,4];
x[p,2] := T[0,2][1,4];
y[p,2] := T[0,2][2,4];

x[p,1] := -sin(alpha(t))*l[p1]+x[c](t)

y[p,1] := cos(alpha(t))*l[p1]

x[p,2] := -cos(alpha(t))*sin(theta(t))*l[p2]-sin(alpha(t))*cos(theta(t))*l[p2]-sin(alpha(t))*L[p1]+x[c](t)

y[p,2] := -sin(alpha(t))*sin(theta(t))*l[p2]+cos(alpha(t))*cos(theta(t))*l[p2]+cos(alpha(t))*L[p1]

x[h]  = x-coordinate of the hinge COG absolute Cartesian position

y[h]  = y-coordinate of the hinge COG absolute Cartesian position

>    x[h] := T[0,h][1,4];
y[h] := T[0,h][2,4];

x[h] := -sin(alpha(t))*L[p1]+x[c](t)

y[h] := cos(alpha(t))*L[p1]

xd[p,i]  = x-coordinate of each pendulum's Centre Of Gravity (COG) absolute Cartesian velocity
yd[p,i]  = y-coordinate of each pendulum's Centre Of Gravity (COG) absolute Cartesian velocity

>    xd[p,1] := diff(x[p,1],t);
yd[p,1] := diff(y[p,1],t);
xd[p,2] := diff(x[p,2],t);
yd[p,2] := diff(y[p,2],t);

xd[p,1] := -cos(alpha(t))*diff(alpha(t),t)*l[p1]+diff(x[c](t),t)

yd[p,1] := -sin(alpha(t))*diff(alpha(t),t)*l[p1]

xd[p,2] := sin(alpha(t))*diff(alpha(t),t)*sin(theta(t))*l[p2]-cos(alpha(t))*cos(theta(t))*diff(theta(t),t)*l[p2]-cos(alpha(t))*diff(alpha(t),t)*cos(theta(t))*l[p2]+sin(alpha(t))*sin(theta(t))*diff(thet...
xd[p,2] := sin(alpha(t))*diff(alpha(t),t)*sin(theta(t))*l[p2]-cos(alpha(t))*cos(theta(t))*diff(theta(t),t)*l[p2]-cos(alpha(t))*diff(alpha(t),t)*cos(theta(t))*l[p2]+sin(alpha(t))*sin(theta(t))*diff(thet...

yd[p,2] := -cos(alpha(t))*diff(alpha(t),t)*sin(theta(t))*l[p2]-sin(alpha(t))*cos(theta(t))*diff(theta(t),t)*l[p2]-sin(alpha(t))*diff(alpha(t),t)*cos(theta(t))*l[p2]-cos(alpha(t))*sin(theta(t))*diff(the...
yd[p,2] := -cos(alpha(t))*diff(alpha(t),t)*sin(theta(t))*l[p2]-sin(alpha(t))*cos(theta(t))*diff(theta(t),t)*l[p2]-sin(alpha(t))*diff(alpha(t),t)*cos(theta(t))*l[p2]-cos(alpha(t))*sin(theta(t))*diff(the...

xd[h]  = x-coordinate of the hinge COG absolute Cartesian position

yd[h]  = y-coordinate of the hinge COG absolute Cartesian position

>    xd[h] := diff(x[h],t);
yd[h] := diff(y[h],t);

xd[h] := -cos(alpha(t))*diff(alpha(t),t)*L[p1]+diff(x[c](t),t)

yd[h] := -sin(alpha(t))*diff(alpha(t),t)*L[p1]

State-Space Variables

  • The chosen states should at least include the generalized coordinates and their first-time derivatives.
  • X is the state vector.
  • In the state vector X: Lagrangian coordinates are first, followed by their first-time derivatives, and finally any other states, as required.

Substitution sets for the states (to obtain time-independent state equations).

>    subs_Xq := { seq( q[i] = X[i], i=1..Nq ) };
subs_Xqd := { seq( qd[i] = X[i+Nq], i=1..Nq ) };

subs_Xq := {theta(t) = X[3], alpha(t) = X[2], x[c](t) = X[1]}

subs_Xqd := {diff(theta(t),t) = X[6], diff(alpha(t),t) = X[5], diff(x[c](t),t) = X[4]}

Substitution set for the input(s).

set the input to be the motor voltage:

>    subs_U := { V[m] = U[1] }:

set the input to be the cart's driving force: F[c]  (if not expressed as a function of the motor voltage):

>    #subs_U := { F[c] = U[1] }:

Nu = number of inputs; U = input (row) vector (e.g. U = [ V[m] ] )

>    Nu := nops( subs_U ):

substitution set for the position states' second time derivatives

>    subs_Xqdd := { seq( diff( q[i], t$2 ) =  Xd[i+Nq], i=1..Nq ) };

subs_Xqdd := {diff(alpha(t),`$`(t,2)) = Xd[5], diff(theta(t),`$`(t,2)) = Xd[6], diff(x[c](t),`$`(t,2)) = Xd[4]}

second time derivatives of the position states (written as time-independent variables).

The set of unknowns is obtained from this list to solve the Lagrange's equations of motion.

>    Xqdd := [ seq( Xd[i+Nq], i=1..Nq ) ];

Xqdd := [Xd[4], Xd[5], Xd[6]]

substitution set to linearize the state-space matrices (i.e. A and B)

about the quiescent null state vector (small-displacement theory)

>    subs_XUzero := { seq( X[i] = 0, i=1..2*Nq ), seq( U[i] = 0, i=1..Nu ) }:

Nx = dim( X ) = total number of states (should be greater than or equal to: 2 * Nq)

Ny = chosen number of outputs

>    Nx := 2 * Nq + 0:
Ny := Nq:

Total Potential and Kinetic Energies of the System

The total potential and kinetic energies are needed to calculate the Lagragian of the system.

Total Potential Energy: V[T]  

The total potential energy can be expressed in terms of the generalized coordinates alone.

V[e] = Total Elastic Potential Energy of the system

>    V[e] := 0;

V[e] := 0

Pendulum 1 potential energy

>    Vg[1] := potential_energy( 'gravity', M[p1], g, y[p,1] );

Vg[1] := M[p1]*g*cos(alpha(t))*l[p1]

Pendulum 2 potential energy

>    Vg[2] := potential_energy( 'gravity', M[p2], g, y[p,2] );

Vg[2] := M[p2]*g*(-sin(alpha(t))*sin(theta(t))*l[p2]+cos(alpha(t))*cos(theta(t))*l[p2]+cos(alpha(t))*L[p1])

Hinge potential energy

>    Vg[h] := potential_energy( 'gravity', M[h], g, y[h] );

Vg[h] := M[h]*g*cos(alpha(t))*L[p1]

Vg = Total Gravitational Potential Energy of the system

>    V[g] := Vg[1] + Vg[2] + Vg[h];

V[g] := M[p1]*g*cos(alpha(t))*l[p1]+M[p2]*g*(-sin(alpha(t))*sin(theta(t))*l[p2]+cos(alpha(t))*cos(theta(t))*l[p2]+cos(alpha(t))*L[p1])+M[h]*g*cos(alpha(t))*L[p1]

V[T] = Total Potential Energy of the system

>    V[T] := simplify(V[g] + V[e]);

V[T] := g*(M[p1]*cos(alpha(t))*l[p1]-M[p2]*sin(alpha(t))*sin(theta(t))*l[p2]+M[p2]*cos(alpha(t))*cos(theta(t))*l[p2]+M[p2]*cos(alpha(t))*L[p1]+M[h]*cos(alpha(t))*L[p1])
V[T] := g*(M[p1]*cos(alpha(t))*l[p1]-M[p2]*sin(alpha(t))*sin(theta(t))*l[p2]+M[p2]*cos(alpha(t))*cos(theta(t))*l[p2]+M[p2]*cos(alpha(t))*L[p1]+M[h]*cos(alpha(t))*L[p1])

Total Kinetic Energy: T[T]

The total kinetic energy can be expressed in terms of the generalized coordinates and their first-time derivatives.

Tt[c]  = translational kinetic energy of the motorized cart (e.g. HFLC)

M[c]  = cart total mass

>    Tt[c] := kinetic_energy( 'translation', M[c], qd[1] );

Tt[c] := 1/2*M[c]*diff(x[c](t),t)^2

The cart's directions of translation and rotation are orthogonal.

T[r]  = kinetic energy due to rotation tied to the motorized cart

J[m]  = motor armature inertia; K[g]  = gear ratio; r[mp]  = motor pinion radius

>    Tr[c] := kinetic_energy( 'rotation', J[m], omega[m](t));

Tr[c] := 1/2*J[m]*omega[m](t)^2

Angular rate of motor w.r.t. linear velocity (no gearbox).

>    REL_W_X := omega[m](t) = K[g] * qd[1] / r[mp]:
REL_W_X;

omega[m](t) = K[g]*diff(x[c](t),t)/r[mp]

Express rotational kinetic energy in terms of linear velocity.

>    K_ROT_CART := subs(REL_W_X,Tr[c]):
K_ROT_CART;

1/2*J[m]*K[g]^2*diff(x[c](t),t)^2/r[mp]^2

Evaluate coefficient of above term.

>    K_ROT_CART_COEFF := coeff(K_ROT_CART,diff(x[c](t),t),2):
K_ROT_CART_COEFF = evalf(subs(IP02_PARAM,K_ROT_CART_COEFF),3)*Unit(kg);

1/2*J[m]*K[g]^2/r[mp]^2 = .680e-1*Unit([kg])

Given that 0.0680 kg << Mc (0.14 kg), the rotational kinetic energy from the cart can be neglected. Therefore

>    Tr[c] := 0;

Tr[c] := 0

Pendulum 1 motion is composed of one rotation and one translation, both directions are orthogonal.

t α t  = pendulum 1 absolute angular velocity;

Tr[p,1] = pendulum 1 rotational kinetic kinergy;

>    #Tr[p,1] := kinetic_energy( 'rotation', J[p1], qd[2] );
Tr[p,1] := 0;

Tr[p,1] := 0

v[p,1] = pendulum 1 cartesian velocity (magnitude);

Tt[p,1] = pendulum 1 translational kinetic kinergy

>    v[p,1] := n_norm( [ xd[p,1], yd[p,1] ], 2 ):
Tt[p,1] := kinetic_energy( 'translation', M[p1], v[p,1] );

Tt[p,1] := 1/2*M[p1]*((-cos(alpha(t))*diff(alpha(t),t)*l[p1]+diff(x[c](t),t))^2+sin(alpha(t))^2*diff(alpha(t),t)^2*l[p1]^2)

Pendulum 2 motion is composed of one rotation and one translation, both directions are orthogonal.

t θ t  = pendulum 2 absolute angular velocity

Tr[p,2] = pendulum 2 rotational kinetic kinergy

>    #Tr[p,2] := kinetic_energy( 'rotation', J[p2], qd[3] );
Tr[p,2] := 0;

Tr[p,2] := 0

v[p,2] = pendulum 2 cartesian velocity (magnitude)

Tt[p,2] = pendulum 2 translational kinetic kinergy

>    v[p,2] := n_norm( [ xd[p,2], yd[p,2] ], 2 ):
Tt[p,2] := kinetic_energy( 'translation', M[p2], v[p,2] );

Tt[p,2] := 1/2*M[p2]*((sin(alpha(t))*diff(alpha(t),t)*sin(theta(t))*l[p2]-cos(alpha(t))*cos(theta(t))*diff(theta(t),t)*l[p2]-cos(alpha(t))*diff(alpha(t),t)*cos(theta(t))*l[p2]+sin(alpha(t))*sin(theta(t...
Tt[p,2] := 1/2*M[p2]*((sin(alpha(t))*diff(alpha(t),t)*sin(theta(t))*l[p2]-cos(alpha(t))*cos(theta(t))*diff(theta(t),t)*l[p2]-cos(alpha(t))*diff(alpha(t),t)*cos(theta(t))*l[p2]+sin(alpha(t))*sin(theta(t...
Tt[p,2] := 1/2*M[p2]*((sin(alpha(t))*diff(alpha(t),t)*sin(theta(t))*l[p2]-cos(alpha(t))*cos(theta(t))*diff(theta(t),t)*l[p2]-cos(alpha(t))*diff(alpha(t),t)*cos(theta(t))*l[p2]+sin(alpha(t))*sin(theta(t...
Tt[p,2] := 1/2*M[p2]*((sin(alpha(t))*diff(alpha(t),t)*sin(theta(t))*l[p2]-cos(alpha(t))*cos(theta(t))*diff(theta(t),t)*l[p2]-cos(alpha(t))*diff(alpha(t),t)*cos(theta(t))*l[p2]+sin(alpha(t))*sin(theta(t...

The hinge motion is composed one translation

v[h] = hinge cartesian velocity (magnitude);

Tt[h] = hinge translational kinetic kinergy

>    v[h] := n_norm( [ xd[h], yd[h] ], 2 ):
Tt[h] := kinetic_energy( 'translation', M[h], v[h] );

Tt[h] := 1/2*M[h]*((-cos(alpha(t))*diff(alpha(t),t)*L[p1]+diff(x[c](t),t))^2+sin(alpha(t))^2*diff(alpha(t),t)^2*L[p1]^2)

Total kinetic energy.

>    T[T] := collect( simplify( Tr[c]+Tt[c]+Tr[p,1]+Tt[p,1]+Tr[p,2]+Tt[p,2]+Tt[h] ), diff );

T[T] := 1/2*M[p2]*diff(theta(t),t)^2*l[p2]^2+((M[p2]*l[p2]^2+M[p2]*cos(theta(t))*l[p2]*L[p1])*diff(alpha(t),t)+(-M[p2]*cos(alpha(t))*cos(theta(t))*l[p2]+M[p2]*sin(alpha(t))*sin(theta(t))*l[p2])*diff(x[...
T[T] := 1/2*M[p2]*diff(theta(t),t)^2*l[p2]^2+((M[p2]*l[p2]^2+M[p2]*cos(theta(t))*l[p2]*L[p1])*diff(alpha(t),t)+(-M[p2]*cos(alpha(t))*cos(theta(t))*l[p2]+M[p2]*sin(alpha(t))*sin(theta(t))*l[p2])*diff(x[...
T[T] := 1/2*M[p2]*diff(theta(t),t)^2*l[p2]^2+((M[p2]*l[p2]^2+M[p2]*cos(theta(t))*l[p2]*L[p1])*diff(alpha(t),t)+(-M[p2]*cos(alpha(t))*cos(theta(t))*l[p2]+M[p2]*sin(alpha(t))*sin(theta(t))*l[p2])*diff(x[...
T[T] := 1/2*M[p2]*diff(theta(t),t)^2*l[p2]^2+((M[p2]*l[p2]^2+M[p2]*cos(theta(t))*l[p2]*L[p1])*diff(alpha(t),t)+(-M[p2]*cos(alpha(t))*cos(theta(t))*l[p2]+M[p2]*sin(alpha(t))*sin(theta(t))*l[p2])*diff(x[...
T[T] := 1/2*M[p2]*diff(theta(t),t)^2*l[p2]^2+((M[p2]*l[p2]^2+M[p2]*cos(theta(t))*l[p2]*L[p1])*diff(alpha(t),t)+(-M[p2]*cos(alpha(t))*cos(theta(t))*l[p2]+M[p2]*sin(alpha(t))*sin(theta(t))*l[p2])*diff(x[...

Generalized Forces: Q[i] 's

The non-conservative forces corresponding to the generalized coordinates are: F[c]  and the viscous damping forces, where

F[c]  = linear force generated by the motorized cart (e.g. HFLC)

Bp1 = bottom pendulum viscous friction torque coefficient (a.k.a. viscous damping)

Bp2 = top pendulum viscous friction torque coefficient (a.k.a. viscous damping)

Beq = cart viscous damping force coefficient

B[eq]  = 0 and B[p1]  = 0 and B[p2]  = 0 if all viscous dampings are neglected

>    #B[eq] := 0:
#B[p1] := 0:
#B[p2] := 0:

Q[i] = generalized force applied on generalized coordinate q[i]
the Coulomb friction is neglected, as well as the force due to the pendulum and acting on the linear cart

>    Q[1] := F[c] - B[eq] * qd[1];

Q[1] := F[c]-B[eq]*diff(x[c](t),t)

>    Q[2] := - B[p1] * qd[2];

Q[2] := -B[p1]*diff(alpha(t),t)

>    Q[3] := - B[p2] * qd[3];

Q[3] := -B[p2]*diff(theta(t),t)

F[c]  = Linear force produced by the motor at the motor pinion: cart driving force

F[c]  is calculated in the Maple worksheet titled: IP01_2_Equations.mws .
rm: comment the following line out if U = F[c], uncomment it if U = V[m]

>    F[c] := eta[g] * K[g] * eta[m] * K[t] * ( V[m] * r[mp] - K[g] * K[m] * qd[1] ) / R[m] / r[mp]^2;;

F[c] := eta[g]*K[g]*eta[m]*K[t]*(V[m]*r[mp]-K[g]*K[m]*diff(x[c](t),t))/R[m]/r[mp]^2

>    Q := [ seq( Q[i], i=1..Nq ) ];

Q := [eta[g]*K[g]*eta[m]*K[t]*(V[m]*r[mp]-K[g]*K[m]*diff(x[c](t),t))/R[m]/r[mp]^2-B[eq]*diff(x[c](t),t), -B[p1]*diff(alpha(t),t), -B[p2]*diff(theta(t),t)]

Euler-Lagrange's Equations

For a N -DOF system, the Lagrange's equations can be written:

Diff(Diff(L,qdot[i]),t)-Diff(L,q[i]) = Q[i]   for i = 1  through N

where:

  Q[i] 's are special combinations of external forces and called the generalized forces,

  q[1] , ..., q[N] , are N independent coordinates chosen to describe the system and called the generalized coordinates ,

 and L  is the Lagrangian  of the system.

L  is defined by:

L = T - U

where T  is the total kinetic energy of the system and U  the total potential energy of the system.

>    EOM_orig := lagrange_equations( T[T], V[T], q, Q ):

this is to display the EOM's

>    EOM_orig := collect( EOM_orig, { seq( diff( q[i], t$2 ), i=1..Nq ), seq( diff( q[i], t ), i=1..Nq ), seq( q[i], i=1..Nq ) } );

EOM_orig := [(M[p2]*sin(alpha(t))*cos(theta(t))*l[p2]+M[p2]*cos(alpha(t))*sin(theta(t))*l[p2])*diff(theta(t),t)^2+(2*M[p2]*sin(alpha(t))*cos(theta(t))*l[p2]+2*M[p2]*cos(alpha(t))*sin(theta(t))*l[p2])*d...
EOM_orig := [(M[p2]*sin(alpha(t))*cos(theta(t))*l[p2]+M[p2]*cos(alpha(t))*sin(theta(t))*l[p2])*diff(theta(t),t)^2+(2*M[p2]*sin(alpha(t))*cos(theta(t))*l[p2]+2*M[p2]*cos(alpha(t))*sin(theta(t))*l[p2])*d...
EOM_orig := [(M[p2]*sin(alpha(t))*cos(theta(t))*l[p2]+M[p2]*cos(alpha(t))*sin(theta(t))*l[p2])*diff(theta(t),t)^2+(2*M[p2]*sin(alpha(t))*cos(theta(t))*l[p2]+2*M[p2]*cos(alpha(t))*sin(theta(t))*l[p2])*d...
EOM_orig := [(M[p2]*sin(alpha(t))*cos(theta(t))*l[p2]+M[p2]*cos(alpha(t))*sin(theta(t))*l[p2])*diff(theta(t),t)^2+(2*M[p2]*sin(alpha(t))*cos(theta(t))*l[p2]+2*M[p2]*cos(alpha(t))*sin(theta(t))*l[p2])*d...
EOM_orig := [(M[p2]*sin(alpha(t))*cos(theta(t))*l[p2]+M[p2]*cos(alpha(t))*sin(theta(t))*l[p2])*diff(theta(t),t)^2+(2*M[p2]*sin(alpha(t))*cos(theta(t))*l[p2]+2*M[p2]*cos(alpha(t))*sin(theta(t))*l[p2])*d...
EOM_orig := [(M[p2]*sin(alpha(t))*cos(theta(t))*l[p2]+M[p2]*cos(alpha(t))*sin(theta(t))*l[p2])*diff(theta(t),t)^2+(2*M[p2]*sin(alpha(t))*cos(theta(t))*l[p2]+2*M[p2]*cos(alpha(t))*sin(theta(t))*l[p2])*d...
EOM_orig := [(M[p2]*sin(alpha(t))*cos(theta(t))*l[p2]+M[p2]*cos(alpha(t))*sin(theta(t))*l[p2])*diff(theta(t),t)^2+(2*M[p2]*sin(alpha(t))*cos(theta(t))*l[p2]+2*M[p2]*cos(alpha(t))*sin(theta(t))*l[p2])*d...
EOM_orig := [(M[p2]*sin(alpha(t))*cos(theta(t))*l[p2]+M[p2]*cos(alpha(t))*sin(theta(t))*l[p2])*diff(theta(t),t)^2+(2*M[p2]*sin(alpha(t))*cos(theta(t))*l[p2]+2*M[p2]*cos(alpha(t))*sin(theta(t))*l[p2])*d...
EOM_orig := [(M[p2]*sin(alpha(t))*cos(theta(t))*l[p2]+M[p2]*cos(alpha(t))*sin(theta(t))*l[p2])*diff(theta(t),t)^2+(2*M[p2]*sin(alpha(t))*cos(theta(t))*l[p2]+2*M[p2]*cos(alpha(t))*sin(theta(t))*l[p2])*d...
EOM_orig := [(M[p2]*sin(alpha(t))*cos(theta(t))*l[p2]+M[p2]*cos(alpha(t))*sin(theta(t))*l[p2])*diff(theta(t),t)^2+(2*M[p2]*sin(alpha(t))*cos(theta(t))*l[p2]+2*M[p2]*cos(alpha(t))*sin(theta(t))*l[p2])*d...
EOM_orig := [(M[p2]*sin(alpha(t))*cos(theta(t))*l[p2]+M[p2]*cos(alpha(t))*sin(theta(t))*l[p2])*diff(theta(t),t)^2+(2*M[p2]*sin(alpha(t))*cos(theta(t))*l[p2]+2*M[p2]*cos(alpha(t))*sin(theta(t))*l[p2])*d...
EOM_orig := [(M[p2]*sin(alpha(t))*cos(theta(t))*l[p2]+M[p2]*cos(alpha(t))*sin(theta(t))*l[p2])*diff(theta(t),t)^2+(2*M[p2]*sin(alpha(t))*cos(theta(t))*l[p2]+2*M[p2]*cos(alpha(t))*sin(theta(t))*l[p2])*d...
EOM_orig := [(M[p2]*sin(alpha(t))*cos(theta(t))*l[p2]+M[p2]*cos(alpha(t))*sin(theta(t))*l[p2])*diff(theta(t),t)^2+(2*M[p2]*sin(alpha(t))*cos(theta(t))*l[p2]+2*M[p2]*cos(alpha(t))*sin(theta(t))*l[p2])*d...

Express the Euler-Lagrange equations of motion as functions of the states:

1) substitute (i.e. name) the acceleration states first!

2) then substitute the velocity states!

3) and only after, the position states, and the inputs!

>    EOM_states := subs( subs_Xqd, subs( subs_Xqdd, EOM_orig ) ):

>    EOM_states := subs( subs_Xq, subs_U, EOM_states );

EOM_states := [(M[p2]*sin(X[2])*cos(X[3])*l[p2]+M[p2]*cos(X[2])*sin(X[3])*l[p2])*X[6]^2+(2*M[p2]*sin(X[2])*cos(X[3])*l[p2]+2*M[p2]*cos(X[2])*sin(X[3])*l[p2])*X[5]*X[6]+(M[p1]*sin(X[2])*l[p1]+M[p2]*cos(...
EOM_states := [(M[p2]*sin(X[2])*cos(X[3])*l[p2]+M[p2]*cos(X[2])*sin(X[3])*l[p2])*X[6]^2+(2*M[p2]*sin(X[2])*cos(X[3])*l[p2]+2*M[p2]*cos(X[2])*sin(X[3])*l[p2])*X[5]*X[6]+(M[p1]*sin(X[2])*l[p1]+M[p2]*cos(...
EOM_states := [(M[p2]*sin(X[2])*cos(X[3])*l[p2]+M[p2]*cos(X[2])*sin(X[3])*l[p2])*X[6]^2+(2*M[p2]*sin(X[2])*cos(X[3])*l[p2]+2*M[p2]*cos(X[2])*sin(X[3])*l[p2])*X[5]*X[6]+(M[p1]*sin(X[2])*l[p1]+M[p2]*cos(...
EOM_states := [(M[p2]*sin(X[2])*cos(X[3])*l[p2]+M[p2]*cos(X[2])*sin(X[3])*l[p2])*X[6]^2+(2*M[p2]*sin(X[2])*cos(X[3])*l[p2]+2*M[p2]*cos(X[2])*sin(X[3])*l[p2])*X[5]*X[6]+(M[p1]*sin(X[2])*l[p1]+M[p2]*cos(...
EOM_states := [(M[p2]*sin(X[2])*cos(X[3])*l[p2]+M[p2]*cos(X[2])*sin(X[3])*l[p2])*X[6]^2+(2*M[p2]*sin(X[2])*cos(X[3])*l[p2]+2*M[p2]*cos(X[2])*sin(X[3])*l[p2])*X[5]*X[6]+(M[p1]*sin(X[2])*l[p1]+M[p2]*cos(...
EOM_states := [(M[p2]*sin(X[2])*cos(X[3])*l[p2]+M[p2]*cos(X[2])*sin(X[3])*l[p2])*X[6]^2+(2*M[p2]*sin(X[2])*cos(X[3])*l[p2]+2*M[p2]*cos(X[2])*sin(X[3])*l[p2])*X[5]*X[6]+(M[p1]*sin(X[2])*l[p1]+M[p2]*cos(...
EOM_states := [(M[p2]*sin(X[2])*cos(X[3])*l[p2]+M[p2]*cos(X[2])*sin(X[3])*l[p2])*X[6]^2+(2*M[p2]*sin(X[2])*cos(X[3])*l[p2]+2*M[p2]*cos(X[2])*sin(X[3])*l[p2])*X[5]*X[6]+(M[p1]*sin(X[2])*l[p1]+M[p2]*cos(...
EOM_states := [(M[p2]*sin(X[2])*cos(X[3])*l[p2]+M[p2]*cos(X[2])*sin(X[3])*l[p2])*X[6]^2+(2*M[p2]*sin(X[2])*cos(X[3])*l[p2]+2*M[p2]*cos(X[2])*sin(X[3])*l[p2])*X[5]*X[6]+(M[p1]*sin(X[2])*l[p1]+M[p2]*cos(...
EOM_states := [(M[p2]*sin(X[2])*cos(X[3])*l[p2]+M[p2]*cos(X[2])*sin(X[3])*l[p2])*X[6]^2+(2*M[p2]*sin(X[2])*cos(X[3])*l[p2]+2*M[p2]*cos(X[2])*sin(X[3])*l[p2])*X[5]*X[6]+(M[p1]*sin(X[2])*l[p1]+M[p2]*cos(...
EOM_states := [(M[p2]*sin(X[2])*cos(X[3])*l[p2]+M[p2]*cos(X[2])*sin(X[3])*l[p2])*X[6]^2+(2*M[p2]*sin(X[2])*cos(X[3])*l[p2]+2*M[p2]*cos(X[2])*sin(X[3])*l[p2])*X[5]*X[6]+(M[p1]*sin(X[2])*l[p1]+M[p2]*cos(...
EOM_states := [(M[p2]*sin(X[2])*cos(X[3])*l[p2]+M[p2]*cos(X[2])*sin(X[3])*l[p2])*X[6]^2+(2*M[p2]*sin(X[2])*cos(X[3])*l[p2]+2*M[p2]*cos(X[2])*sin(X[3])*l[p2])*X[5]*X[6]+(M[p1]*sin(X[2])*l[p1]+M[p2]*cos(...
EOM_states := [(M[p2]*sin(X[2])*cos(X[3])*l[p2]+M[p2]*cos(X[2])*sin(X[3])*l[p2])*X[6]^2+(2*M[p2]*sin(X[2])*cos(X[3])*l[p2]+2*M[p2]*cos(X[2])*sin(X[3])*l[p2])*X[5]*X[6]+(M[p1]*sin(X[2])*l[p1]+M[p2]*cos(...

Linearization  in the EOM's   of the Trigonometric Functions

Linearization of the equations of motion around the quiescent point of operation (in order to solve them).

Here, linearization around the zero angles, i.e. for small-amplitude oscillations.

Linearization around: alpha0 = 0, alpha_dot0 = 0, alpha1 = 0, and alpha_dot1 = 0

>    EOM_ser := EOM_states:

Generalized series expansions of the trigonometric functions is used (for small angles).

>    for i from 1 to Nq do
  for k from 1 to Np do
    EOM_ser[i] := subsop( 1 = convert( series( op( 1, EOM_ser[i] ), X[ k+1 ] ), polynom ), EOM_ser[i] );
  end do:
  EOM_ser[i] := simplify( EOM_ser[i] );
end do:

>    EOM_ser;

[Xd[4]*M[p2]+Xd[4]*M[c]+Xd[4]*M[h]+Xd[4]*M[p1]-M[p2]*l[p2]*Xd[6]-Xd[5]*M[p1]*l[p1]-Xd[5]*M[h]*L[p1]-M[p2]*l[p2]*Xd[5]-Xd[5]*M[p2]*L[p1]+X[2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*l[p2]*Xd[5]-Xd[5]*M[p2]*L[p1]+X[2]*M[p2]*l[p2]*X[6]^2+X[2]*X[5]^2*M[p1]*l[p1]+X[2]*M[p2]*l[p2]*...
[Xd[4]*M[p2]+Xd[4]*M[c]+Xd[4]*M[h]+Xd[4]*M[p1]-M[p2]*l[p2]*Xd[6]-Xd[5]*M[p1]*l[p1]-Xd[5]*M[h]*L[p1]-M[p2]*l[p2]*Xd[5]-Xd[5]*M[p2]*L[p1]+X[2]*M[p2]*l[p2]*X[6]^2+X[2]*X[5]^2*M[p1]*l[p1]+X[2]*M[p2]*l[p2]*...
[Xd[4]*M[p2]+Xd[4]*M[c]+Xd[4]*M[h]+Xd[4]*M[p1]-M[p2]*l[p2]*Xd[6]-Xd[5]*M[p1]*l[p1]-Xd[5]*M[h]*L[p1]-M[p2]*l[p2]*Xd[5]-Xd[5]*M[p2]*L[p1]+X[2]*M[p2]*l[p2]*X[6]^2+X[2]*X[5]^2*M[p1]*l[p1]+X[2]*M[p2]*l[p2]*...

Additional Insight: Inertia (or mass) Matrix: Fi

The nonlinear system of equations resulting from the Lagrangian mechanics can be written in the following matrix form:

F( q ) . qdd + G( q, qd ) . qd + H( q ) . q = L( q, qd, u )

F, G, and H are called, respectively, the mass, damping, and stiffness matrices.

They are symmetric in form.

The inertia (a.k.a. mass) matrix, F, gives indications regarding the coupling existing in the system.

>    Fi := Matrix( Nq, Nq ):

>    for i from 1 to Nq do
  for k from 1 to Nq do
    Fi[ i, k ] := simplify( diff( op( 1, EOM_states[i] ), Xd[k+Nq] ) );
    Fi[ i, k ] := collect( combine( Fi[ i, k ], trig ), cos );
  end do;
end do:

>    'F[i]' = Fi;

F[i] = Matrix(%id = 137153196)
F[i] = Matrix(%id = 137153196)
F[i] = Matrix(%id = 137153196)
F[i] = Matrix(%id = 137153196)
F[i] = Matrix(%id = 137153196)

Linearization of the inertia matrix for small-displacements

>    Fi_lin := Matrix( Nq, Nq ):

>    for i from 1 to Nq do
  for k from 1 to Nq do
    Fi_lin[ i, k ] := Fi[ i, k ];
    Fi_lin[ i, k ] := convert( series( Fi_lin[ i, k ], X[ 2 ] ), polynom );
    Fi_lin[ i, k ] := subs( subs_XUzero, Fi_lin[ i, k ] );
  end do;
end do:

>    'F_lin' = Fi_lin;

F_lin = Matrix(%id = 137153560)
F_lin = Matrix(%id = 137153560)
F_lin = Matrix(%id = 137153560)
F_lin = Matrix(%id = 137153560)
F_lin = Matrix(%id = 137153560)

Solving the Euler-Lagrange's Equations

To solve the Euler-Lagrange's equations, they need to be linear.

Reverse State Substitution for Pretty Display of the Solved EOM's

only for pretty print

>    subs_Xq_rev := { seq( X[i] = q[i], i=1..Nq ) }:
subs_Xqd_rev := { seq( X[i+Nq] = qd[i], i=1..Nq ) }:

>    subs_U_rev := { U[1] = V[m] }:
#subs_U_rev := { U[1] = F[c] }:

>    eom_collect_list := { seq( diff( q[i], t ), i=1..Nq ), seq( q[i], i=1..Nq ) };

eom_collect_list := {diff(theta(t),t), diff(alpha(t),t), diff(x[c](t),t), theta(t), x[c](t), alpha(t)}

>    if not assigned( J[p1] ) then
  eom_collect_list := eom_collect_list union { J[p1] };
end if;

eom_collect_list := {J[p1], diff(theta(t),t), diff(alpha(t),t), diff(x[c](t),t), theta(t), x[c](t), alpha(t)}

>    if not assigned( J[p2] ) then
  eom_collect_list := eom_collect_list union { J[p2] };
end if;

eom_collect_list := {J[p1], diff(theta(t),t), diff(alpha(t),t), diff(x[c](t),t), theta(t), x[c](t), J[p2], alpha(t)}

Solution to the Non-Linear Equations of Motion

Solve the non-linear form of the equations of motion for the states' second time derivatives

>    Xqdd_solset_nl := solve( convert( EOM_states, set ), convert( Xqdd, set ) ):

>    assign( Xqdd_solset_nl );

>    for i from 1 to Nq do
  Xd_nl[i+Nq] := simplify( Xd[i+Nq] ):
  unassign( 'Xd[i+Nq]' ):
end do:

pretty display w.r.t. the named system states

>    for i from 1 to Nq do
  Xd_nl[i+Nq] := simplify( subs( subs_U_rev, subs_Xq_rev, subs_Xqd_rev, Xd_nl[i+Nq] ) ):
end do:

>    for i from 1 to Nq do
  diff( qd[i], t ) = collect( Xd_nl[i+Nq], eom_collect_list );
end do:

Solution to the Linearized EOM's

Solve the linear form of the equations of motion for the states' second time derivatives

>    Xqdd_solset_ser := solve( convert( EOM_ser, set ), convert( Xqdd, set ) ):

>    assign( Xqdd_solset_ser );

Moreover, for small angles

>    subs_avsq_list := { X[Nq+2]^2 = 0, X[Nq+3]^2 = 0 }:

>    for i from 1 to Nq do
  Xd[i+Nq] := subs( subs_avsq_list, Xd[i+Nq] );
end:

pretty display w.r.t. the named system states

>    for i from 1 to Nq do
  diff( qd[i], t ) = collect( subs( subs_U_rev, subs_Xq_rev, subs_Xqd_rev, Xd[i+Nq] ), eom_collect_list );
end do;

diff(x[c](t),`$`(t,2)) = (-(-2*theta(t)^2*alpha(t)*R[m]*r[mp]^2*M[p2]^2*L[p1]^2*l[p2]^2+(2*M[p2]*l[p2]^2*R[m]*r[mp]^2*M[p1]*l[p1]^2-2*M[p1]*l[p1]*R[m]*r[mp]^2*M[p2]*l[p2]^2*L[p1])*theta(t)+(2*M[p2]*l[p...
diff(x[c](t),`$`(t,2)) = (-(-2*theta(t)^2*alpha(t)*R[m]*r[mp]^2*M[p2]^2*L[p1]^2*l[p2]^2+(2*M[p2]*l[p2]^2*R[m]*r[mp]^2*M[p1]*l[p1]^2-2*M[p1]*l[p1]*R[m]*r[mp]^2*M[p2]*l[p2]^2*L[p1])*theta(t)+(2*M[p2]*l[p...
diff(x[c](t),`$`(t,2)) = (-(-2*theta(t)^2*alpha(t)*R[m]*r[mp]^2*M[p2]^2*L[p1]^2*l[p2]^2+(2*M[p2]*l[p2]^2*R[m]*r[mp]^2*M[p1]*l[p1]^2-2*M[p1]*l[p1]*R[m]*r[mp]^2*M[p2]*l[p2]^2*L[p1])*theta(t)+(2*M[p2]*l[p...
diff(x[c](t),`$`(t,2)) = (-(-2*theta(t)^2*alpha(t)*R[m]*r[mp]^2*M[p2]^2*L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1]*l[p1]*R[m]*r[mp]^2*M[p2]*l[p2]^2*L[p1])*theta(t)+(2*M[p2]*l[p...
diff(x[c](t),`$`(t,2)) = (-(-2*theta(t)^2*alpha(t)*R[m]*r[mp]^2*M[p2]^2*L[p1]^2*l[p2]^2+(2*M[p2]*l[p2]^2*R[m]*r[mp]^2*M[p1]*l[p1]^2-2*M[p1]*l[p1]*R[m]*r[mp]^2*M[p2]*l[p2]^2*L[p1])*theta(t)+(2*M[p2]*l[p...
diff(x[c](t),`$`(t,2)) = (-(-2*theta(t)^2*alpha(t)*R[m]*r[mp]^2*M[p2]^2*L[p1]^2*l[p2]^2+(2*M[p2]*l[p2]^2*R[m]*r[mp]^2*M[p1]*l[p1]^2-2*M[p1]*l[p1]*R[m]*r[mp]^2*M[p2]*l[p2]^2*L[p1])*theta(t)+(2*M[p2]*l[p...
diff(x[c](t),`$`(t,2)) = (-(-2*theta(t)^2*alpha(t)*R[m]*r[mp]^2*M[p2]^2*L[p1]^2*l[p2]^2+(2*M[p2]*l[p2]^2*R[m]*r[mp]^2*M[p1]*l[p1]^2-2*M[p1]*l[p1]*R[m]*r[mp]^2*M[p2]*l[p2]^2*L[p1])*theta(t)+(2*M[p2]*l[p...

diff(alpha(t),`$`(t,2)) = (-(2*theta(t)^3*M[p2]^2*l[p2]^2*L[p1]*R[m]*r[mp]^2*alpha(t)^2-2*theta(t)^2*alpha(t)*M[p2]^2*L[p1]*l[p2]^2*R[m]*r[mp]^2+(2*l[p1]*M[p2]*l[p2]^2*R[m]*r[mp]^2*M[p1]-2*M[p1]*R[m]*r...
diff(alpha(t),`$`(t,2)) = (-(2*theta(t)^3*M[p2]^2*l[p2]^2*L[p1]*R[m]*r[mp]^2*alpha(t)^2-2*theta(t)^2*alpha(t)*M[p2]^2*L[p1]*l[p2]^2*R[m]*r[mp]^2+(2*l[p1]*M[p2]*l[p2]^2*R[m]*r[mp]^2*M[p1]-2*M[p1]*R[m]*r...
diff(alpha(t),`$`(t,2)) = (-(2*theta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r[mp]^2+(2*l[p1]*M[p2]*l[p2]^2*R[m]*r[mp]^2*M[p1]-2*M[p1]*R[m]*r...
diff(alpha(t),`$`(t,2)) = (-(2*theta(t)^3*M[p2]^2*l[p2]^2*L[p1]*R[m]*r[mp]^2*alpha(t)^2-2*theta(t)^2*alpha(t)*M[p2]^2*L[p1]*l[p2]^2*R[m]*r[mp]^2+(2*l[p1]*M[p2]*l[p2]^2*R[m]*r[mp]^2*M[p1]-2*M[p1]*R[m]*r...
diff(alpha(t),`$`(t,2)) = (-(2*theta(t)^3*M[p2]^2*l[p2]^2*L[p1]*R[m]*r[mp]^2*alpha(t)^2-2*theta(t)^2*alpha(t)*M[p2]^2*L[p1]*l[p2]^2*R[m]*r[mp]^2+(2*l[p1]*M[p2]*l[p2]^2*R[m]*r[mp]^2*M[p1]-2*M[p1]*R[m]*r...
diff(alpha(t),`$`(t,2)) = (-(2*theta(t)^3*M[p2]^2*l[p2]^2*L[p1]*R[m]*r[mp]^2*alpha(t)^2-2*theta(t)^2*alpha(t)*M[p2]^2*L[p1]*l[p2]^2*R[m]*r[mp]^2+(2*l[p1]*M[p2]*l[p2]^2*R[m]*r[mp]^2*M[p1]-2*M[p1]*R[m]*r...
diff(alpha(t),`$`(t,2)) = (-(2*theta(t)^3*M[p2]^2*l[p2]^2*L[p1]*R[m]*r[mp]^2*alpha(t)^2-2*theta(t)^2*alpha(t)*M[p2]^2*L[p1]*l[p2]^2*R[m]*r[mp]^2+(2*l[p1]*M[p2]*l[p2]^2*R[m]*r[mp]^2*M[p1]-2*M[p1]*R[m]*r...
diff(alpha(t),`$`(t,2)) = (-(2*theta(t)^3*M[p2]^2*l[p2]^2*L[p1]*R[m]*r[mp]^2*alpha(t)^2-2*theta(t)^2*alpha(t)*M[p2]^2*L[p1]*l[p2]^2*R[m]*r[mp]^2+(2*l[p1]*M[p2]*l[p2]^2*R[m]*r[mp]^2*M[p1]-2*M[p1]*R[m]*r...
diff(alpha(t),`$`(t,2)) = (-(2*theta(t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mp]^2+(2*l[p1]*M[p2]*l[p2]^2*R[m]*r[mp]^2*M[p1]-2*M[p1]*R[m]*r...
diff(alpha(t),`$`(t,2)) = (-(2*theta(t)^3*M[p2]^2*l[p2]^2*L[p1]*R[m]*r[mp]^2*alpha(t)^2-2*theta(t)^2*alpha(t)*M[p2]^2*L[p1]*l[p2]^2*R[m]*r[mp]^2+(2*l[p1]*M[p2]*l[p2]^2*R[m]*r[mp]^2*M[p1]-2*M[p1]*R[m]*r...
diff(alpha(t),`$`(t,2)) = (-(2*theta(t)^3*M[p2]^2*l[p2]^2*L[p1]*R[m]*r[mp]^2*alpha(t)^2-2*theta(t)^2*alpha(t)*M[p2]^2*L[p1]*l[p2]^2*R[m]*r[mp]^2+(2*l[p1]*M[p2]*l[p2]^2*R[m]*r[mp]^2*M[p1]-2*M[p1]*R[m]*r...
diff(alpha(t),`$`(t,2)) = (-(2*theta(t)^3*M[p2]^2*l[p2]^2*L[p1]*R[m]*r[mp]^2*alpha(t)^2-2*theta(t)^2*alpha(t)*M[p2]^2*L[p1]*l[p2]^2*R[m]*r[mp]^2+(2*l[p1]*M[p2]*l[p2]^2*R[m]*r[mp]^2*M[p1]-2*M[p1]*R[m]*r...
diff(alpha(t),`$`(t,2)) = (-(2*theta(t)^3*M[p2]^2*l[p2]^2*L[p1]*R[m]*r[mp]^2*alpha(t)^2-2*theta(t)^2*alpha(t)*M[p2]^2*L[p1]*l[p2]^2*R[m]*r[mp]^2+(2*l[p1]*M[p2]*l[p2]^2*R[m]*r[mp]^2*M[p1]-2*M[p1]*R[m]*r...
diff(alpha(t),`$`(t,2)) = (-(2*theta(t)^3*M[p2]^2*l[p2]^2*L[p1]*R[m]*r[mp]^2*alpha(t)^2-2*theta(t)^2*alpha(t)*M[p2]^2*L[p1]*l[p2]^2*R[m]*r[mp]^2+(2*l[p1]*M[p2]*l[p2]^2*R[m]*r[mp]^2*M[p1]-2*M[p1]*R[m]*r...
diff(alpha(t),`$`(t,2)) = (-(2*theta(t)^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1]*R[m]*r[mp]^2*M[p2]^2*l[p2]^2*L[p1]+2*M[p2]^2*l[p2]^...
diff(theta(t),`$`(t,2)) = (1/l[p2]^2*(2*theta(t)^3*M[p2]^3*l[p2]^3*L[p1]*R[m]*r[mp]^2*alpha(t)^2+(-2*M[p2]^3*L[p1]*l[p2]^3*R[m]*r[mp]^2-2*M[p1]*l[p1]*R[m]*r[mp]^2*M[p2]^2*l[p2]^2*L[p1]+2*M[p2]^2*l[p2]^...
diff(theta(t),`$`(t,2)) = (1/l[p2]^2*(2*theta(t)^3*M[p2]^3*l[p2]^3*L[p1]*R[m]*r[mp]^2*alpha(t)^2+(-2*M[p2]^3*L[p1]*l[p2]^3*R[m]*r[mp]^2-2*M[p1]*l[p1]*R[m]*r[mp]^2*M[p2]^2*l[p2]^2*L[p1]+2*M[p2]^2*l[p2]^...

Determine the System State-Space Matrices: A, B, C, and D

>    A_ss := Matrix( Nx, Nx ):

>    A_ss := deriveA( Xqdd, A_ss, Nq, subs_XUzero ):
A = A_ss;

A = Matrix(%id = 137153904)
A = Matrix(%id = 137153904)
A = Matrix(%id = 137153904)
A = Matrix(%id = 137153904)
A = Matrix(%id = 137153904)
A = Matrix(%id = 137153904)
A = Matrix(%id = 137153904)
A = Matrix(%id = 137153904)
A = Matrix(%id = 137153904)
A = Matrix(%id = 137153904)
A = Matrix(%id = 137153904)
A = Matrix(%id = 137153904)
A = Matrix(%id = 137153904)
A = Matrix(%id = 137153904)
A = Matrix(%id = 137153904)
A = Matrix(%id = 137153904)
A = Matrix(%id = 137153904)
A = Matrix(%id = 137153904)
A = Matrix(%id = 137153904)
A = Matrix(%id = 137153904)
A = Matrix(%id = 137153904)
A = Matrix(%id = 137153904)
A = Matrix(%id = 137153904)
A = Matrix(%id = 137153904)
A = Matrix(%id = 137153904)
A = Matrix(%id = 137153904)
A = Matrix(%id = 137153904)

>    B_ss := Matrix( Nx, Nu ):

>    B_ss := deriveB( Xqdd, B_ss, Nq, subs_XUzero ):
B = B_ss;

B = Matrix(%id = 137404524)

>    C_ss := IdentityMatrix( Nq, Nx ):
C = C_ss;

C = Matrix(%id = 137405124)

>    D_ss := Matrix( Ny, Nu, 0 ):
D = D_ss;

D = Matrix(%id = 137405556)

Write A, B, C, and D to a Matlab file

Save the state-space matrices A, B, C and D to a MATLAB file.

>    Matlab_File_Name := "DBIP_ABCD_eqns.m":

unassign variables, when necessary, for those present in the "Matlab_Notations" substitution set

>    if assigned( B[eq] ) then
  unassign( 'B[eq]' );
end if;

>    if assigned( B[p1] ) then
  unassign( 'B[p1]' );
end if;

>    if assigned( J[p1] ) then
  unassign( 'J[p1]' );
end if;

>    if assigned( B[p2] ) then
  unassign( 'B[p2]' );
end if;

>    if assigned( J[p2] ) then
  unassign( 'J[p2]' );
end if;

substitution set containing a notation consistent with that used in the MATLAB design script(s)

>    Matlab_Notations := {
M[c] = Mc, M[h] = Mh, B[eq] = Beq, K[t] = Kt, r[mp] = r_mp, eta[m] = Eff_m, eta[g]=Eff_g, K[g]=Kg, K[m]=Km, R[m]=Rm, M[p1] = Mp1, L[p1] = Lp1, l[p1] = lp1, J[p1] = Jp1, B[p1] = Bp1,  
M[p2] = Mp2, L[p2] = Lp2, l[p2] = lp2, J[p2] = Jp2, B[p2] = Bp2 }:

>    Experiment_Name := "Double Inverted Pendulum":

>    write_ABCD_to_Mfile( Matlab_File_Name, Experiment_Name, Matlab_Notations, A_ss, B_ss, C_ss, D_ss );

Procedure Printing

default:

>    #interface( verboseproc = 1 );

>    eval( lagrange_equations ):

>   

>   

>   

>   

>   

>   

>   

>   

>   

Click here to go back to top: Description Section.