Anda di halaman 1dari 6

# Appendix A

## State Space Tutorial

Gantry Crane: An Example
The following gure shows a gantry crane with one degree of freedom for the cart. The mass of the load is assumed
to be concentrated and equal to m. The combined mass of the cart and the pulley is M. The length of the cable is
l and its mass is assumed to be negligible.The cart is subject to the external force of f(t) in the x direction. The
movement of the cart is subject to friction proportional to the speed with constant of damping d. The nal desired
position of the load is vertical, ( = 0) and at a distance X
0
from the z-axis.
1 Equation of Motion, EOM
The cart can only move in the x direction. Assuming the x-coordinate of the cart to be x(t) and the tilt angle to
be (t), the coordinates of the load x
L
(t) and z
L
(t), will be;
x
L
(t) = x(t) + l sin((t)) (1)
z
L
(t) = l cos((t)) (2)
In the sequel the dependence on t is dropped in writing the equations but it is assumed that this dependence is
understood. Therefore, for instance, x(t) will be written just as x.
1
2 Lagrangian Mechanics
In the Lagrangian formulation we have to construct the Lagrangian, L = T V , where T is the total kinetic energy
and V is the total potential energy of the system. The equations governing the system then would be;
d
dt
L
q
i

L
q
i
= f
i
i = 1...n
where q
i
is the i
th
generalized coordinate and f
i
is the generalized force in the direction of this coordinate.
In this example we have chosen x and as our generalized coordinate. The carts movement is conned only to the
x direction. Its position is x and its velocity x. The position of the load is;
x
L
= x + l sin()
z
L
= l cos()
The velocity of the load in the x and z directions therefore are;
x
L
= x + l cos()

z
L
= l sin()

v
=
_
x
2
L
+ z
L
2
=
_
x
2
+ 2l cos() x

+ l
2

2
The forces acting on the system are the control force f and the frictional damping d x in the x direction. Therefore
the equations in the x and coordinates are;
d
dt
L
x

L
x
= f d x (3)
d
dt
L

= 0 (4)
The kinetic energy of the system is;
T =
1
2
Mv
2
cart
+
1
2
mv
2
Substituting we get;
T =
1
2
M x
2
+
1
2
m( x
2
+ 2l cos() x

+ l
2

2
)
The potential energy is equal to;
V = mgl cos()
Therefore the Lagrangian is obtained as;
L = T V =
1
2
M x
2
+
1
2
m
_
x
2
+ 2l cos() x

+ l
2

2
_
+ mgl cos()
Computing the derivatives in the x and coordinates we have;
L
x
= (M + m) x + ml cos()

d
dt
L
x
= (M + m) x + ml cos()

ml sin()

2
L
x
= 0
L

= ml cos x + ml
2

d
dt
L

= ml cos() x + ml
2

ml sin() x

= ml sin x

mgl sin()
2
The equations of motion in the two chosen coordinates are obtained by substituting the above derivatives in (3)
and (4);
(M + m) x + ml cos()

ml sin()

2
+ d x = f (5)
ml[cos() x + l

+ g sin()] = 0 (6)
These two generalized coordinate equations are governing the dynamic behavior of the crane.
3 The output equation
The desired position of the load (and the cart) is at a distance of X
0
from the z-axis with the cable at vertical
position = 0. So the output equation would be:
Y =
_
x

_
4 Formulating the equations in state space
The rst step in putting the equations in the state space is to de-couple the second derivatives. Therefore, the
equations governing the gantry crane becomes;
(M + m) x + ml cos()

= f d x + ml sin()

2
ml[cos() x + l

= g sin()]
4.1 The vector matrix method
Putting these equation in the vector-matrix form we obtain;
_
M + m ml cos()
ml cos() ml
2
_ _
x

_
=
_
ml sin()

2
d x
mgl sin()
_
+
_
f
0
_
Inverting the matrix that multiplies the vector of the second derivatives we get;
_
1
M+mmcos()
2

cos()
l(M+mmcos()
2
)

cos()
l(M+mmcos()
2
)

M+m
ml
2
(M+mmcos()
2
)
_
Multiplying both side of the equation by this matrix we get;
_
x

_
=
_
ml sin()

2
d x+mg sin() cos()
(M+mmcos()
2
)

ml sin() cos()

2
cos()d x+g(M+m) sin()
l(M+mmcos()
2
)
_
+
_
1
M+mmcos()
2

cos()
l(M+mmcos()
2
)

cos()
l(M+mmcos()
2
)

M+m
ml
2
(M+mmcos()
2
)
_
_
f
0
_
Dening the states of the system and the control force as;
X ==
_

_
X
1
X
2
X
3
X
4
_

_
=
_

_
x
x

_
U =
_
U
1

=
_
f

Taking the derivatives of the states and substituting from the above, the nonlinear equations governing the states
is derived;

X =
_

X
1

X
2

X
3

X
4
_

_
=
_

_
x
x

_
= F(X, U) =
_

_
X
2
ml sin(X
3
)
_
X
4
2
_
dX
2
+ mg sin(X
3
) cos(X
3
) + U
1
_
M + m mcos(X
3
)
2
_
X
4
ml sin(X
3
) cos(X
3
)
_
X
4
2
_
cos(X
3
)dX
2
+ (M + m)g sin(X
3
) + cos(X
3
)U
1
l
_
M + m mcos(X
3
)
2
_
_

_
3
The equations in this example allow the separation of the control input so that we have;

X = F
1
(X) +F
2
(X)U
=
_

_
X
2
ml sin(X
3
)
_
X
4
2
_
dX
2
+ mg sin(X
3
) cos(X
3
)
_
M + m mcos(X
3
)
2
_
X
4
ml sin(X
3
) cos(X
3
)
_
X
4
2
_
cos(X
3
)dX
2
+ (M + m)g sin(X
3
)
l
_
M + m mcos(X
3
)
2
_
_

_
+
_

_
0
1
_
M + m mcos(X
3
)
2
_
0
cos(X
3
)
l
_
M + m mcos(X
3
)
2
_
_

_
_
U

## 4.2 The output equation

Expressing the output in terms of the states we get;
Y =
_
X
1
X
3
_
= H(X, U)
5 Equilibrium (xed) points
When the system is in equilibrium, all derivatives are zero. In this example when the system is in equilibrium, the
external control force in the x-direction has to be zero. Therefore, after substituting zero for all the derivatives, we
obtain the following equations;
0 = U
0 = X
2
0 = ml sin(X
3
)
_
X
4
2
_
dX
2
+ mg sin(X
3
) cos(X
3
)
0 = X
4
0 = ml sin(X
3
) cos(X
3
)
_
X
4
2
_
cos(X
3
)dX
2
+ (M + m)g sin(X
3
)
Solving these equations we nd that X
1
could have any value, choosing it to be X
1
= X
0
we nd that, X
2
= 0,
X
3
= 0 , , X
4
= 0, and U = 0. There are two equilibrium (xed) points for this system. The equilibrium point
{X
1
= X
0
, X
2
= 0, X
3
= 0, X
4
= 0, U = 0} is stable and the equilibrium point {X
1
= X
0
, X
2
= 0, X
3
= , X
4
= 0, U = 0}
is not feasible and certainly unstable.
6 Linearization
Many systems are governed by state equations of the form

X = F(X, U), with equilibrium point(s)

X

= 0,
F(X

, U

) = 0. When changes in the states and the control are small, these equations are linearized around an
equilibrium point. For the above gantry crane system the equation governing it and the equilibrium points are;

X = F(X, U) =
_

_
f
1
(X, U)
f
2
(X, U)
f
3
(X, U)
f
4
(X, U
_

_
Y = H(X, U) =
_
h
1
(X, U)
h
2
(X, U)
_
U

1
=
_
0

1
=
_

_
X

1
X

2
X

3
X

4
_

_
=
_

_
X
0
0
0
0
_

_
4
U

2
=
_
0

2
=
_

_
X

1
X

2
X

3
X

4
_

_
=
_

_
X
0
0

0
_

_
Let;
X
i
= X

i
+ X
i
= X

i
+ x
i
i = 1 4
U = U

+ u
or in matrix vector form;
X = X

+x
U = U

+u
Then we have;
d
dt
(X

+x) = F(X

+x, U

+u)
Expanding the above function in Taylor series around the point {X

, U

} we will have;
d
dt
(X

) +
d
dt
(x) = F(X

, U

) +

X
F(X, U) |
X=X

,U=U
+

U
F(X, U) |
X=X

,U=U
+H.O.T.
Since;
d
dt
(X

) = F(X

, U

) = 0
Neglecting the H.O.T. we nally get;
d
dt
(x) =
_

X
F(X, U) |
X=X

,U=U

_
x +
_

U
F(X, U) |
X=X

,U=U

_
u
= Ax +bu
Dening the following constant matrices we derive;
A = J =
_

_
f1
X1

f1
X4
.
.
.
.
.
.
.
.
.
f4
X1

f4
X4
_

_ b =
_

_
f1
U
.
.
.
f4
U
_

_
d
dt
(x) = Ax +bu
This is the linearized state space equation for the above system. The output equation is already linear, therefore
we have;
y = Cx +Du
For the example at hand we have;
f
1
(X, U) = X
2
f
2
(X, U) =
ml sin(X
3
)
_
X
4
2
_
dX
2
+ mg sin(X
3
) cos(X
3
) + U
_
M + m mcos(X
3
)
2
_
f
3
(X, U) = X
4
f
4
(X, U) =
ml sin(X
3
) cos(X
3
)
_
X
4
2
_
cos(X
3
)dX
2
+ (M + m)g sin(X
3
) + cos(X
3
)U
l
_
M + m mcos(X
3
)
2
_
Employing the numerical values;
M = 100 kg m = 100 kg x
0
= 10 m d = 10 m g = 9.81 m/s
2
f
1
(X, U) = X
2
f
2
(X, U) =
1000 sin(X
3
)X
4
2
10X
2
+ 981 sin(X
3
) cos(X
3
)
200 100 cos(X
3
)
f
3
(X, U) = X
4
f
4
(X, U) =
0.1
_
1000 sin(X
3
) cos(X
3
)X
4
2
10 cos(X
3
)X
2
+ 1962 sin(X
3
) + cos(X
3
)U
_
200 100 cos(X
3
)
5
Linearizing around the stable equilibrium point;
a
ij
= j
ij
=
f
i
(X, U)
X
j
|
X1=X0,X2=0,X3=0,X4=0,U=0
i = 1 4 j = 1 4
b
i
=
f
i
(X, U)
U
|
X1=X0,X2=0,X3=0,X4=0,U=0
i = 1 4
Evaluating we get;
A =
_

_
0 1 0 0
0 0.100 9.810 0
0 0 0 1
0 0.010 1.962 0
_

_
B =
_

_
0
0.010
0
0.001
_

_
C =
_
1 0 0
0 0 1 0
_
D =
_
0

_

_
x
1
x
2
x
3
x
4
_

_
=
_

_
0 1 0 0
0 0.100 9.810 0
0 0 0 1
0 0.010 1.962 0
_

_
_

_
x
1
x
2
x
3
x
4
_

_
+
_

_
0
0.010
0
0.001
_

_
_
u
1

_
y
1
y
2
_
=
_
1 0 0 0
0 0 1 0
_
_

_
x
1
x
2
x
3
x
4
_

_
+
_
0
_
u
1

x = Ax +Bu
y = Cx +Du
6