cacsd - Untitled
Description: Untitled

Next: misc, Previous: sysfreq, Up: Control Theory

### 30.9 Controller Design

— Function File: dgkfdemo ()

> Octave Controls toolbox demo: H-2/H-infinity options demos.

— Function File: hinfdemo ()

> H-infinity design demos for continuous SISO and MIMO systems and a discrete system. The SISO system is difficult to control because it is non-minimum-phase and unstable. The second design example controls the `jet707` plant, the linearized state space model of a Boeing 707-321 aircraft at v=80 m/s (M = 0.26, Ga0 = -3 deg, alpha0 = 4 deg, kappa = 50 deg). Inputs: (1) thrust and (2) elevator angle Outputs: (1) airspeed and (2) pitch angle. The discrete system is a stable and second order.

> SISO plant:

>                                      s - 2
>                           G(s) = --------------
>                                  (s + 2)(s - 1)

>                                                    +----+
>                               -------------------->| W1 |---> v1
>                           z   |                    +----+
>                           ----|-------------+
>                               |             |
>                               |    +---+    v   y  +----+
>                             u *--->| G |--->O--*-->| W2 |---> v2
>                               |    +---+       |   +----+
>                               |                |
>                               |    +---+       |
>                               -----| K |<-------
>                                    +---+

>                      min || T   ||
>                              vz   infty

>   W1 und W2 are the robustness and performance weighting functions.

> MIMO plant:
>   The optimal controller minimizes the H-infinity norm of the augmented plant P (mixed-sensitivity problem):

>                           w
>                            1 -----------+
>                                         |                   +----+
>                                     +---------------------->| W1 |----> z1
>                           w         |   |                   +----+
>                            2 ------------------------+
>                                     |   |            |
>                                     |   v   +----+   v      +----+
>                                  +--*-->o-->| G  |-->o--*-->| W2 |---> z2
>                                  |          +----+      |   +----+
>                                  |                      |
>                                  ^                      v
>                                  u                       y (to K)
>                               (from controller K)

>                                        +    +           +    +
>                                        | z  |           | w  |
>                                        |  1 |           |  1 |
>                                        | z  | = [ P ] * | w  |
>                                        |  2 |           |  2 |
>                                        | y  |           | u  |
>                                        +    +           +    +

> Discrete system:
>   This is not a true discrete design. The design is carried out in continuous time while the effect of sampling is described by a bilinear transformation of the sampled system. This method works quite well if the sampling period is “small” compared to the plant time constants.
> The continuous plant:

>                                         1
>                           G (s) = --------------
>                            k      (s + 2)(s + 1)

>   is discretised with a ZOH (Sampling period = Ts = 1 second):

>                                     0.199788z + 0.073498
>                           G(z) = --------------------------
>                                  (z - 0.36788)(z - 0.13534)

>                                                    +----+
>                               -------------------->| W1 |---> v1
>                           z   |                    +----+
>                           ----|-------------+
>                               |             |
>                               |    +---+    v      +----+
>                               *--->| G |--->O--*-->| W2 |---> v2
>                               |    +---+       |   +----+
>                               |                |
>                               |    +---+       |
>                               -----| K |<-------
>                                    +---+

>                      min || T   ||
>                              vz   infty

>   W1 and W2 are the robustness and performance weighting functions.

— Function File: [l, m, p, e] = dlqe (a, g, c, sigw, sigv, z)

> Construct the linear quadratic estimator (Kalman filter) for the discrete time system

>               x[k+1] = A x[k] + B u[k] + G w[k]
>                 y[k] = C x[k] + D u[k] + v[k]

> where w, v are zero-mean gaussian noise processes with respective intensities sigw`= cov (`w`,` w`)` and sigv`= cov (`v`,` v`)`.

> If specified, z is `cov (`w`,` v`)`. Otherwise `cov (`w`,` v`) = 0`.

> The observer structure is

>               z[k|k] = z[k|k-1] + L (y[k] - C z[k|k-1] - D u[k])
>               z[k+1|k] = A z[k|k] + B u[k]

> The following values are returned:

> l
>   The observer gain, (a - alc). is stable.
> m
>   The Riccati equation solution.
> p
>   The estimate error covariance after the measurement update.
> e
>   The closed loop poles of (a - alc).

— Function File: [k, p, e] = dlqr (a, b, q, r, z)

> Construct the linear quadratic regulator for the discrete time system

>               x[k+1] = A x[k] + B u[k]

> to minimize the cost functional

>               J = Sum (x' Q x + u' R u)

> z omitted or

>               J = Sum (x' Q x + u' R u + 2 x' Z u)

> z included.

> The following values are returned:

> k
>   The state feedback gain, (a - bk) is stable.
> p
>   The solution of algebraic Riccati equation.
> e
>   The closed loop poles of (a - bk).

— Function File: [Lp, Lf, P, Z] = dkalman (A, G, C, Qw, Rv, S)

> Construct the linear quadratic estimator (Kalman predictor) for the discrete time system

>               x[k+1] = A x[k] + B u[k] + G w[k]
>                 y[k] = C x[k] + D u[k] + v[k]

> where w, v are zero-mean gaussian noise processes with respective intensities Qw`= cov (`w`,` w`)` and Rv`= cov (`v`,` v`)`.

> If specified, S is `cov (`w`,` v`)`. Otherwise `cov (`w`,` v`) = 0`.

> The observer structure is

>               x[k+1|k] = A x[k|k-1] + B u[k] + LP (y[k] - C x[k|k-1] - D u[k])
>               x[k|k] = x[k|k-1] + LF (y[k] - C x[k|k-1] - D u[k])

> The following values are returned:

> Lp
>   The predictor gain, (A - Lp C) is stable.
> Lf
>   The filter gain.
> P
>   The Riccati solution.

>   P = E [(x - x[n|n-1])(x - x[n|n-1])']

> Z
>   The updated error covariance matrix.

>   Z = E [(x - x[n|n])(x - x[n|n])']

— Function File: [K, gain, kc, kf, pc, pf] = h2syn (asys, nu, ny, tol)

> Design H-2 optimal controller per procedure in Doyle, Glover, Khargonekar, Francis, State-Space Solutions to Standard H-2 and H-infinity Control Problems, IEEE TAC August 1989.

> Discrete-time control per Zhou, Doyle, and Glover, Robust and optimal control, Prentice-Hall, 1996.

> Inputs

> asys
>   system data structure (see ss, sys2ss)
>   - controller is implemented for continuous time systems
>   - controller is not implemented for discrete time systems
> nu
>   number of controlled inputs
> ny
>   number of measured outputs
> tol
>   threshold for 0. Default: 200*`eps`

> Outputs

> k
>   system controller
> gain
>   optimal closed loop gain
> kc
>   full information control (packed)
> kf
>   state estimator (packed)
> pc
>   ARE solution matrix for regulator subproblem
> pf
>   ARE solution matrix for filter subproblem

— Function File: K = hinf_ctr (dgs, f, h, z, g)

> Called by `hinfsyn` to compute the H-infinity optimal controller.

> Inputs

> dgs
>   data structure returned by `is_dgkf`
> f
> h
>   feedback and filter gain (not partitioned)
> g
>   final gamma value
> Outputs
> K
>   controller (system data structure)

> Do not attempt to use this at home; no argument checking performed.

— Function File: [k, g, gw, xinf, yinf] = hinfsyn (asys, nu, ny, gmin, gmax, gtol, ptol, tol)

> Inputs input system is passed as either

> asys
>   system data structure (see `ss`, `sys2ss`)
>   - controller is implemented for continuous time systems
>   - controller is not implemented for discrete time systems (see bilinear transforms in `c2d`, `d2c`)
> nu
>   number of controlled inputs
> ny
>   number of measured outputs
> gmin
>   initial lower bound on H-infinity optimal gain
> gmax
>   initial upper bound on H-infinity Optimal gain.
> gtol
>   Gain threshold. Routine quits when gmax/gmin < 1+tol.
> ptol
>   poles with `abs(real(pole))` < ptol*||H|| (H is appropriate Hamiltonian) are considered to be on the imaginary axis. Default: 1e-9.
> tol
>   threshold for 0. Default: 200*`eps`.

>   gmax, min, tol, and tol must all be positive scalars.

> Outputs
> k
>   System controller.
> g
>   Designed gain value.
> gw
>   Closed loop system.
> xinf
>   ARE solution matrix for regulator subproblem.
> yinf
>   ARE solution matrix for filter subproblem.

> References:

> 1. Doyle, Glover, Khargonekar, Francis, State-Space Solutions to Standard H-2 and H-infinity Control Problems, IEEE TAC August 1989.
> 2. Maciejowksi, J.M., Multivariable feedback design, Addison-Wesley, 1989, ISBN 0-201-18243-2.
> 3. Keith Glover and John C. Doyle, State-space formulae for all stabilizing controllers that satisfy an H-infinity-norm bound and relations to risk sensitivity, Systems & Control Letters 11, Oct. 1988, pp 167–172.

— Function File: [retval, pc, pf] = hinfsyn_chk (a, b1, b2, c1, c2, d12, d21, g, ptol)

> Called by `hinfsyn` to see if gain g satisfies conditions in Theorem 3 of Doyle, Glover, Khargonekar, Francis, State Space Solutions to Standard H-2 and H-infinity Control Problems, IEEE TAC August 1989.

> Warning: do not attempt to use this at home; no argument checking performed.

> Inputs

> As returned by `is_dgkf`, except for:

> g
>   candidate gain level
> ptol
>   as in `hinfsyn`

> Outputs

> retval
>   1 if g exceeds optimal Hinf closed loop gain, else 0
> pc
>   solution of “regulator” H-infinity ARE
> pf
>   solution of “filter” H-infinity ARE
> Do not attempt to use this at home; no argument checking performed.

— Function File: [xinf, x_ha_err] = hinfsyn_ric (a, bb, c1, d1dot, r, ptol)

> Forms

>               xx = ([bb; -c1'*d1dot]/r) * [d1dot'*c1 bb'];
>               Ha = [a 0*a; -c1'*c1 - a'] - xx;

> and solves associated Riccati equation. The error code x_ha_err indicates one of the following conditions:

> 0
>   successful
> 1
>   xinf has imaginary eigenvalues
> 2
>   hx not Hamiltonian
> 3
>   xinf has infinite eigenvalues (numerical overflow)
> 4
>   xinf not symmetric
> 5
>   xinf not positive definite
> 6
>   r is singular

— Function File: [k, p, e] = lqe (a, g, c, sigw, sigv, z)

> Construct the linear quadratic estimator (Kalman filter) for the continuous time system

>               dx
>               -- = A x + G u
>               dt

>               y = C x + v

> where w and v are zero-mean gaussian noise processes with respective intensities

>               sigw = cov (w, w)
>               sigv = cov (v, v)

> The optional argument z is the cross-covariance `cov (`w`,` v`)`. If it is omitted, `cov (`w`,` v`) = 0` is assumed.

> Observer structure is `dz/dt = A z + B u + k (y - C z - D u)`

> The following values are returned:

> k
>   The observer gain, (a - kc) is stable.
> p
>   The solution of algebraic Riccati equation.
> e
>   The vector of closed loop poles of (a - kc).

— Function File: [k, q1, p1, ee, er] = lqg (sys, sigw, sigv, q, r, in_idx)

> Design a linear-quadratic-gaussian optimal controller for the system

>               dx/dt = A x + B u + G w       [w]=N(0,[Sigw 0    ])
>                   y = C x + v               [v]  (    0   Sigv ])

> or

>               x(k+1) = A x(k) + B u(k) + G w(k)       [w]=N(0,[Sigw 0    ])
>                 y(k) = C x(k) + v(k)                  [v]  (    0   Sigv ])

> Inputs

> sys
>   system data structure
> sigw
> sigv
>   intensities of independent Gaussian noise processes (as above)
> q
> r
>   state, control weighting respectively. Control ARE is
> in_idx
>   names or indices of controlled inputs (see `sysidx`, `cellidx`)

>   default: last dim(R) inputs are assumed to be controlled inputs, all others are assumed to be noise inputs.

> Outputs
> k
>   system data structure format LQG optimal controller (Obtain A, B, C matrices with `sys2ss`, `sys2tf`, or `sys2zp` as appropriate).
> p1
>   Solution of control (state feedback) algebraic Riccati equation.
> q1
>   Solution of estimation algebraic Riccati equation.
> ee
>   Estimator poles.
> es
>   Controller poles.

> See also: h2syn, lqe, lqr.

— Function File: [k, p, e] = lqr (a, b, q, r, z)

> construct the linear quadratic regulator for the continuous time system

>               dx
>               -- = A x + B u
>               dt

> to minimize the cost functional

>                     infinity
>                     /
>                 J = |  x' Q x + u' R u
>                    /
>                   t=0

> z omitted or

>                     infinity
>                     /
>                 J = |  x' Q x + u' R u + 2 x' Z u
>                    /
>                   t=0

> z included.

> The following values are returned:

> k
>   The state feedback gain, (a - bk) is stable and minimizes the cost functional
> p
>   The stabilizing solution of appropriate algebraic Riccati equation.
> e
>   The vector of the closed loop poles of (a - bk).

> Reference Anderson and Moore, Optimal control: linear quadratic methods, Prentice-Hall, 1990, pp. 56–58.

— Function File: [y, x] = lsim (sys, u, t, x0)

> Produce output for a linear simulation of a system; produces a plot for the output of the system, sys.

> u is an array that contains the system's inputs. Each row in u corresponds to a different time step. Each column in u corresponds to a different input. t is an array that contains the time index of the system; t should be regularly spaced. If initial conditions are required on the system, the x0 vector should be added to the argument list.

> When the lsim function is invoked a plot is not displayed; however, the data is returned in y (system output) and x (system states).

— Function File: K = place (sys, p)

> Computes the matrix K such that if the state is feedback with gain K, then the eigenvalues of the closed loop system (i.e. A-BK) are those specified in the vector p.

> Version: Beta (May-1997): If you have any comments, please let me know. (see the file place.m for my address)