Lab 5 Prelab
Lab 5 Prelab
Manipulator
Kevin Groves, Andrea Serrani
Department of Electrical and Computer Engineering
The Ohio State University
Columbus, OH 43210 USA
1 Introduction
In this experiment, we consider the nonlinear control of a robotic arm with joint flexibility. The
specific mechanism under investigation is an attachment to rotary Quanser experimental setup.
Flexibility is attained by attaching the link to the motor shaft using a pair of springs. There is
some discretion in choosing the joint stiffness as there are different locations that the springs can be
attached on the body as well as several spring choices.
The goal of this project is to model and control the flexible joint for the case in which the arm
is oriented vertically. This introduces a non-linearity into the system in the form of a sinusoid, as a
result of the potential energy due to gravity. The output to be controlled is the tip angle, which is
given by the sum of the motor angle θ and the joint deflection α with respect to the motor shaft.
The non-linear model of the dynamics will be linearized by means of state feedback in such a way
that the input-output response between the voltage applied to the motor and the tip angle becomes
that of a linear system. After the system has been rendered linear by feedback, it can be controlled
using any linear control system design.
ẋ = f (x) + g(x)u
(1)
y = h(x)
depicted in Figure 1 possesses a linear input/output map y = G(s)v between the new input v and
the system output y. This problem is known as the input/output feedback linearization problem, and
it is sometimes referred to as partial linearization problem (1). If the objective is that of finding
a control law of the kind (2) and a set of coordinates under which the closed loop system (3) is
1
u ẋ = f (x) + g(x)u
v β(x)v + y
y = h(x)
α(x)
G(s)
altogether a realization of the map u/y, then the problem in question is referred to as the exact
feedback linearization problem. It is worth noting that, although an output y = h(x) is specified for
the system (1), the entire state vector x ∈ Rn is assumed available for feedback.
2.1 Notation
We will adopt the following notation:
• A smooth vector field f (x) is a mapping assigning a point x ∈ Rn to a column vector whose
components are smooth functions of x ∈ Rn
f1 (x)
f2 (x)
f (x) = . .
..
fn (x)
• Given a vector field f : Rn → Rn and a function λ : Rn → R, both defined and smooth over
a domain D ⊂ Rn , we denote by
. ∂λ
Lf λ : R n → R , x 7→ Lf λ(x) = f (x)
∂x
the derivative of λ(x) along the vector field f (x). Note that Lf λ(x) is again a smooth function.
Therefore, higher order derivatives of λ(x) along f (x) are easily defined using the recursive
relation
k−1
. ∂Lf λ(x)
Lkf λ(x) = f (x) ,
∂x
for any integer k > 1.
2
2. Φ is smooth in D and Φ−1 is smooth in Φ(D)1 .
If the above properties hold for D = Φ(D) = Rn , then Φ is said to be a , global diffeomorphism.
One easy way to recognize a local diffeomorphism is the following. Suppose Φ is a smooth function
over a domain D. If the jacobian matrix ∂Φ/∂x is non singular at a point x◦ ∈ D, then Φ is a local
diffeomorphism in a neighborhood of x◦2 .
The importance of a local diffeomorphism for nonlinear systems lies in the fact that it represents a
nonlinear coordinate transformation, in the same way that a nonsingular matrix defines a change of
basis in a linear system. Suppose we are given a system of the kind (1) over a domain D ⊂ R n , and
a local diffeomorphism Φ defined in D. Letting z = Φ(x), we obtain
d ∂Φ
ż(t) = Φ(x(t)) = ẋ(t)
dt ∂x
and thus, in the new coordinate z the system (1) has the expression
ż = f¯(z) + ḡ(z)u
(4)
y = h̄(z)
where
∂Φ ∂Φ
f¯(z) = f (x) , ḡ(z) = g(x) , h̄(z) = [h(x)]x=Φ−1 (z) .
∂x x=Φ−1 (z) ∂x x=Φ−1 (z)
Note that (4) is defined in the domain Φ(D).3 Therefore, the coordinate transformation
φ1 (x)
φ2 (x)
z = Φ(x) =
... ,
φn (x)
yields a transformed system (4) in which
Lf φ1 (x) Lg φ1 (x)
Lf φ2 (x) Lg φ2 (x)
f¯(z) =
ḡ(z) = h̄(z) = h(Φ−1 (z)) .
... ...
Lf φn (x) x=Φ−1 (z) Lg φn (x) x=Φ−1 (z)
3. Lg Lr−1
f h(x◦ ) 6= 0.
Remark 2.1 It is important to point out that the relative degree of a systems is defined for a specific
output map h(x), and it can not exceed the dimension of the state space n.
1 The set Φ(D) is the set of all points y ∈ Rn such that y = Φ(x) for some x ∈ D
2 This can be verified using the Implicit Function Theorem
3 It is easy to verify that, as a result of the continuity of Φ −1 , the set Φ(D) is open and connected.
3
2.3.1 Example
In a linear SISO systems
ẋ = Ax + Bu
y = Cx
the relative degree is defined at each point in the state space. In this case, since f (x) = Ax, g(x) = B
and h(x) = Cx, we have
It can be shown that the integer satisfying these conditions is exactly equal to the difference between
the degree of the denominator polynomial and the degree of the numerator polynomial of the transfer
function of the system
G(s) = C(sI − A)−1 B .
Let us discuss a simpler and more intuitive characterization of the relative degree of a system
from the point of view of its trajectories. Suppose that x(t) is the trajectory of (1) originating from
a point x(t0 ) = x◦ at which a relative degree r < n is defined. For a sufficiently small interval [t 0 , t1 ]
the trajectory x(t) with t ∈ [t0 , t1 ] remains close to x◦ and thus we can assume that x(t) remains
in the neighborhood of x◦ in which conditions 1-3 in definition 2.1 hold. Taking derivative of the
output y(t) of the system, we obtain
∂h
y (1) (t) = ẋ = Lf h(x(t)) + Lg h(x(t))u(t) .
∂x
If the relative degree is greater than 1, for all t ∈ [t0 , t1 ] we have Lg h(x(t)) = 0, and therefore
If this is the case, then the second derivative of the output is given by
Continuing along these lines, it is easy to see that the relative degree at x ◦ being r means that the
derivatives of the output y(t) in a sufficiently small interval of time are given by
The relative degree r is exactly equal to the number of times one needs to differentiate the output
y(t) at time t = t0 in order to have the input u(t0 ) appear explicitly.
4
Lemma 2.1 Suppose the system (1) has relative degree r at x◦ . Then, the r × n matrix
∂h(x)
∂x
∂Lf h(x)
∂x
..
.
∂Lr−1 h(x)
f
∂x
has rank equal to r for all x in a neighborhood of x◦ .
This results suggests that the r smooth functions h(x), Lf h(x),. . .,Lr−1
f h(x) are good candidates
to define a local coordinate transformation in a neighborhood of x◦ . Since the dimension of the
state space is n and r ≤ n, we need n − r more functions to complete the construction of a local
diffeomorphism. At this regard, we can invoke the following result, which constitutes a nonlinear
analogue of the theorem of the completion of basis in linear algebra:
Theorem 2.2 Suppose the system (1) has relative degree r at x◦ . Let
.
φ1 (x) = h(x)
.
φ2 (x) = Lf h(x)
...
.
φr (x) = Lr−1 f h(x).
If r < n there exist n − r smooth functions φr+1 (x), . . . , φn (x) such that the mapping
φ1 (x)
φ2 (x)
Φ(x) =
...
φn (x)
has a nonsingular jacobian matrix ∂Φ/∂x in x◦ , and thus Φ(x) defines a local diffeomorphism in a
neighborhood of x◦ . Furthermore, it is always possible to choose φr+1 (x), . . . , φn (x) in such a way
that
Lg φi (x) = 0 , i = r + 1, . . . , n
for all x in a neighborhood of x◦ .
At this point, we know that we can construct a coordinate transformation z = Φ(x) in such a way
that the the first r components are exactly z1 = h(x), z2 = Lf h(x), . . ., zr = Lr−1
f h(x). In terms of
trajectories, this means thatk
z1 (t) = y(t) , z2 (t) = y (1) (t) , . . . zr (t) = y r−1 (t)
for all t in a sufficiently small interval [t0 , t1 ]. In view of this, and due to the choice of the other
n − r components of the diffeomorphism Φ(x), the system (1) in the new coordinates has the form
ż1 = z2
ż2 = z3
..
.
żr−1 = zr
żr = a(z) + b(z)u (5)
żr+1 = qr+1 (z)
..
.
żn = qn (z)
y = z1
5
u ẋ = f (x) + g(x)u y
1
v b(z)
v + y = h(x) x
z
− a(z)
b(z)
Φ(x)
where
a(z) = Lrf h(x)|x=Φ−1 (z) , b(z) = Lg Lr−1
f h(x)|x=Φ−1 (z) ,
b(z ◦ ) = Lg Lr−1
f h(x◦ ) 6= 0 .
As b(z) is a smooth function, b(z) 6= 0 in a neighborhood z ◦ . Consider the feedback law (see Figure 2)
1
u= [−a(z) + v] , (6)
b(z)
The feedback law (6), which is well defined in a neighborhood of z ◦ (x◦ in the original coordinates)
yields the closed loop system
ż1 = z2
ż2 = z3
..
.
żr−1 = zr
żr = v (7)
żr+1 = qr+1 (z)
..
.
żn = qn (z)
y = z1 .
6
It is easy to see that the control law has acted in such a way that the closed loop system has
been split into a linear and a nonlinear part. More precisely, let z = col(ξ, η), with dim ξ = r and
dim η = n − r. System (7) can be rewritten as
ξ˙ = Aξ + Bv
y = Cξ (8)
η̇ = q(η, ξ)
where
0 1 0 ··· 0 0
0 0 1 ··· 0 0
A= , B = . , C= 1 0 ··· 0 .
.. ..
.
0 0 0 ··· 0 1
The interconnection between the two subsystem is depicted in Figure 3. For the closed loop system
in Figure 2, the I/O map between v ed y is that of the linear system (A, B, C) with transfer function
1
G(s) = C(sI − A)−1 B =
sr
which is the transfer function of a chain of r integrators. It is easy to see that r is precisely the
difference between the degree of the denominator polynomial of G(s) and the degree of its numerator
polynomial.
v y
- G(s) -
ξ
?
η̇ = q(η, ξ)
It is worth noting that the control law (6) has rendered the partial state η unobservable from the
output y. Also, keep in mind that the control law (6), and consequently the closed loop system (8),
remain valid only in the neighborhood of the point x◦ at which the relative degree is defined.
If the system has relative degree n, then the diffeomorphism Φ(x) is found immediately as
h(x)
Lf h(x)
Φ(x) = .. ,
.
Lfn−1 h(x)
7
yields the n dimensional linear closed loop system
ż1 = z2
ż2 = z3
..
. (9)
żn−1 = zn
żn = v
y = z1 .
It is thus clear that our ability to find a change of coordinates and a feedback law that at the same
time produces a linear I/O map and transform the original nonlinear system into a linear system
depends exclusively on an intrinsic property of the nonlinear system, that is, its relative degree at a
point. Note that the relative degree of a system remains the same independently of the chosen set
of coordinates.
The system has global 4 relative degree 2 with respect to the given output. It is easy to see, in fact,
that the system is already in normal form, with
u = x1 − (1 − x21 )x2 + v
ẋ1 = x2
ẋ2 = v
y = x1 .
Assume, on the other hand, that the output for the system is given by y = x 21 + x2 . It is easy to say
that in this case the system has global relative degree 1, since
Lg h(x) = 1 , ∀ x ∈ R2 .
The choice for the first function of the coordinate transformation is obviously φ 1 (x) = h(x) = x21 +x2 .
For the second function φ2 (x), we are free to choose any function which form a local diffeomorphism
with φ1 (x) and such that Lg φ2 (x) = 0. For instance, z2 = x1 is a good choice, since
2
x1 + x 2
Φ(x) =
x1
8
which is nonsingular for any x ∈ R2 . The inverse transformation is readily seen to be
−1 z2
x = Φ (z) = .
z1 − z22
At this point, define the setpoint error e1 (t) = y(t) − yd , and, since yd is constant, note that e(t)
satisfies
(n)
e1 (t) = v(t) .
The above equation has state-space realization
ė = Ae + Bv
e1 = Ce
In order to drive the error to zero asymptotically it suffices to compute a state feedback matrix
K ∈ R1×n such that A + BK has all eigenvalues with Re[s] < 0, which exists since the pair (A, B)
is controllable, and apply the outer/loop control v = Ke. The resulting control system is shown in
Figure 4.
9
inner loop
K = K h + Kl , V = V g + Vs
being
Vg = mgh cos(θ + α)
1
Vs = Ks α 2
2
1
Kh = Jh θ̇2
2
1
Kl = Jl (θ̇ + α̇)2 ,
2
10
where Vg is the potential energy due to gravity, Vs is the potential energy due to the springs, Kh is
the kinetic energy of the hub, and Kl is the kinetic energy of the load. Also, m is the mass of the
shaft, g is the gravity constant, h is the height of the center of gravity of the link with respect to
the rest position, Jh is the inertia at the motor output, Jl is the inertia of the arm, and Ks is the
spring stiffness. The value of the constant Ks depends on the way the springs are attached to the
link. Following the Quanser manual, the expression for Ks is
2R 3
Ks = 3 (Dd − Rr 2 )Fr + (D 2 d − DLd + Rr 2 L)K
D2
D = r 2 + (R − d)2 ,
where R is the arm anchor point, d is the body “Y” anchor point, r is the body “X” anchor point,
K is the spring stiffness, Fr is the spring restoring force, and L is the spring length at rest. The
values of the constants can be found in Table 1.
Jl θ̈ + Jl α̈ + Ks α − mgh sin(θ + α) = 0
(10)
(Jh + Jl )θ̈ + Jl α̈ − mgh sin(θ + α) = τ
In the above equations, τ is the torque produced by the motor. The torque is commanded by the
voltage v applied to the armature, which represent the control input to the system. The relationship
between the torque and the applied voltage is given in the Quanser lab manual as
v = iRm + Km Kg ω
which gives
v Km Kg
i = − ω,
Rm Rm
being ω the angular velocity of the motor, i the armature current, and Rm the motor resistance,
and Km and Kg constant parameters. Since
τ
i =
Kg Km
θ̇ = ω,
θ = x1
α = x2
θ̇ = x3
α̇ = x4 ,
11
Parameter Symbol Value
Spring Stiffness Ks 1.61 [N/m]
Inertia of hub Jh 0.0021 [Kgm2 ]
Link Mass m 0.403 [Kg]
Grav. Const. g -9.81 [N/m]
Height of C.M. h 0.06 [m]
Motor Const. Km 0.00767 [N/rad/s]
Gear Ratio Kg 70
Load Inertia Jl 0.0059 [Kgm2 ]
Motor Resist. Rm 2.6 [Ω]
x˙1 = x3
x˙2 = x4
2
Ks Km Kg2 Km Kg
x˙3 = x2 − x3 + v
Jh Rm Jh Rm Jh
2
Ks Km Kg2 Km Kg Ks mgh
x˙4 = − x2 + x3 − v− x2 + sin(x1 + x2 ) .
Jh Rm Jh Rm Jh Jl Jl
Letting u = v, and choosing as output the tip position y = x1 + x2 , the system can now be given
the usual state-space form
ẋ = f (x) + g(x)u
(11)
y = h(x) ,
being
x3
x4
f (x) =
2
Ks Km Kg2
Jh x 2 − R m Jh x 3
2
Km Kg2
−( K
Jh +
s Ks
Jl )x2 + mgh
Jl sin(x1 + x2 ) + R m Jh x 3
0
0
g(x) =
Km Kg ,
h(x) = x1 + x2 .
R m Jh
K K
− Rm g
m Jh
4 Problems
In preparation for the laboratory, you are asked to solve the following problems:
• Problem 1 Determine the relative degree of the flexible joint manipulator model (11) with
respect to the given input and the given output. Is the relative degree of the system (11)
dependent on the state x?
• Problem 2 Compute a change of coordinates z = Φ(x) that puts the given system in normal
form.
12
• Problem 3 Find a feedback linearizing control u = α(x)+β(x)v. What is the transfer function
G(s) of the closed loop system between the new input v and the output y?
• Problem 4 Implement the original plant model and the linearizing controller in Simulink.
• Problem 5 Compute an outer loop state-feedback linear controller v = Kz that regulates the
tip position y(t) to a constant setpoint yd . You can use either LQR or pole placement.
13