Exercise 4

Problem 1: Controller parameterizations

This problem studies the equivalence between the below 2-dof controller parameterizations

obs_command.pngCffCfb.pngRST.png

1.A:

Show that the observer-based feedback control law LaTeX: u=-L\hat x + l_r y_ru=Lˆx+lryr, where LaTeX: \hat xˆx is given by a Kalman filter, kan be written as

LaTeX: U(s) = -C_{\text{fb}}Y(s) + C_\text{ff}Y_r(s)U(s)=CfbY(s)+CffYr(s),

with

LaTeX: \begin{aligned}
C_\text{fb}(s) & = L(sI - A + BL + KC)^{-1} K \\
C_\text{ff} & = (I - L(sI - A + BL + KC)^{-1}B)l_r \\
& = (I + L(sI - A + KC)^{-1}B)^{-1}l_r
\end{aligned}Cfb(s)=L(sIA+BL+KC)1KCff=(IL(sIA+BL+KC)1B)lr=(I+L(sIA+KC)1B)1lr

1.B

Show that the controller above can be written as

LaTeX: R(s)U = -S(s)Y + T(s)Y_rR(s)U=S(s)Y+T(s)Yr,

with

LaTeX: \begin{aligned}
R(s) & = \det(sI - A + BL + KC) \\
T(s) & = l_r\cdot\det(sI - A + KC)
\end{aligned}R(s)=det

Hence, the observer polynomial equals the zero polynomial of the feedforward controller LaTeX: C_\text{ff}C_\text{ff}

Problem 2: Euclid, Bezout and Diophantine

Detail of Raphael's impression of Euclid, teaching students in The School of Athens (1509–1511)

(From wikipedia)

This exercise takes you through Euclid's algorithm, the Bezout identity and Diophantine equations. Going through this takes a bit of work, but will give you the tools to understand and implement pole-placing algorithms.

Euclid's algorithm

Let LaTeX: ll, LaTeX: mm and LaTeX: nn be natural numbers. If LaTeX: m = knm = kn for some natural number LaTeX: kk, then LaTeX: nn is a divisor of LaTeX: mm. If also LaTeX: l = k'nl = k'n for some natural number LaTeX: k'k', then LaTeX: mm is a common divisor of LaTeX: ll and LaTeX: mm.

Euclid's algorithm finds the greatest common divisor of two natural numbers.

2a)

 

  •  Let LaTeX: m > nm > n and let LaTeX: ll be the greatest common divisor of LaTeX: mm and LaTeX: nn (LaTeX: l = \textrm{gcd}(m, n)l = \textrm{gcd}(m, n)). Prove that LaTeX: l = \textrm{gcd}(m - n, n)l = \textrm{gcd}(m - n, n)

Now, let LaTeX: m_0 = mm_0 = m, LaTeX: n_0 = nn_0 = n and consider the recursion

LaTeX: \begin{aligned}
m_{i+1} & = \max(m_i-n_i, n_i) \\
n_{i+1} & = \min(m_i-n_i, n_i)
\end{aligned}\begin{aligned} m_{i+1} & = \max(m_i-n_i, n_i) \\ n_{i+1} & = \min(m_i-n_i, n_i) \end{aligned}.

2b)

  • Show that if LaTeX: n_i = 0n_i = 0 for some LaTeX: ii, then LaTeX: m_i = gcd(m, n)m_i = gcd(m, n).
  • Show that the algorithm converges in finite time.
  • Compute LaTeX: gcd(210, 84)gcd(210, 84) using Euclid's algorithm

An improvement due to Gabriel Lamé (1844)

image.png

Let LaTeX: mm and LaTeX: nn be integers. Define LaTeX: r_{-2} = mr_{-2} = m and LaTeX: r_{-1} = nr_{-1} = n. Given LaTeX: r_{k-2}r_{k-2} and LaTeX: r_{k-1}r_{k-1} perform division with remainder by finding an integer quotient LaTeX: q_kq_k and remainder LaTeX: r_kr_k:

LaTeX: r_{k-2} = q_k r_{k-1} + r_kr_{k-2} = q_k r_{k-1} + r_k,

until LaTeX: r_n = 0r_n = 0. This gives a sequence LaTeX: r_{-2} = m, r_{-1} = n,r_0, \ldots, r_{n} = 0r_{-2} = m, r_{-1} = n,r_0, \ldots, r_{n} = 0.

2c)

  • Prove that the above recursion converges.
  • Prove that LaTeX: r_{n-1}r_{n-1}is a common divisor of LaTeX: r_{-2}, r_{-1}, \ldots, r_{n-2}r_{-2}, r_{-1}, \ldots, r_{n-2}
  • Let LaTeX: ll be another common divisor of LaTeX: mm and LaTeX: nn, show that LaTeX: ll also divides LaTeX: r_{n-1}r_{n-1}
  • Compute LaTeX: gcd(210, 84)gcd(210, 84) using the improved version.

Divisors of integers are defined analogously to natural numbers.

Bézout's identity

image.png

Bezout's identity: Assume that LaTeX: mm and LaTeX: nn are integers and that LaTeX: d = \textrm{gcd}(m, n)d = \textrm{gcd}(m, n). Then there exist integers LaTeX: xx and LaTeX: yy such that LaTeX: mx + ny = dmx + ny = d.

2d)

  • Show that if LaTeX: (x, y)(x, y) solves LaTeX: mx + ny = dmx + ny = d, then all solutions can be obtained from LaTeX: \left( x - k\frac{n}{d}, y + k \frac{m}{d}\right)\left( x - k\frac{n}{d}, y + k \frac{m}{d}\right).
  • Use Euclid's algorithm (based on division with remainder) to prove Bezout's identity.
  • Show that the extended euclidean algorithm (below) computes x and y with LaTeX: r_{n-1} = dr_{n-1} = d, LaTeX: x = s_{n-1}x = s_{n-1} and LaTeX: y = t_{n-1}y = t_{n-1}.

The extended euclidean algorithm adds two extra quantities LaTeX: s_{-2} = 1, s_{-1} = 0, \ldots, s_{n-1}s_{-2} = 1, s_{-1} = 0, \ldots, s_{n-1} and LaTeX: t_{-2} = 0, t_{-1}= 1, \ldots, t_{n-1}t_{-2} = 0, t_{-1}= 1, \ldots, t_{n-1} (in addition ro LaTeX: r_kr_k and LaTeX: q_kq_k that follow the recursive relationship

LaTeX: \begin{aligned}
r_{k-2} & = q_k r_{k-1} + r_k \\
s_{k-2} & = q_ks_{k-1} + s_k \\
t_{k-2} & = q_kt_{k-1} + t_k
\end{aligned}\begin{aligned} r_{k-2} & = q_k r_{k-1} + r_k \\ s_{k-2} & = q_ks_{k-1} + s_k \\ t_{k-2} & = q_kt_{k-1} + t_k \end{aligned}

Diophantine equations

Diophantus of alexandria, source: https://accessoclub.com/diophantus-the-father-of-algebra/

Consider the linear Diophantine equation LaTeX: ax + by = cax + by = c where LaTeX: a, b, ca, b, c are fixed integers and LaTeX: x, yx, y are unknown integers to be solved for.

2e)

  • Prove that the linear Diophantine equation has a solution if, and only if LaTeX: c = k \cdot \textrm{gcd}(a, b)c = k \cdot \textrm{gcd}(a, b).

All of the development until now concerned integers. So how does this relate to pole placement? In L7:Pole Placement, we reduced pole-placement to solving a polynomial equation known as a polynomial Diophantine Equation:

LaTeX: AX + BY = CAX + BY = C

where LaTeX: A, B,\ CA, B,\ C are given polynomials and LaTeX: X,\ YX,\ Y are unknowns to be solved for.

Polynomials (over a field) share many of the algebraic properties of integers:

Property Polynomials Integers
Irreducability LaTeX: (s - a)(s - a) for any LaTeX: aa primes: n = -1,1,2,3,5,7,11..
Fundamental theorem Algebra: LaTeX: X(S) = (s-a_1)^{n_1}(s-a_2)^{n_2}\cdots(s-a_n)^{n_n}X(S) = (s-a_1)^{n_1}(s-a_2)^{n_2}\cdots(s-a_n)^{n_n}

Arithmetic: LaTeX: m = a_1^{n_1}a_2^{n_2}\cdots a_n^{n_n}m = a_1^{n_1}a_2^{n_2}\cdots a_n^{n_n}, LaTeX: a_ia_i prime

greatest common divisor product of shared irreducible factors (with multiplicities) product of shared primes (with multiplicities)
euclidean division Given LaTeX: A(s), B(s) \neq 0A(s), B(s) \neq 0 there exist two unique polynomials LaTeX: Q(s), R(s)Q(s), R(s) with LaTeX: \textrm{deg}R(s) < \textrm{deg}B(s)\textrm{deg}R(s) < \textrm{deg}B(s) so that LaTeX: A(s) = Q(s)B(s) + R(s)A(s) = Q(s)B(s) + R(s) Given integers: LaTeX: a, b \neq 0a, b \neq 0 there exist two unique integers LaTeX: q,rq,r with LaTeX: |r| < |b||r| < |b| so that LaTeX: a = bq + ra = bq + r

2f) Translate 2c-2e to polynomials.

Problem 3

Use Euclid's algorithm to find all solutions to the equation

LaTeX: s^2x(s) + (0.5s + 1)y(s) = 1s^2x(s) + (0.5s + 1)y(s) = 1

where LaTeX: xx and LaTeX: yy are polynomials. Use the results to find a solution to the equation

LaTeX: s^2f(s) + (0.5s + 1)g(s) = (s^2 + 2\zeta_c\omega_c s + \omega_c^2)(s^2 + 2\zeta_o\omega_os + \omega_o^2)s^2f(s) + (0.5s + 1)g(s) = (s^2 + 2\zeta_c\omega_c s + \omega_c^2)(s^2 + 2\zeta_o\omega_os + \omega_o^2)

such that the polynomials LaTeX: ff and LaTeX: gg have degrees 2 and 1 respectively.

Problem 4

For polynomials LaTeX: A, B, CA, B, C with LaTeX: \textrm{deg}(A) = \textrm{deg}(B) = n\textrm{deg}(A) = \textrm{deg}(B) = n and unknown polynomials LaTeX: X, YX, Y with degrees LaTeX: n - 1n - 1.
The Diophantine equation can be posed as a set of linear equations:

LaTeX: \begin{bmatrix}
a_0 & 0  & \ldots & 0 & b_0 & 0  & \ldots & 0 \\
a_1 & a_0 & \ldots & 0 & b_1 & b_0 & \ldots & 0\\
\vdots & \vdots & \ddots & \vdots & \vdots & \vdots & \ddots & \vdots\\
a_{n-1} & a_{n-2} & \ldots & a_0 &  b_{n-1} & b_{n-2} & \ldots & b_0 \\
 a_n & a_{n-1} & \ldots & a_1  & b_n & b_{n-1} & \ldots & b_1 \\
0 & a_n & \ldots &a_2 & 0 & b_n & \ldots & b_2 \\
\vdots & \vdots & \ddots & \vdots & \vdots & \vdots & \ddots & \vdots\\
0 & \ldots & 0 & a_n &  0 & \ldots & 0 & b_n
\end{bmatrix}
\begin{bmatrix}
x_0\\ \vdots \\x_{n-1}\\ y_0 \\ \vdots \\ y_{n-1} 
\end{bmatrix}
=
\begin{bmatrix}
c_0 \\ c_1 \\c_2 \\ \vdots \\c_n \\c_{n+1} \\ c_{n+2} \\ \vdots \\ c_{2n - 1}
\end{bmatrix}\begin{bmatrix} a_0 & 0 & \ldots & 0 & b_0 & 0 & \ldots & 0 \\ a_1 & a_0 & \ldots & 0 & b_1 & b_0 & \ldots & 0\\ \vdots & \vdots & \ddots & \vdots & \vdots & \vdots & \ddots & \vdots\\ a_{n-1} & a_{n-2} & \ldots & a_0 & b_{n-1} & b_{n-2} & \ldots & b_0 \\ a_n & a_{n-1} & \ldots & a_1 & b_n & b_{n-1} & \ldots & b_1 \\ 0 & a_n & \ldots &a_2 & 0 & b_n & \ldots & b_2 \\ \vdots & \vdots & \ddots & \vdots & \vdots & \vdots & \ddots & \vdots\\ 0 & \ldots & 0 & a_n & 0 & \ldots & 0 & b_n \end{bmatrix} \begin{bmatrix} x_0\\ \vdots \\x_{n-1}\\ y_0 \\ \vdots \\ y_{n-1} \end{bmatrix} = \begin{bmatrix} c_0 \\ c_1 \\c_2 \\ \vdots \\c_n \\c_{n+1} \\ c_{n+2} \\ \vdots \\ c_{2n - 1} \end{bmatrix}

If LaTeX: AA and LaTeX: BB have common factors, what are the left and right null spaces?

Problem 5

Prove that if LaTeX: \lim_{s \to 0} P(s) \neq 0\lim_{s \to 0} P(s) \neq 0, then zero stationary error implies  LaTeX: \lim_{s \to \textcolor{red}{0}} C(s) = \infty\lim_{s \to \textcolor{red}{0}} C(s) = \infty. (Discuss what assumptions are needed for this statement...)

Problem 6

This exercise compares two ways of introducing integral action into observer-based feedback controllers. Apply your results to

LaTeX: P_2(s) = 50 \frac{(1/5 - s)(s + 5)}{ (1/5 + s)(5 - s) (s + 10)}
P_2(s) = 50 \frac{(1/5 - s)(s + 5)}{ (1/5 + s)(5 - s) (s + 10)}

from exercise 3.1.

Design controllers for LaTeX: P_2P_2 and construct code to find the controller polynomials R,S,T for state-feedback controller with observer that includes integral action:

a)  with u = -K\hat x + k_i x_i + k_r r, as in the basic course Ch 8. See Explicit integral state

b) with "input offset estimation", see Disturbance observer

Explicit integral state

The following procedure can be used to introuce integral action. Consider

LaTeX: \begin{aligned}
\dot x & = Ax + Bu \\
y & = Cx
\end{aligned}\begin{aligned} \dot x & = Ax + Bu \\ y & = Cx \end{aligned}

Augment the state vector with an extra component

LaTeX: x_i = \int_0^t e(\tau)d\tau= \int_0^t \left(y_r(\tau) - y(\tau)\right)d\taux_i = \int_0^t e(\tau)d\tau= \int_0^t \left(y_r(\tau) - y(\tau)\right)d\tau.

Taking LaTeX: x_a = \begin{bmatrix} x \\ x_i \end{bmatrix}x_a = \begin{bmatrix} x \\ x_i \end{bmatrix}, we get

LaTeX: \begin{aligned}
\dot x_a & = \begin{bmatrix} A & 0 \\ -C & 0 \end{bmatrix} x_a + \begin{bmatrix}B \\ 0 \end{bmatrix} u + \begin{bmatrix}0 \\ 1\end{bmatrix}y_r \\
y & = \begin{bmatrix}C & 0 \end{bmatrix}
\end{aligned}\begin{aligned} \dot x_a & = \begin{bmatrix} A & 0 \\ -C & 0 \end{bmatrix} x_a + \begin{bmatrix}B \\ 0 \end{bmatrix} u + \begin{bmatrix}0 \\ 1\end{bmatrix}y_r \\ y & = \begin{bmatrix}C & 0 \end{bmatrix} \end{aligned}.

A state-feedback control law LaTeX: u = -K_ax_a + k_r y_ru = -K_ax_a + k_r y_r then has a natural decomposition into LaTeX: u = -Kx - k_ix_i + k_r y_ru = -Kx - k_ix_i + k_r y_r.

The state LaTeX: x_ix_i is is unobservable from LaTeX: yy, but it's known to the controller, as we construct it causally from the known quantities LaTeX: yy and LaTeX: y_ry_r. Typically one uses the controller LaTeX: u = -K\hat x - k_i x_i + k_r y_ru = -K\hat x - k_i x_i + k_r y_r where LaTeX: \hat x\hat x is generated by a Kalman filter. See the figure below.

explicit_integrator.png

Disturbance Observer

The standard observer-based feedback controller is based on modeling disturbances as perturbations to the initial conditions. This model is too simplistic to be useful in practice. The method of introducing an explicit integrator mediates this somewhat, but is limited to precisely integrators. The following allows the engineer to include a large variety of disturbance models into observer-based design methods.

Consider a process that is affected by a disturbance LaTeX: dd, modeled by

LaTeX: \begin{aligned}
\dot x & = Ax + B_u u + B_d d\\
y & = Cx
\end{aligned}\begin{aligned} \dot x & = Ax + B_u u + B_d d\\ y & = Cx \end{aligned}.

The disturbance LaTeX: dd, is modeled as

LaTeX: \begin{aligned}
\dot w & = A_w w \\
d & = C_w w
\end{aligned}\begin{aligned} \dot w & = A_w w \\ d & = C_w w \end{aligned}

The matrix LaTeX: A_wA_w typically has eigenvalues close to the origin (models constant load disturbances), or on the imaginary axis (models sinusoidal disturbances). The augmented system becomes

LaTeX: \begin{aligned}
\dot x_a & = \begin{bmatrix} A & B_dC_w \\ 0 & A_w \end{bmatrix} x_a + \begin{bmatrix} B_u\\ 0\end{bmatrix} u \\
y & = \begin{bmatrix} C & 0 \end{bmatrix}x_a
\end{aligned}\begin{aligned} \dot x_a & = \begin{bmatrix} A & B_dC_w \\ 0 & A_w \end{bmatrix} x_a + \begin{bmatrix} B_u\\ 0\end{bmatrix} u \\ y & = \begin{bmatrix} C & 0 \end{bmatrix}x_a \end{aligned},

where the augmented state is given by LaTeX: x_a = \begin{bmatrix} x  \\ w \end{bmatrix}x_a = \begin{bmatrix} x \\ w \end{bmatrix}. The state LaTeX: ww is not controllable, but it is observable. We construct the controller asLaTeX: u =  -K\hat x - K_w \hat w + k_r y_ru = -K\hat x - K_w \hat w + k_r y_r, where LaTeX: \hat x_a = \begin{bmatrix} \hat x \\ \hat w \end{bmatrix}\hat x_a = \begin{bmatrix} \hat x \\ \hat w \end{bmatrix} is computed by a Kalman filter. The closed-loop system is described by

LaTeX: \begin{aligned}
\dot x & = (A - B_u K)x + (B_d C_w - B_u K_w)w - B_uK \tilde x - B_u K_w \tilde w\\
\dot w & = A_w w \\
\dot{\tilde x} & = (A - LC)\tilde x +B_d C_w \tilde w \\
\dot{\tilde w} & = A_w \tilde w - L_w C \tilde x
\end{aligned}\begin{aligned} \dot x & = (A - B_u K)x + (B_d C_w - B_u K_w)w - B_uK \tilde x - B_u K_w \tilde w\\ \dot w & = A_w w \\ \dot{\tilde x} & = (A - LC)\tilde x +B_d C_w \tilde w \\ \dot{\tilde w} & = A_w \tilde w - L_w C \tilde x \end{aligned}

This method is particularly effective if one can pick LaTeX: K_wK_w such that LaTeX: B_d C_w = B_u K_wB_d C_w = B_u K_w. Input offset estimation builds on the model LaTeX: y = P(u + d)y = P(u + d), i.e. LaTeX: B_u = B_dB_u = B_d. This is sometimes called matched disturbance.

dist_observer.png