Topics in Undergraduate Control Systems...

137
Topics in Undergraduate Control Systems Design João P. Hespanha May 9, 2012 Disclaimer: This is an early draft and probably contains many typos. Comments and information about typos are welcome. Please contact the author at (hespanha@ece. ucsb.edu). c Copyright to João Hespanha. Please do not distribute this document without the author’s consent.

Transcript of Topics in Undergraduate Control Systems...

Page 1: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

Topics in Undergraduate

Control Systems Design

João P. Hespanha

May 9, 2012

Disclaimer: This is an early draft and probably contains many typos.

Comments and information about typos are welcome. Please contact the author at ([email protected]).

c© Copyright to João Hespanha. Please do not distribute this document without the author’s consent.

Page 2: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and
Page 3: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

Contents

I System Identification 1

1 Computer-Controlled Systems 5

1.1 Computer Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51.2 Continuous-time Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61.3 Discrete-time Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81.4 Discrete- vs. Continuous-time Transfer Functions . . . . . . . . . . . . . . . . . . . . 101.5 MATLAB R© Hints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121.6 To Probe Further . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131.7 Exercise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

2 Parametric Identification using Least-squares 15

2.1 Parametric Identification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152.2 Least-squares Line Fitting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152.3 Vector Least-squares . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172.4 MATLAB R© Hints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192.5 To Probe Further . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192.6 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

3 Parametric Identification of an ARX Model 23

3.1 ARX Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233.2 Identification of an ARX Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243.3 Dealing with Known Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253.4 MATLAB R© Hints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253.5 To Probe Further . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273.6 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

4 Practical Considerations in Parametric Identification 29

4.1 Choice of Inputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294.2 Signal Scaling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334.3 Choice of Sampling Frequency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 364.4 Choice of Model Order . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 374.5 Combination of Multiple Experiments . . . . . . . . . . . . . . . . . . . . . . . . . . . 414.6 Closed-loop Identification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 424.7 MATLAB R© Hints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 424.8 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

5 Nonparametric Identification 47

5.1 Nonparametric Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475.2 Time-domain Identification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475.3 Frequency Response Identification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 495.4 MATLAB R© Hints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 515.5 To Probe Further . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 515.6 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52

i

Page 4: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

ii João P. Hespanha

II Robust Control 55

6 Robust stability 59

6.1 Model Uncertainty . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59

6.2 Nyquist Stability Criterion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62

6.3 Small Gain Condition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63

6.4 MATLAB R© Hints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65

6.5 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66

7 Control design by loop shaping 69

7.1 The Loop-shaping Design Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69

7.2 Open-loop vs. closed-loop specifications . . . . . . . . . . . . . . . . . . . . . . . . . 69

7.3 Open-loop Gain Shaping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73

7.4 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74

III LQG/LQR Controller Design 77

8 Review of State-space models 81

8.1 State-space Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81

8.2 Input-output Relations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82

8.3 Realizations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83

8.4 Controllability and Observability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83

8.5 Stability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84

8.6 MATLAB R© Hints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84

9 Linear Quadratic Regulation (LQR) 87

9.1 Feedback Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87

9.2 Optimal Regulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88

9.3 State-Feedback LQR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89

9.4 Stability and Robustness . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90

9.5 Loop-shaping Control using LQR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92

9.6 MATLAB R© Hints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94

9.7 To Probe Further . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95

9.8 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96

10 LQG/LQR Output Feedback 97

10.1 Output Feedback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97

10.2 Full-order Observers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97

10.3 LQG Estimation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98

10.4 LQG/LQR Output Feedback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99

10.5 Separation Principle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100

10.6 Loop-gain Recovery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100

10.7 Loop Shaping using LQR/LQG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102

10.8 MATLAB R© Hints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102

10.9 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102

11 Set-point control 105

11.1 Nonzero Equilibrium State and Input . . . . . . . . . . . . . . . . . . . . . . . . . . . 105

11.2 State feedback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106

11.3 Output feedback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107

11.4 MATLAB R© Hints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107

11.5 To Probe Further . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107

Page 5: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

Control Systems Design iii

IV Nonlinear Control 109

12 Feedback linearization controllers 113

12.1 Feedback Linearization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11312.2 Generalized Model for Mechanical Systems . . . . . . . . . . . . . . . . . . . . . . . . 11412.3 Feedback Linearization of Mechanical Systems . . . . . . . . . . . . . . . . . . . . . . 11612.4 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117

13 Lyapunov Stability 119

13.1 Lyapunov Stability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11913.2 Lyapunov Stability Theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12113.3 Exercise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12213.4 LaSalle’s Invariance Principle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12213.5 Liénard Equation and Generalizations . . . . . . . . . . . . . . . . . . . . . . . . . . . 12313.6 To Probe Further . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12513.7 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125

14 Lyapunov-based Designs 127

14.1 Lyapunov-based Controllers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12714.2 Application to Mechanical Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12814.3 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129

Attention! When a marginal note finishes with “ p. XXX,” more information about that topic can befound on page XXX.

Page 6: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

iv João P. Hespanha

Page 7: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

Part I

System Identification

1

Page 8: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and
Page 9: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

Introduction to System Identification

The goal of system identification is to utilize input/output experimental data to determine a system’smodel. For example, one may apply to the system a specific input u, measure the observed discrete-time output y an try to determine the system’s transfer function (cf. Figure 1).

u y?

Figure 1. System identification from input/output experimental data

Pre-requisites

1. Laplace transform, continuous-time transfer functions, stability, and frequency response (brieflyreviewed here).

2. z-transform, discrete-time transfer functions, stability, and impulse/step/frequency responses(briefly reviewed here).

3. Computer-control system design (briefly reviewed here).

4. Familiarity with basic vector and matrix operations.

5. Knowledge of MATLAB R©/Simulink.

Further reading A more extensive coverage of system identification can be found, e.g., in [10].

3

Page 10: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

4 João P. Hespanha

Page 11: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

Chapter 1

Computer-Controlled Systems

Contents

1.1 Computer Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51.2 Continuous-time Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61.3 Discrete-time Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81.4 Discrete- vs. Continuous-time Transfer Functions . . . . . . . . . . . . . . . . . . . . 101.5 MATLAB R© Hints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121.6 To Probe Further . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131.7 Exercise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

1.1 Computer Control

Figure 1.1 show the typical block diagram of a control system implemented using a digital computer.Although the output ycptq of most physical systems vary continuously as a function of time, it can

computer process

sample

holdrptq ucptq ycptqudpkq

ydpkq

Figure 1.1. Computer control architecture. The components in the dashed boxed can be regarded as a discrete-time process to be controlled.

only be measured at discrete time instants. Typically, it is sampled periodically as shown in the leftplot of Figure 1.2. Moreover, the control signal ucptq cannot be changed continuously and typicallyis held constant between sampling times as shown in the right plot of Figure 1.2. It is thereforesometimes convenient to regard the process to be controlled as a discrete-time system whose inputs

5

Page 12: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

6 João P. Hespanha

Ts

Ts 2Ts 3Ts

ydp1q

ydp2q ydp3qycptq

. . .

Ts

Ts 2Ts 3Ts

udp1q

udp2q udp3q

ucptq

. . .

Figure 1.2. Sampling (left) and holding (right)

and outputs are the discrete-time signals

ydpkq “ ycpkTsq, udpkq “ ucpkTsq, k P t0, 1, 2, . . . u.

The identification techniques that we will study allow us to estimate the transfer function of thisdiscrete-time system. We can then use standard techniques from digital control to (approximately)recover the underlying continuous-time transfer function. This is discussed in Section 1.4 below.

1.2 Continuous-time Systems

ucptq ycptq

Hcpsq “?

Figure 1.3. Continuous-time system

Consider the continuous-time system in Figure 1.3 and assume that the input and output signalssatisfy the following differential equation:

Notation 1. We denote by 9ycptqand :ycptq the first and sec-ond time derivatives of the signalycptq. Higher-order derivatives oforder k ě 3 are denoted by de-note by ypkqptq.

ypnqc ` βn´1y

pn´1qc ` ¨ ¨ ¨ ` β2:yc ` β1 9yc ` β0yc

“ αmupmqc ` αm´1u

pm´1qc ` ¨ ¨ ¨ ` α2:uc ` α1 9uc ` α0uc. (1.1)

We recall that, given a signal xptq with Laplace transform X psq, the Laplace transform of the ℓth

Note 1. The (unilateral) Laplacetransform of a signal xptq is givenby

Xpsq –

ż 8

0e´stxptqdt.

See [5, Appendix A] for a review ofLaplace transforms.

derivative of xptq is given by

sℓX psq ´ sℓ´1xp0q ´ sℓ´29xp0q ´ ¨ ¨ ¨ ´ xpℓ´1qp0q.

In particular, when x and all its derivatives are zero at time t “ 0, the Laplace transform of the ℓthderivative xpℓqptq simplifies to

sℓX psq.

Taking Laplace transforms to both sides of (1.1) and assuming that both y and u are zero at timezero (as well as all their derivatives), we obtain

snYcpsq ` βn´1sn´1Ycpsq ` ¨ ¨ ¨ ` β2s

2Ycpsq ` β1sYcpsq ` β0Ycpsq“ αmsmUcpsq ` αm´1s

m´1Ucpsq ` ¨ ¨ ¨ ` α2s2Ucpsq ` α1sUcpsq ` α0Ucpsq.

Page 13: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

System Identification 7

This leads toMATLAB R© Hint 1.tf(num,den) creates acontinuous-time transfer functionwith numerator and denominatorspecified by num, den. . . p. 12

MATLAB R© Hint 2. zpk(z,p,k)creates a continuous-time transferfunction with zeros, poles, andgain specified by z, p, k. . . p. 12

MATLAB R© Hint 3. pole(sys)and zero(sys) compute thepoles and zeros of a system,respectively.

Ycpsq “ HcpsqUcpsq,where

Hcpsq –αmsm ` αm´1s

m´1 ` ¨ ¨ ¨ ` α1s ` α0

sn ` βn´1sn´1 ` ¨ ¨ ¨ ` β1s ` β0, (1.2)

the (continuous-time) transfer function of the system. The roots of the denominator are called thepoles of the system and the roots of the numerator are called the zeros of the system.

The system is (BIBO) stable if all poles have negative real part. In this case, for every input

Note 2. Since there are other no-tions of stability, one should usethe term BIBO stable to clarifythat it refers to the property thatBounded-Inputs lead to Bounded-Outputs.

bounded signal ucptq, the output ycptq remains bounded.

1.2.1 Steady-state Response to Sine Waves

Suppose that we apply a sinusoidal input with amplitude A and angular frequency ω, given by

Note 3. The angular frequency ωis measured in radian per second,and is related to the (regular) fre-quency f by the formula ω “ 2πf ,where f is given in Hertz or cyclesper second.

ucptq “ A cospωtq, @t ě 0,

to the system (1.1) with transfer function (1.2). Assuming that the system is BIBO stable, thecorresponding output is of the form

ycptq “ gA cospωt ` φqlooooooomooooooonsteady-state

` εptqloomoontransient

, @t ě 0, (1.3)

where the gain g and the phase φ are given by the following formulas

g – |Hcpjωq|, φ – =Hcpjωq, (1.4)

and εptq is a transient signal that decays to zero at t Ñ 8 (cf. Figure 1.4).

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5−1

−0.5

0

0.5

1

t (sec)

u

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5−0.2

−0.1

0

0.1

0.2

t (sec)

y

Figure 1.4. Response to a sinusoidal input with frequency f “ 1Hz, corresponding to ω “ 2π rad/sec. TheBode plot of the system is shown in Figure 1.5.

The Bode plot of a transfer function Hcpsq depictsMATLAB R© Hint 4. bode(sys)draws the Bode plot of the systemsys. . . p. 13

1. the norm of Hcpjωq in decibels [dB], which is given by 20 log10

ˇHcpjωq

ˇ; and

2. the phase of Hcpjωqboth as a function of the angular frequency ω (in a logarithmic scale). In view of (1.3)–(1.4), theBode plot provides information about how much a sinusoidal signal is amplified and by how much itsphase is changed.

Page 14: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

8 João P. Hespanha

−40

−30

−20

−10

0From: u To: y

Mag

nitu

de (

dB)

10−2

10−1

100

101

102

−90

−45

0

Pha

se (

deg)

Bode Diagram

Frequency (rad/sec)

Figure 1.5. Bode plot of a system with transfer function Hcpsq “ 1s`1

.

1.3 Discrete-time Systems

process SHucptq ycptq

udpkq “ ucpkTsq ydpkq “ ycpkTsq

Hcpsq

HdpzqFigure 1.6. Discrete-time system

Consider now the discrete-time system in Figure 1.6 and assume that the output can be computedNote 4. Since the output cannotdepend on future inputs, we musthave n ě m for (1.5) to be physi-cally realizable.

recursively by the following difference equation:

ydpk ` nq “ ´βn´1ydpk ` n ´ 1q ´ ¨ ¨ ¨ ´ β2ydpk ` 2q ´ β1ydpk ` 1q ´ β0ydpkq` αmudpk ` mq ` αm´1udpk ` m ´ 1q ` ¨ ¨ ¨ ` α2udpk ` 2q ` α1udpk ` 1q ` α0udpkq. (1.5)

To obtain an equation that mimics (1.1), we can re-write (1.5) as

ydpk ` nq ` βn´1ydpk ` n ´ 1q ` ¨ ¨ ¨ ` β2ydpk ` 2q ` β1ydpk ` 1q ` β0ydpkq“ αmudpk ` mq ` αm´1udpk ` m ´ 1q ` ¨ ¨ ¨ ` α2udpk ` 2q ` α1udpk ` 1q ` α0udpkq. (1.6)

We recall that, given a signal xpkq with z-transform X pzq, the z-transform of xpk ` ℓq is given byNote 5. The (unilateral) z-transform of a signal xpkq is givenby

Xpzq –

8ÿ

k“0

z´k xpkq.

See [5, Section 8.2] for a review ofLaplace z-transforms.

zℓX pzq ´ zℓxp0q ´ zℓ´1xp1q ´ ¨ ¨ ¨ ´ zxpℓ ´ 1q.

In particular, when x is equal to zero before time k “ ℓ , the z-transform of xpk ` ℓq simplifies to

zℓX pzq.

Page 15: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

System Identification 9

Taking z-transforms to both sides of (1.6) and assuming that both yd and ud are zero before timen ě m, we obtain

znYdpzq ` βn´1zn´1Ydpzq ` ¨ ¨ ¨ ` β2z

2Ydpzq ` β1zYdpzq ` β0Ydpzq“ αmzmUdpzq ` αm´1z

m´1Udpzq ` ¨ ¨ ¨ ` α2z2Udpzq ` α1zUdpzq ` α0Udpzq.

This leads toMATLAB R© Hint 5.tf(num,den,Ts) creates adiscrete-time transfer functionwith sampling time Ts and numer-ator and denominator specified bynum, den. . . p. 12

MATLAB R© Hint 6.zpk(z,p,k,Ts) creates atransfer function with samplingtime Ts zeros, poles, and gainspecified by z, p, k. . . p. 12

Ydpzq “ HdpzqUdpzq,

where

Hdpzq –αmzm ` αm´1z

m´1 ` ¨ ¨ ¨ ` α1z ` α0

zn ` βn´1zn´1 ` ¨ ¨ ¨ ` β1z ` β0, (1.7)

is called the (discrete-time) transfer function of the system. The roots of the denominator are calledthe poles of the system and the roots of the numerator are called the zeros of the system.

The system is (BIBO) stable if all poles have magnitude strictly smaller than one. In this case,

Note 6. Since there are other no-tions of stability, one should usethe term BIBO stable to clarifythat it refers to the property thatBounded-Inputs lead to Bounded-Outputs.

for every input bounded signal upkq, the output ypkq remains bounded.

1.3.1 Steady-state Response to Sine Waves

Suppose that we apply a sinusoidal input with amplitude A and discrete-time angular frequencyΩ P r0, πs, given by

Note 7. Discrete-time angularfrequencies take values from0 to π. In particular, Ω “ πcorresponds to the “fastest”discrete-time signal:

udpkq “ A cospπkq “ Ap´1qk .

. . . p. 13

udpkq “ A cospΩkq, @k P t0, 1, 2 . . . u,

to the system (1.1) with transfer function (1.2). Assuming that the system is BIBO stable, thecorresponding output is of the form

ydpkq “ gA cospΩk ` φqloooooooomoooooooonsteady-state

` εpkqloomoontransient

, @k P t0, 1, 2 . . . u, (1.8)

where the gain g and phase φ are given by Attention! For discrete-time sys-tems the argument to H is ejΩ andnot just jΩ, as in continuous-timesystems. This means that Hpzqwill be evaluated over the unit cir-cle, instead of the imaginary axis.

g – |HdpejΩq|, φ – =HdpejΩq, (1.9)

and εptq is a transient signal that decays to zero at k Ñ 8 (cf. Figure 1.4).

The Bode plot of a transfer function Hdpzq depictsMATLAB R© Hint 7. bode(sys)draws the Bode plot of the systemsys. . . p. 13

1. the norm of HdpejΩq in decibels [dB], which is given by 20 log10

ˇHdpejΩq

ˇ; and

2. the phase of HdpejΩq

as a function of the angular frequency Ω (in a logarithmic scale). In view of (1.8)–(1.9), the Bodeplot provides information about how much a sinusoidal signal is amplified (magnitude) and by howmuch its phase is changed.

1.3.2 Step and Impulse Responses

Suppose that we apply a discrete-time impulse, given by

upkq “ δpkq –

#1 k “ 0

0 k ‰ 0

Page 16: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

10 João P. Hespanha

0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5−1

−0.5

0

0.5

1

t (sec)

u0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5

−1

−0.5

0

0.5

1

t (sec)y

Figure 1.7. Response to a sinusoidal input with frequency f “ 1Hz, ω “ 2π rad/sec sampled with a periodequal to Ts “ .01 sec. The corresponding discrete-time frequency is given by Ω “ .02π and the Bode plot ofthe system is shown in Figure 1.8.

to the system (1.1) with transfer function (1.2). The corresponding output hpkq is called the impulse

response and its z-transform is precisely the system’s transfer function:

Hdpzq “8ÿ

k“0

z´khpkq.

Consider now an input equal to a discrete-time step with magnitude α , i.e.,

upkq “ spkq –

#0 k ă 0

α k ě 0,

and let ypkq be the corresponding output, which is called the step response. Since the impulse δpkqcan be obtained from the step spkq by

δpkq “ spkq ´ spk ´ 1qα

, @k P t0, 1, 2 . . . u,

the impulse response hpkq (which is the output to δpkq) can be obtained from the output ypkq tospkq by

hpkq “ ypkq ´ ypk ´ 1qα

, @k P t0, 1, 2 . . . u.

This is a consequence of linearity (cf. Figure 1.9).

1.4 Discrete- vs. Continuous-time Transfer Functions

When the sampling time Ts is small, one can easily go from continuous- to discrete-time transferfunctions shown in Figure 1.10. To understand how this can be done, consider a continuous-timeintegrator

9yc “ uc (1.10)

with transfer function

Hcpsq “ YcpsqUcpsq “ 1

s. (1.11)

Page 17: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

System Identification 11

−40

−30

−20

−10

0From: u To: y

Mag

nitu

de (

dB)

10−2

10−1

100

101

102

−90

−45

0

Pha

se (

deg)

Bode Diagram

Frequency (rad/sec)

Figure 1.8. Bode plot of a system with transfer function Hdpsq “ .05z´.95

.

sptq yptqHdpzq

(a) step response

δpkq “ spkq´spk´1qα hpkq “ ypkq´ypk´1q

αHdpzq

(b) impulse response

Figure 1.9. Impulse versus step responses

Suppose that the signals y and u are sampled every Ts time units as shown in Figure 1.2 and thatwe define the discrete-time signals

ydpkq “ ycpkTsq, udpkq “ ucpkTsq, k P t0, 1, 2, . . . u.

Assuming that ucptq is approximately constant over an interval of length Ts, we can take a finitedifferences approximation to the derivative in (1.10), which leads to

ycpt ` Tsq ´ ycptqTs

“ ucptq.

In particular, for t “ kTs we obtain

ydpk ` 1q ´ ydpkqTs

“ udpkq. (1.12)

process SHucptq ycptq

udpkq ydpkq

Hcpsq

HdpzqFigure 1.10. Discrete vs. continuous-time transfer functions

Page 18: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

12 João P. Hespanha

Taking the z-transform we conclude thatNote 8. In discrete-time, an in-tegrator has a pole at z “ 1,whereas in continuous-time thepole is at s “ 0.

zYdpzq ´ YdpzqTs

“ Udpzq ô Hdpzq “ YdpzqUdpzq “ 1

z´1Ts

. (1.13)

Comparing (1.11) with (1.13), we observe that we can go directly from a continuous-time transferfunction to the discrete-time one using the so called Euler transformations:

MATLAB R© Hint 8. c2d and d2c

convert transfer functions fromcontinuous- to discrete-time andvice-versa. . . p. 13

s ÞÑ z ´ 1

Tsô z ÞÑ 1 ` sTs.

In general, a somewhat better approximation is obtained by taking the right-hand-side of (1.12) tobe the average of udpkq and udpk ` 1q. This leads to the so called Tustin or bilinear transformation:

Note 9. Why?. . . p. 14

Note 10. The Euler transforma-tion preserves the number of polesand the number of zeros since itreplaces a polynomial of degreen in s by a polynomial of thesame degree in z and vice-versa.However, the Tustin transformationonly preserves the number of polesand can make discrete-time zerosappear, for systems that did nothave continuous-time zeros. E.g.,the integrator system 1

s becomesTspz`1q2pz´1q . . . p. 14

s ÞÑ 2pz ´ 1qTspz ` 1q ô z ÞÑ 2 ` sTs

2 ´ sTs.

1.5 MATLAB R© Hints

MATLAB R© Hint 1, 5 (tf). The command sys_tf=tf(num,den) assigns to sys_tf a MATLAB R©

continuous-time transfer function. num is a vector with the coefficients of the numerator of the system’stransfer function and den a vector with the coefficients of the denominator. The last coefficient mustalways be the zero-order one. E.g., to get 2s

s2`3one should use num=[2 0];den=[1 0 3];

The command sys_tf=tf(num,den,Ts) assigns to sys_tf a MATLAB R© discrete-time transferfunction, with sampling time equal to Ts.

For transfer matrices, num and den are cell arrays. Type help tf for examples.

Optionally, one can specify the names of the inputs, outputs, and state to be used in subsequentplots as follows:

sys_tf=tf(num,den,...

’InputName’,’input1’,’input2’,...,...

’OutputName’,’output1’,’output2’,...,...

’StateName’,’input1’,’input2’,...)

The number of elements in the bracketed lists must match the number of inputs,outputs, and statevariables. 2

MATLAB R© Hint 2, 6 (zpk). The command sys_tf=zpk(z,p,k) assigns to sys_tf a MATLAB R©

continuous-time transfer function. z is a vector with the zeros of the system, p a vector with itspoles, and k the gain. E.g., to get 2s

ps`1qps`3q one should use z=0;p=[1,3];k=2;

The command sys_tf=zpk(z,p,k,Ts) assigns to sys_tf a MATLAB R© discrete-time transfer func-tion, with sampling time equal to Ts.

For transfer matrices, z and p are cell arrays and k a regular array. Type help zpk for examples.

Optionally, one can specify the names of the inputs, outputs, and state to be used in subsequentplots as follows:

sys_tf=zpk(z,p,k,...

’InputName’,’input1’,’input2’,...,...

’OutputName’,’output1’,’output2’,...,...

’StateName’,’input1’,’input2’,...)

The number of elements in the bracketed lists must match the number of inputs,outputs, and statevariables. 2

Page 19: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

System Identification 13

MATLAB R© Hint 4, 7, 22 (bode). The command bode(sys) draws the Bode plot of the system sys.To specify the system one can use:

1. sys=tf(num,den), where num is a vector with the coefficients of the numerator of the system’stransfer function and den a vector with the coefficients of the denominator. The last coefficientmust always be the zero-order one. E.g., to get 2s

s2`3one should use num=[2 0];den=[1 0

3];

2. sys=zpk(z,p,k), where z is a vector with the zeros of the system, p a vector with its poles,and k the gain. E.g., to get 2s

ps`1qps`3q one should use z=0;p=[1,3];k=2;

3. sys=ss(A,B,C,D), where A,B,C,D are a realization of the system. 2

MATLAB R© Hint 8 (c2d and d2c). The command c2d(sysc,Ts,’tustin’) converts the continuous-time LTI model sysc to a discrete-time model with sampling time Ts using the Tustin transformation.To specify the continuous-time system sysc one can use:

1. sysc=tf(num,den), where num is a vector with the coefficients of the numerator of thesystem’s transfer function and den a vector with the coefficients of the denominator. Thelast coefficient must always be the zero-order one. E.g., to get 2s

s2`3one should use num=[2

0];den=[1 0 3];

2. sysc=zpk(z,p,k), where z is a vector with the zeros of the system, p a vector with its poles,and k the gain. E.g., to get 2s

ps`1qps`3q one should use z=0;p=[1,3];k=2;

3. sysc=ss(A,B,C,D), where A,B,C,D are a realization of the system.

The command d2c(sysd,’tustin’) converts the discrete-time LTI model sysd to a continuous-time model, using the Tustin transformation. To specify the discrete-time system sysd one canuse:

1. sysd=tf(num,den,Ts), where Ts is the sampling time, num is a vector with the coefficientsof the numerator of the system’s transfer function and den a vector with the coefficients of thedenominator. The last coefficient must always be the zero-order one. E.g., to get 2s

s2`3one

should use num=[2 0];den=[1 0 3];

2. sysd=zpk(z,p,k,Ts), where Ts is the sampling time, z is a vector with the zeros of thesystem, p a vector with its poles, and k the gain. E.g., to get 2s

ps`1qps`3q one should use

z=0;p=[1,3];k=2;

3. sysd=ss(A,B,C,D,Ts), where Ts is the sampling time, A,B,C,D are a realization of thesystem. 2

1.6 To Probe Further

Note 7 (Discrete- vs. continuous-time frequencies). When operating with a sample period Ts, togenerate a discrete-time signal udpkq that corresponds to the sampled version of the continuous-time signal

ucptq “ A cospωtq, @t ě 0

we must have

udpkq “ ucpkTsq “ A cospωkTsq “ A cospΩkq,

where the last equality holds as long as we select Ω “ ωTs “ 2πfTs.

Page 20: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

14 João P. Hespanha

Discrete-time angular frequencies take values from 0 to π. In particular, Ω “ π results in the“fastest” discrete-time signal:

udpkq “ A cospπkq “ Ap´1qk ,

which corresponds to a continuous-time frequency f “ 12T s

equal to half the sampling rate, alsoknown as the Nyquist frequency. 2

Note 9 (Tustin transformation). Consider a continuous-time integrator in (1.10) and assume that uptqis approximately linear on the interval rkTs, pk ` 1qTss, i.e.,

uptq “ pk ` 1qTs ´ t

Tsudpkq ` t ´ kTs

Tsudpk ` 1q, @t P rkTs, pk ` 1qTss.

Then, for ydpk ` 1q to be exactly equal to the integral of uptq at time t “ pk ` 1qTs, we need tohave

ydpk ` 1q “ ydpkq `ż pk`1qTs

kTs

´ pk ` 1qTs ´ t

Tsudpkq ` t ´ kTs

Tsudpk ` 1q

¯dt

“ ydpkq ` Ts

2udpkq ` Ts

2udpk ` 1q.

Taking the z-transform we conclude that

zYdpzq ´ YdpzqTs

“ Udpzq ` zUdpzq2

ô Hdpzq “ YdpzqUdpzq “ Tsp1 ` zq

2pz ´ 1q .

Comparing this with (1.11), we observe that we can go directly from a continuous-time transferfunction to the discrete-time one using the so called Tustin or bilinear transformation:

s ÞÑ 2pz ´ 1qTspz ` 1q ô z ÞÑ 2 ` sTs

2 ´ sTs. 2

Note 10 (Number of poles and zeros). The Euler transformation preserves the number of poles andthe number of zeros since the rule

s ÞÑ z ´ 1

Ts

replaces a polynomial of degree n in s by a polynomial of the same degree in z and vice-versa.However, the Tustin transformation

s ÞÑ 2pz ´ 1qTspz ` 1q

replaces a polynomial of degree n in s by a ratio of polynomials of the same degree in z . This meansthat it preserves the number of poles, but it can make discrete-time zeros appear, for systems thatdid not have continuous-time zeros. E.g., the integrator system 1

sbecomes

Tspz ` 1q2pz ´ 1q ,

which has a pole at z “ 1 (as expected), but also a zero at z “ ´1. 2

1.7 Exercise

1.1. Suppose that you sample at 1KHz a unit-amplitude continuous-time sinusoid ucptq with fre-quency 10Hz. Write the expression for the corresponding discrete-time sinusoid udpkq.

Page 21: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

Chapter 2

Parametric Identification using

Least-squares

Contents

2.1 Parametric Identification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152.2 Least-squares Line Fitting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152.3 Vector Least-squares . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172.4 MATLAB R© Hints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192.5 To Probe Further . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192.6 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

2.1 Parametric Identification

In parametric identification one attempts to determine a finite number of unknown parameters thatcharacterize the model of the system. The following is a typical problem in this class:

Problem 2.1 (Parametric transfer function identification). Determine the coefficients αi and βi of thesystem’s rational transfer function

Hpzq “ αmzm ` αm´1zm´1 ` ¨ ¨ ¨ ` α1z ` α0

zn ` βn´1zn´1 ` ¨ ¨ ¨ ` β1z ` β0.

The number of poles n and the number of zeros m are assumed known.

This can be done using the method of least-squares, which we introduce next, starting from asimple line fitting problem and eventually building up to Problem 2.1 in Chapter 3.

The methods of least-squares is generally attributed to Gauss [6] but the American mathematicianAdrain [1] seems to have arrived at the same results independently [7]. A detailed treatment of least-squares estimation can be found, e.g., in [10, Chapter 7].

2.2 Least-squares Line Fitting

Suppose that we have reasons to believe that two physical scalar variables x and y are approximately

related by a linear equation of the form

y “ ax ` b, (2.1)

15

Page 22: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

16 João P. Hespanha

y “ voltage

x “ current

R

(a) Voltage vs. current

y “ pressure

x “ height

(b) Pressure vs. height

Figure 2.1. Linear models

but we do not know the value of the constants a and b. The variables y and x could be, e.g., avoltage and a current in a simple electric circuit, or the height of a fluid in a tank and the pressureat the bottom of the tank (cf. Figure 2.1).

Numerical values for a and b can be determined by conducting several experiments and measuringthe values obtained for x and y. We will denote by pxi, yiq the measurements obtained on the ithexperiment of a total of N experiments. As illustrated in Figure 2.2, it is unlikely that we have exactly

yi “ axi ` b, @i P t1, 2, . . . , Nu, (2.2)

because of measurement errors and also because often the model (2.1) is only approximate.

x

y

y “ ax ` b

pxi, yiq

(a) Measurement noise

x

y

y “ ax ` b

pxi, yiq

(b) Nonlinearity

Figure 2.2. Main causes for discrepancy between experimental data and linear model

Least-squares identification attempts to find values for a and b for which the left- and the right-hand-sides of (2.2) differ by the smallest possible error. More precisely, the values of a and b leadingto the smallest possible sum of squares for the errors over the N experiments. This motivates thefollowing problem:

Problem 2.2 (Basic Least-Squares). Find values for a and b that minimize the following Sum-of-Squares Error (SSE):

SSE –

Nÿ

i“1

paxi ` b ´ yiq2.

Solution to Problem 2.2. This problem can be solved using standard calculus. All we need to do issolve

$’’’’&’’’’%

BSSE

Ba“

Nÿ

i“1

2xipaxi ` b ´ yiq “ 0

BSSE

Bb“

Nÿ

i“1

2paxi ` b ´ yiq “ 0

Page 23: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

System Identification 17

for the unknowns a and b. This is a simple task because it amounts to solving a system of linearequations:

$’’’’&’’’’%

2` Nÿ

i“1

x2i

˘a ` 2

` Nÿ

i“1

xi

˘b “ 2

Nÿ

i“1

xiyi

2` Nÿ

i“1

xi

˘a ` 2Nb “ 2

Nÿ

i“1

yi

ô

$’’’&’’’%

a “ Npři xiyiq ´ při xiqpři yiqNpři x2

i q ´ při xiq2

b “ při x2i qpři yiq ´ při xiyiqpři xiqNpři x2

i q ´ při xiq2

In the above expressions, we used a and b to denote the solution to the least-squares minimization.These are called the least-squares estimates of a and b, respectively. 2

Note 11. Statistical interpreta-tion of least-squares. . . p. 19Attention! The above estimates for a and b are not valid when

Npÿ

i

x2i q ´ p

ÿ

i

xiq2 “ 0, (2.3)

because this would lead to a division by zero. It turns out that (2.3) only holds when the xi obtainedNote 12. Why does (2.3) only holdwhen all the xi are equal to eachother? . . . p. 20drafttextOnlyshow sufficiency, i.e., that all xi

equal lead to (2.3).

in all experiments are exactly the same, as shown in Figure 2.3. Such set of measurements does not

x

y

Figure 2.3. Singularity in least-squares line fitting due to poor data.

provide enough information to estimate the parameter a and b that characterize the line defined by(2.1). 2

2.3 Vector Least-squares

The least-square problem defined in Section 2.2 can be extended to a more general linear model,where y is a scalar, z –

“z1 z2 ¨ ¨ ¨ zm

‰an m-vector, and these variables are related by a

linear equation of the formNotation 2. a¨b denotes the innerproduct of a and b. . . p. 19

Note 13. The line fitting problemis a special case of this one forz “ rx 1s and θ “ ra bs.

y “mÿ

j“1

zjθj “ z ¨ θ, (2.4)

where θ –“θ1 θ2 ¨ ¨ ¨ θm

‰is an m-vector with parameters whose values we would like to

determine.

To determine the parameter vector θ, we conduct N experiments from which we obtain measure- Attention! We are now using piqto denote the ith experiment sincethe subscript in zj is needed todenotes the jth entry of the vectorz .

ments`zpiq, ypiq

˘, i P t1, 2, . . . , Nu, where each zpiq denotes one m-vector and each ypiq a scalar.

The least-squares problem is now formulated as follows:

Problem 2.3 (Vector Least-Squares). Find values for θ –“θ1 θ2 ¨ ¨ ¨ θm

‰that minimize the

following Sum-of-Squares Error (SSE):

SSE –

Nÿ

i“1

`zpiq ¨ θ ´ ypiq

˘2.

Page 24: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

18 João P. Hespanha

Solution to Problem 2.3. This problem can also be solved using standard calculus. Essentially wehave to solve

BSSE

Bθ1“ BSSE

Bθ2“ ¨ ¨ ¨ “ BSSE

Bθm“ 0,

for the unknown θi . The equation above can also be re-written asNotation 3. ∇x fpxq denotes thegradient of fpxq. . . p. 19 ∇θSSE “

”BSSE

Bθ1

BSSEBθ2

¨ ¨ ¨ BSSEBθm

ı“ 0.

However, to simplify the computation it is convenient to write the SSE in vector notation. DefiningNote 14. Vector notation is con-venient both for algebraic manipu-lations and for efficient MATLAB R©

computations.

E to be an N-vector obtained by stacking all the errors zpiq ¨ θ ´ ypiq on top of each other, i.e.,

E –

»———–

zp1q ¨ θ ´ yp1qzp2q ¨ θ ´ yp2q

...zpNq ¨ θ ´ ypNq

fiffiffiffifl

Nˆ1

,

we can writeNotation 4. Given a matrix M , wedenote the transpose of M by M1 . SSE “ E2 “ E 1E.

Moreover, by viewing θ as a column vector, we can write

E “ Zθ ´ Y ,

where Z denotes a N ˆ m matrix obtained by stacking all the row vectors zpiq on top of each other,and Y an m-vector obtained by stacking all the ypiq on top of each other, i.e.,

Z “

»———–

zp1qzp2q

...zpNq

fiffiffiffifl

Nˆm

, Y “

»———–

yp1qyp2q

...ypNq

fiffiffiffifl

Nˆ1

.

Therefore

SSE “ pθ1Z 1 ´ Y 1qpZθ ´ Y q “ θ1Z 1Zθ ´ 2Y 1Zθ ` Y 1Y . (2.5)

It is now straightforward to compute the gradient of the SSE and find the solution to ∇θSSE “ 0:Note 15. The gradientof a quadratic functionfpxq “ x1Qx ` cx ` d,is given by ∇x fpxq “x1pQ ` Q1q ` c. . . p. 20

MATLAB R© Hint 9. ZzY computesdirectly pZ1Zq´1Z1Y in a very ef-ficient way, which avoids invertingZ1Z by solving directly the linearsystem of equations in (2.6). Thisis desirable, because this opera-tion is often ill-conditioned.

∇θSSE “ 2θ1Z 1Z ´ 2Y 1Z “ 0 ô θ1 “ Y 1Z pZ 1Z q´1, (2.6)

which yields the following least-squares estimate for θ:

θ “ pZ 1Z q´1Z 1Y . (2.7)

Since Z 1Z “ ři zpiq1zpiq and Z 1Y “ ř

i zpiq1ypiq, we can re-write the above formula as

θ “ R´1f, R –

Nÿ

i“1

zpiq1zpiq, f –

Nÿ

i“1

zpiq1ypiq.

One can gauge the quality of the fit by computing the SSE achieved by the estimate (i.e., theminimum achievable squared-error). Replacing the estimate (2.7) in (2.5) we obtain

SSE

Y 2“ Z θ ´ Y 2

Y 2“ 1 ´ Y 1Z pZ 1Z q´1Z 1Y

Y 1Y“ 1 ´ Y 1Z θ

Y 1Y. (2.8)

When this error-to-signal ratio is much smaller than one, the mismatch between the left- and right-hand-sides of (2.4) has been made significantly smaller than the output. 2

Attention! The above estimate for θ is not valid when the mˆm matrix R is not invertible. SingularityMATLAB R© Hint 10. svd(A)provides a measure of how closeA is to being singular. . . p. 19

of R is a situation similar to (2.3) in line fitting and it means that the zpiq are not sufficiently richto estimate θ. In practice, even when R is invertible, poor estimates are obtained if R is close to asingular matrix. 2

Page 25: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

System Identification 19

2.4 MATLAB R© Hints

MATLAB R© Hint 10 (svd). The command svd(A) computes the singular values of the matrix A. Thesingular values of a matrix A are the square-roots of the eigenvalues of A1A. Singular values arealways real and nonnegative.

1. The largest singular value (written σmaxrAs) provides a measure of how much a matrix canamplify a vector. In particular,

Ax ď σmaxrAsx.

2. The smallest singular value (written σminrAs) provides a measure of how little a matrix canamplify a vector. In particular,

Ax ě σminrAsx.

For singular matrices σminrAs “ 0.

3. The ratio between the largest and smallest singular values is called the condition number ofa matrix:

ρrAs –σmaxrAsσminrAs .

For singular matrices, the condition number is equal to 8. Finite but large condition numberscorrespond to matrices that are nonsingular but “close” to being singular, in the sense thatthey can become singular by making small changes in their entries. Because of this property,the condition number provides a measure of how close a matrix is to being singular.

Inverting matrices with large condition numbers is very difficult and often results in largenumerical errors due to round-off. 2

2.5 To Probe Further

Notation 2 (Inner product). Given two m-vectors, a ““a1 a2 ¨ ¨ ¨ am

‰and a “

“a1 a2 ¨ ¨ ¨ am

‰,

a ¨ b denotes the inner product of a and b, i.e.,

a ¨ b “mÿ

i“1

aibi.

2

Notation 3 (Gradient). Given a scalar function of n variables fpx1, . . . , xmq, ∇x f denotes the gradientof f , i.e.,

∇x fpx1, x2, . . . , xmq “”

BfBx1

BfBx2

¨ ¨ ¨ BfBxm

ı. 2

Note 11 (Statistical interpretation of least-squares). Suppose that the mismatch between left- andthe right-hand sides of (2.2) is due to uncorrelated zero-mean noise. In particular, that

yi “ axi ` b ` ni, @i P t1, 2, . . . , nu,

where all the ni are uncorrelated zero-mean random variables with the same variance σ 2, i.e.,

Ernis “ 0, Ern2i s “ σ 2, Erni nj s “ 0,@i, j ‰ i.

The Gauss-Markov Theorem stated below justifies the wide use of least-squares estimation.

Page 26: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

20 João P. Hespanha

Theorem 2.1 (Gauss-Markov). The best linear unbiased estimator (BLUE) for the parameters a and

b is the least-squares estimator.

Some clarification is needed to understand this theorem

1. The Gauss-Markov Theorem 2.1 compares all linear estimators, i.e., all estimators of the form

a “ α1y1 ` ¨ ¨ ¨ ` αnyn, b “ β1y1 ` ¨ ¨ ¨ ` βnyn,

where the αi, βi are coefficients that may depend on the xi .

2. It then asks what is the choice for the αi, βi that lead to an estimator that is “best” in thesense that it is (i) unbiased, i.e., for which

Eras “ a, Erbs “ b,

and (ii) results in the smallest possible variance for the estimation error, i.e., that minimizes

Erpa ´ aq2 ` pb ´ bq2s.

The conclusion is that the least-squares estimator satisfies these requirements.

Unbiasedness, means that when we repeat the identification procedure many time, although we maynever get a “ a and b “ b, the estimates obtained will be clustered around the true values.Minimum variance, means that the clusters so obtained will be as “narrow” as possible. 2

Note 12 (Singularity of line fit). The estimates for a and b are not valid when

Npÿ

i

x2i q ´ p

ÿ

i

xiq2 “ 0.

To understand when this can happen let us compute

Nÿ

i

pxi ´ µq2 “ Nÿ

i

x2i ´ 2Nµ

ÿ

i

xi ` n2µ2

but Nµ “ ři xi , so

Nÿ

i

pxi ´ µq2 “ Nÿ

i

x2i ´ p

ÿ

i

xiq2.

This means that we run into trouble when

ÿ

i

pxi ´ µq2 “ 0,

which can only occur when all the xi are the same and equal to µ. 2

Note 15 (Gradient of a quadratic function). Given a m ˆ m matrix Q and a m-row vector c, thegradient of the quadratic function

fpxq “ x 1Qx ` cx “mÿ

i“1

mÿ

j“1

qijxixj `mÿ

i“1

cixi.

To determine the gradient of f , we need to compute:

BfpxqBxk

“mÿ

i“1

mÿ

j“1

qijxi

Bxj

Bxk`

mÿ

i“1

mÿ

j“1

qijxjBxi

Bxk`

mÿ

i“1

ciBxi

Bxk.

Page 27: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

System Identification 21

However, Bxi

Bxkand

Bxj

Bxkare zero whenever i ‰ k and j ‰ k , respectively, and 1 otherwise. Therefore,

the summations above can be simplified to

BfpxqBxk

“mÿ

i“1

qikxi `mÿ

j“1

qkjxj ` ck “mÿ

i“1

pqik ` qkiqxi ` ck .

Therefore

∇x fpxq “”

BfpxqBx1

BfpxqBx2

¨ ¨ ¨ BfpxqBxm

ı

““řm

i“1pqi1 ` q1iqxi ` c1 ¨ ¨ ¨ řmi“1pqim ` qmiqxi ` cm

“ x 1pQ ` Q1q ` c. 2

2.6 Exercises

2.1 (Electrical circuit). Consider the electrical circuit in Figure 2.4, where the voltage U across thesource and the resistor R are unknown. To determine the values of U and R you place several test

+

−U

RA

B

ri

Ii

Vi

Figure 2.4. Electrical circuit

resistors ri between the terminals A, B and measure the voltages Vi and currents Ii across them.

1. Write a MATLAB R© script to compute the voltages Vi and currents Ii that would be obtainedwhen U “ 10V , R “ 1kΩ, and the ri are equally spaced in the interval r100Ω, 10kΩs. Add tothe “correct” voltage and current values measurement noise. Use for the currents and for thevoltages Gaussian distributed noise with zero mean and standard deviation .1mA and 10mV ,respectively.

The script should take as input the number N of test resistors.

2. Use least-squares to determine the values of R and U from the measurements for N Pt5, 10, 50, 100, 1000u. Repeat each procedure 5 times and plot the average error that youobtained in your estimates versus N . Use a logarithmic scale. What do you conclude? 2

2.2 (Nonlinear spring). Consider a nonlinear spring with restoring force

F “ ´px ` x3q,

where x denotes the spring displacement. Use least-squares to determine linear models for thespring of the form

F “ ax ` b.

Compute values for the parameters a and b for

1. forces evenly distributed in the interval r´.1, .1s,

2. forces evenly distributed in the interval r´.5, .5s, and

Page 28: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

22 João P. Hespanha

3. forces evenly distributed in the interval r´1, 1s.

For each case

1. calculate the SSE ,

2. plot the actual and estimated forces vs. x , and

3. plot the estimation error vs. x . 2

Page 29: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

Chapter 3

Parametric Identification of an ARX

Model

Contents

3.1 ARX Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233.2 Identification of an ARX Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243.3 Dealing with Known Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253.4 MATLAB R© Hints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253.5 To Probe Further . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273.6 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

3.1 ARX Model

Suppose that we want to determine the transfer function Hpzq of the discrete-time system in Fig-ure 3.1. In least-squares identification, one converts the problem of estimating Hpzq into the vector

upkq ypkqHpzq “?

Figure 3.1. System identification from input/output experimental data

least-squares problem considered in Section 2.3. This is done using the ARX model that will beconstructed below.

The z-transforms of the input and output of the system in Figure 3.1 are related by

Y pzqUpzq “ Hpzq “ αmzm ` αm´1z

m´1 ` ¨ ¨ ¨ ` α1z ` α0

zn ` βn´1zn´1 ` ¨ ¨ ¨ ` β1z ` β0, (3.1)

where the αi and the βi denote the coefficients of the numerator and denominator polynomials ofHpzq. Multiplying the numerator and denominator of Hpzq by z´n, we obtain the transfer functionexpressed in negative powers of z:

Y pzqUpzq “ αmz´n`m ` αm´1z

´n`m´1 ` ¨ ¨ ¨ ` α1z´n`1 ` α0z

´n

1 ` βn´1z´1 ` ¨ ¨ ¨ ` β1z´n`1 ` β0z´n

“ z´pn´mq αm ` αm´1z´1 ` ¨ ¨ ¨ ` α1z

´m`1 ` α0z´m

1 ` βn´1z´1 ` ¨ ¨ ¨ ` β1z´n`1 ` β0z´n

23

Page 30: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

24 João P. Hespanha

and therefore

Y pzq ` βn´1z´1Y pzq ` ¨ ¨ ¨ ` β1z

´n`1Y pzq ` β0z´nY pzq “

αmz´n`mUpzq ` αm´1z´n`m´1Upzq ` ¨ ¨ ¨ ` α1z

´n`1Upzq ` α0z´nUpzq.

Taking inverse z-transforms we obtainNote 16. We can view the differ-ence n´m between the degrees ofthe denominator and numerator of(3.1) as a delay, because the out-put ypkq at time k in (3.2) onlydepends on the value of the inputu`k´pn´mq

˘at time k´pn´mq

and on previous values of the in-put.

ypkq ` βn´1ypk ´ 1q ` ¨ ¨ ¨ ` β1ypk ´ n ` 1q ` β0ypk ´ nq “αmupk ´ n ` mq ` αm´1upk ´ n ` m ´ 1q ` ¨ ¨ ¨ ` α1upk ´ n ` 1q ` α0upk ´ nq. (3.2)

This can be re-written compactly as

ypkq “ φpkq ¨ θ (3.3)

where the pn ` m ` 1q-vector θ contains the coefficient of the transfer function and the vector φpkqthe past inputs and outputs, i.e.,

θ –“´βn´1 ¨ ¨ ¨ ´β1 ´β0 αm αm´1 ¨ ¨ ¨ α1 α0

φpkq –“ypk ´ 1q ¨ ¨ ¨ ypk ´ nq upk ´ n ` mq ¨ ¨ ¨ upk ´ nq

‰.

The vector φpkq is called the regression vector and the equation (3.3) is called an ARX model, ashort form of Auto-Regression model with eXogeneous inputs.

3.2 Identification of an ARX Model

We are now ready to solve the system identification Problem 2.1 introduced in Chapter 2, by applyingthe least-squares method to the ARX model:

Solution to Problem 2.1.

1. Apply a probe input signal upkq, k P t1, 2, . . . , Nu to the system.

2. Measure the corresponding output ypkq, k P t1, 2, . . . , Nu.

3. Determine the values for the parameter θ that minimize the discrepancy between the left- andthe right-hand-sides of (3.3) in a least-squares sense.

According to Section 2.3, the least-squares estimate of θ is given byMATLAB R© Hint 11. PHIzY com-

putes θ directly, from the matrixPHI“ Φ and the vector Y“ Y .

θ “ pΦ1Φq´1Φ1Y , (3.4)

whereAttention! When the system is atrest before k “ 1, upkq “ypkq “ 0 @k ď 0. Otherwise, ifthe past inputs are unknown, oneneeds to remove from Φ and Y allrows with unknown data.

Φ –

»—–

φp1qφp2q

...φpNq

fiffifl “

»—–

yp0q ¨¨¨ yp1´nq up1´n`mq ¨¨¨ up1´nqyp1q ¨¨¨ yp2´nq up2´n`mq ¨¨¨ up2´nq

......

......

ypN´1q ¨¨¨ ypN´nq upN´n`mq ¨¨¨ upN´nq

fiffifl , Y –

»—–

yp1qyp2q

...ypNq

fiffifl ,

or equivalently

θ “ R´1f, R – Φ1Φ “Nÿ

k“1

φpkq1φpkq, f – Φ1Y “Nÿ

k“1

φpkq1ypkq.

The quality of the fit can be assessed by computing the error-to-signal ratio

SSE

Y 2“ 1 ´ Y 1Φθ

Y 1Y.

When this quantity is much smaller than one, the mismatch between the left- and right-hand-sidesof (3.3) has been made significantly smaller than the output. 2

Page 31: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

System Identification 25

MATLAB R© Hint 12. arx is con-venient to perform ARX modelsidentification because it does notrequire the construction of the ma-trix Φ and the vector Y . . . p. 25

MATLAB R© Hint 13. compare isuseful to determine the quality offit. . . p. 27

Attention! Two common causes for errors in least-squares identifications of ARX models are:

1. incorrect construction of the matrix Φ and/or vector Y ;

2. incorrect construction of the identified transfer function from the entries in the least-squaresestimate θ.

Both errors can be avoided using the MATLAB R© command arx.

3.3 Dealing with Known Parameters

Due to physical considerations, one often knows one or more poles/zeros of the process. For example:

1. one may know that the process has an integrator, which corresponds to a continuous-time poleat s “ 0 and consequently to a discrete-time pole at z “ 1; or

2. that the process has a differentiator, which corresponds to a continuous-time zero at s “ 0and consequently to a discrete-time zero at z “ 1.

In this case, it suffices to identify the remaining poles/zeros, which can be done as follows: Supposethat it is known that the transfer function Hpzq has a pole at z “ λ, i.e.,

Hpzq “ 1

z ´ λHpzq,

where Hpzq corresponds to the unknown portion of the transfer function. In this case, the z-transformsNote 17. The transfer functionHpzq is proper only if Hpzq isstrictly proper. However, even ifHpzq happens not to be proper,this introduces no difficulties forthis method of system identifica-tion.

of the input and output of the system are related by

Y pzqUpzq “ 1

z ´ λHpzq,

and therefore

Y pzqUpzq “ Hpzq,

where

Y pzq – pz ´ λqY pzq ñ ypkq “ ypk ` 1q ´ λypkq. (3.5)

This means that we can directly estimate Hpzq by computing ypkq prior to identification and thenNote 18. The new output ypkq isnot a causal function of the orig-inal output ypkq, but this is ofno consequence since we have thewhole ypkq available when wecarry out identification.

MATLAB R© Hint 14. One must becareful in constructing the vector yin (3.5) to be used by the functionarx. . . p. 26

regarding this variable as the output, instead of ypkq.

Attention! To obtain the original transfer function Hpzq, one needs to multiply the identified functionHpzq by the term 1

z´λ. 2

3.4 MATLAB R© Hints

MATLAB R© Hint 12 (arx). The command arx from the identification toolbox performs least-squaresidentification of ARX models. To use this command one must

1. Create a data object that encapsulates the input/output data using:

data=iddata(y,u,Ts);

where u and y are vectors with the input and output data, respectively, and Ts is the samplinginterval.

Data from multiple experiments can be combined using the command merge as follows:

Page 32: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

26 João P. Hespanha

dat1=iddata(y1,u1,Ts);

dat2=iddata(y1,u1,Ts);

data=merge(dat1,dat2);

2. Compute the estimated model using:

model=arx(data,[na,nb,nk])

where data is the object with input/output data; na, nb, nk are integers that define theNote 19. MATLAB R© is an objectoriented language and model.a

is the property a of the objectmodel.

degrees of the numerator and denominator of the transfer function (see below); and model aMATLAB R© object with the coefficients of the transfer function. The coefficient are returned fornegative powers of z . In particular, the estimated transfer function is given by

Note 20. Typically, one choosesna equal to the (expected) num-ber of poles, nk equal to the (ex-pected) input delay, and nb “na ´ nk ` 1, which would bethe corresponding number of ze-ros. In this case, ypkq is a func-tion of ypk ´ 1q, . . . , ypk ´ naqand of upk ´nkq, . . . , upk ´nk´nb ` 1q. See equations (3.1)–(3.2). . . p. 23

Y pzqUpzq “ model.bp1q ` model.bp2qz´1 ` ¨ ¨ ¨ ` model.bpnk ` nbqz´nk´nb`1

˘

model.ap1q ` model.ap2qz´1 ` ¨ ¨ ¨ ` model.apna ` 1qz´na, (3.6)

with the first coefficient of model.a equal to 1 and the first nk coefficients of model.b equalto 0.

For processes with nu inputs and ny outputs, na should be an ny ˆ ny square matrix andboth nb and nk should be ny ˆ nu rectangular matrices. In general, all entries of na shouldbe equal to the number of poles of each transfer function, whereas the entries of nk and nb

should reflect the (possibly different) delays and number of zeros, respectively, for each transferfunction.

The estimated discrete-time transfer function can be recovered using the MATLAB R© command

sysd=tf(model,’Measured’)

The object model contains a lot more information about the estimated transfer function, whichincludes

1. model.da and model.db give the standard deviations associated with the estimates of thecoefficient.

Note 21. Obtaining a standarddeviation for one parameter that iscomparable or larger than its esti-mated value typically arises in oneof three situations. . .

One should compare the value of each parameter with its standard deviation. A large value inone or more of the standard deviations indicates that the matrix R – Φ1Φ is close to singularand points to little confidence on the estimated value of that parameter.

2. model.noise provides a measure of the quality of fit and is essentially the value of SSE

divided by the number of samples. However, this measure is not normalized by the norm-squareof Y , opposite to (2.8).

One can type idprops idpoly at the MATLAB R© prompt to obtain more information about otherinformation that is available in model.

The MATLAB R© command arx uses a more sophisticated algorithm than the one described in thesenotes so the results obtained using arx may not match exactly the ones obtained using the formula(3.4). 2

MATLAB R© Hint 14 (Dealing with known parameters). One must be careful in constructing the vectory in (3.5) to be used by the function arx. In particular, its first element must be equal to

yp2q ´ λyp1q,as suggested by (3.5). Moreover, if we had values of ypkq and upkq for k P t1, 2, . . . , Nu, thenypkq will only have values for k P t1, 2, . . . , N ´ 1u, because the last element of ypkq that we canconstruct is

ypN ´ 1q “ ypNq ´ ypN ´ 1q.Since the function iddata only takes input/output pairs of the same length, this means that we needto discard the last input data upNq. The following MATLAB R© commands could be used construct y

from y and also to discard the last element of u:

Page 33: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

System Identification 27

bary=y(2:end)-lambda*y(1:end-1); u=u(1:end-1); 2

MATLAB R© Hint 13 (compare). The command compare from the identification toolbox allows oneto compare experimental outputs with simulated values from an estimated model. This is useful tovalidate model identification. The command

compare(data,model)

plots the measured output from the input/output data object data and the predictions obtained fromthe estimated model model. See MATLAB R© hints 12, 21 for details on these objects. 2

3.5 To Probe Further

Note 21 (Large standard deviations for the parameter estimates). Obtaining a standard deviation forone parameter that is comparable or larger than its estimated value typically arises in one of threesituations:

1. The data collected is not sufficiently rich. This issue is discussed in detail in Section 4.1. It cangenerally be resolved by choosing a different input signal u for the identification procedure.

2. One has hypothesized an incorrect value for the number of poles, the number of zeros, of thesystem delay. This issue is discussed in detail in Section 4.4. It can generally be resolved byone of three options:

• When encounters small estimated value for parameters corresponding to the terms inthe denominator of (3.6) with the most negative powers in z , this may be resolved byselecting a smaller value for nb;

• When encounters small estimated value for parameters corresponding to the terms in thenumerator of (3.6) with the most negative powers in z , this may be resolved by selectinga smaller value for na;

• When encounters small estimated value for parameters corresponding to the terms in thenumerator of (3.6) with the least negative powers in z , this may be resolved by selectinga large value for nk.

3. One is trying to identify a parameter whose value is actually zero or very small.

When the parameter is one of the leading/trailing coefficients of the numerator/denominatorpolynomials, this is can be addressed as discussed in the previous bullet. Otherwise, generallythere is not much one can do about it during system identification. However, since there is afair chance that the value of this parameter has a large percentage error (perhaps even thewrong sign), we must make sure that whatever controller we design for this system is robustwith respect to errors in such parameter. This issue is addressed in Chapters 6–7. 2

3.6 Exercises

3.1 (Known zero). Suppose that the process is known to have a zero at z “ γ , i.e., that

Hpzq “ pz ´ γqHpzq,

where Hpzq corresponds to the unknown portion of the transfer function. How would you estimateHpzq? What if you known that the process has both a zero at γ and a pole at λ? 2

3.2 (Selected parameters). The data provided was obtained from a system with transfer function

Hpzq “ z ´ .5

pz ´ .3qpz ´ pq ,

where p is unknown. Use the least-squares method to determine the value of p. 2

Page 34: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

28 João P. Hespanha

Page 35: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

Chapter 4

Practical Considerations in Parametric

Identification

Contents

4.1 Choice of Inputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294.2 Signal Scaling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334.3 Choice of Sampling Frequency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 364.4 Choice of Model Order . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 374.5 Combination of Multiple Experiments . . . . . . . . . . . . . . . . . . . . . . . . . . . 414.6 Closed-loop Identification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 424.7 MATLAB R© Hints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 424.8 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

4.1 Choice of Inputs

The quality of least-squares estimates depends significantly on the input upkq used. The choice ofinputs should take into account the following requirements:

1. The input should be sufficiently rich so that the matrix R is nonsingular (and is well condi-tioned).

(a) Single sinusoids should be avoided because a sinusoid of frequency Ω will not allow usNote 22. Why? H1pzq “ 1

z´1

and H2pzq “ z`2z´3 have the same

value for z “ ejπ2 “ j . Thereforethey will lead to the same ypkqwhen upkq is a sinusoid with fre-quency π2. This input will not al-low us to distinguish between H1

and H2 .

to distinguish between different transfer functions with exactly the same value at thepoint z “ ejΩ.

(b) Good inputs include: square-waves, the sum of many sinusoids, or a chirp signal (i.e., asignal with time-varying frequency).

2. The amplitude of the resulting output ypkq should be much larger than the measurement noise.In particular, large inputs are needed when one wants to probe the system at frequencies forwhich the noise is large.

However, when the process is nonlinear but is being approximated by a linear model, largeinputs may be problematic because the linearization may not be valid. As shown in Figure 4.1,there is usually an “optimal” input level that needs to be determined by trial-and-error. 2

3. The input should be representative of the class of inputs that are expected to appear in thefeedback loop.

(a) The input should have strong components in the range of frequencies at which the systemwill operate.

29

Page 36: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

30 João P. Hespanha

noisedominates

optimal

nonlinearbehavior

SSEy2

input magnitude

Figure 4.1. Optimal choice of input magnitude

(b) The magnitude of the input should be representative of the magnitudes that are expectedin the closed loop.

Validation. The choice of input is perhaps the most critical aspect in good system identification.After any identification procedure the following steps should be followed to make sure that the datacollected is adequate:

1. Check if the matrix R is far from singular. If not a different “richer” input should be used.MATLAB R© Hint 12. When usingthe arx command, the singular-ity of the matrix R can be inferredfrom the standard deviations as-sociated with the parameter esti-mates. . . p. 25,27

2. Check the quality of fit by computing SSEY 2 . If this quantity is not small, one of the following

MATLAB R© Hint 12. When usingthe arx command, the qual-ity of fit can be inferred fromthe noise field in the estimatedmodel. . . p. 25

is probably occurring:

(a) There is too much noise and the input magnitude needs to be increased.

(b) The inputs are outside the range for which the process is approximately linear and theinput magnitude needs to be decreased.

(c) The assumed degrees for the numerator and denominator are incorrect (see Section 4.4).

3. After an input signal upkq passed the checks above, repeat the identification experimentwith the input αupkq with α “ ´1, α “ .5. If the process is in the linear region, themeasured outputs should roughly by equal to αypkq and the two additional experimentsshould approximately result in the same transfer function. When one obtains larger gains inthe experiment with α “ .5, this typically means that the process is saturating and one needsto decrease the magnitude of the input.

Example 4.1 (Two-cart with spring). To make these concepts concrete, we will use as a runningexample the identification of the two-carts with spring apparatus shown in Figure 4.2. From Newton’s

m1 m2

x1 x2

F

Figure 4.2. Two-mass with spring

law one concludes that

m1:x1 “ kpx2 ´ x1q ` f, m2:x2 “ kpx1 ´ x2q, (4.1)

where x1 and x2 are the positions of both carts, m1 and m2 the masses of the carts, and k the springconstant. The force f is produced by an electrical motor driven by an applied voltage v according to

f “ KmKg

Rmr

´v ´ KmKg

r9x1

¯, (4.2)

where Km, Kg, Rm, and r are the motor parameters.

Page 37: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

System Identification 31

For this system, we are interested in taken the control input to be the applied voltage u – v

and the measured output to be the position y – x2 of the second cart. To determine the system’stransfer function, we replace f from (4.2) into (4.1) and take Laplace transforms to conclude that

#m1s

2X1psq “ k`Y psq ´ X1psq

˘` KmKg

Rmr

´Upsq ´ KmKg

rsX1psq

¯

m2 s2Y psq “ k`X1psq ´ Y psq

˘

ñ#´

m1s2 ` K 2

mK 2g

Rmr2 s ` k¯

X1psq “ kY psq ` KmKg

RmrUpsq

`m2 s2 ` k

˘Y psq “ kX1psq

ñ`m2 s2 ` k

˘´m1s

2 `K 2

mK 2g

Rmr2s ` k

¯Y psq “ k2Y psq ` kKmKg

RmrUpsq

Y psqUpsq “

kKmKg

Rmr`m2 s2 ` k

˘´m1s2 ` K 2

mK 2g

Rmr2 s ` k¯

´ k2(4.3)

where the large caps signals denote the Laplace transforms of the corresponding small caps signals.

From the first principles model derived above, we expect this continuous-time system to have 4poles and no zero. Moreover, a close look at the denominator of the transfer function in (4.3) reveals

Note 23. We can make use of theknowledge that the continuous-time system has 4 poles, be-cause the corresponding discrete-time transfer function will havethe same number of poles. How-ever, the absence of zeros inthe continuous-time transfer func-tions tell us little about the num-ber of zeros in the correspond-ing discrete-time transfer functionbecause the Tustin transformationdoes not preserve the number ofzeros (cf. Note 10). . . p. 14

that there is no term of order zero, since the denominator is equal to

`m2 s2 ` k

˘´m1s

2 `K 2

mK 2g

Rmr2s ` k

¯´ k2 “ m2 s2

´m1s

2 `K 2

mK 2g

Rmr2s ` k

¯` km1s

2 `kK 2

mK 2g

Rmr2s

and therefore the system should have one pole at zero, i.e., it should contain one pure integrator.

Our goal now is to determine the system’s transfer function (4.3) using system identification frominput/output measurements. The need for this typically stems from the fact that

1. we may not know the values of the system parameters m1, m2, k , km, Kg, Rm, and r; and

2. the first-principles model (4.1)–(4.2) may be ignoring factors that turn out to be important, e.g.,the mass of the spring itself, friction between the masses and whatever platform is supportingthem, the fact that the track where the masses move may not be perfectly horizontal, etc.

Figure 4.3(a) shows four sets of input/output data and four discrete-time transfer functions iden-tified from these data sets.

Key observations. A careful examination of the outputs of the arx command and the plots inFigure 4.3 reveals the following:

1. The quality of fit appears to be very good since arx reports a very small value for the noise

parameter (around 10´10). But this value is suspiciously small when compared to the averagevalue of y2 (around 10´2).

2. The standard deviations associated with the denominator parameters are small when comparedto the parameter estimates (ranging from 2 to 100 times smaller than the estimates).

3. The standard deviations associated with the numerator parameters appear to be worse, oftenexceeding the estimate, which indicate problems in the estimated transfer functions.

4. While difficult to see in Figure 4.3(a), it turns out that the data collected with similar inputsignals (square wave with a period of 2Hz) but 2 different amplitudes (2v and 4v) resulted inroughly the same shape of the output, but scaled appropriately. However, the fact that this isdifficult to see in Figure 4.3(a) because of scaling is actually an indication of trouble, as weshall discuss shortly.

Page 38: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

32 João P. Hespanha

0.5 1 1.5

−2

−1

0

1

2

square_a2_f0.5.mat

input [v]output [m]

0.5 1 1.5

−2

−1

0

1

2

square_a2_f1.mat

input [v]output [m]

0.5 1 1.5

−2

−1

0

1

2

square_a2_f2.mat

input [v]output [m]

0.5 1 1.5

−4

−2

0

2

4

square_a4_f2.mat

input [v]output [m]

(a) Four sets of input/output data used to estimate the two-mass system in Figure 4.2. In allexperiments the input signal u is a square wave with frequencies .5Hz, 1Hz, 2Hz, and 2Hz,respectively, from left to right and top to bottom. In the first three plots the square waveswitches from -2v to +2v, whereas in the last plot it switches from -4v to +4v. All signals weresampled at 1KHz.

10−3

10−2

10−1

100

101

102

103

−140

−120

−100

−80

−60

−40

−20

0

f [Hz]

mag

nitu

de [d

B]

square_a2_f0.5.matsquare_a2_f1.matsquare_a2_f2.matsquare_a4_f2.mat

10−3

10−2

10−1

100

101

102

103

−400

−300

−200

−100

0

f [Hz]

phas

e [d

eg]

square_a2_f0.5.matsquare_a2_f1.matsquare_a2_f2.matsquare_a4_f2.mat

(b) Four discrete-time transfer functions estimated from the four sets of input/output data in(a), sampled at 1KHz. The transfer functions were obtained using the MATLAB R© command arx

with na “ 4, nb “ 4, and nk “ 1, which reflects an expectation of 4 poles and a delay of onesampling period. The one period delay from upkq to ypkq is natural since a signal applied atthe sampling time k will not affect the output at the same sampling time k (See Note 20, p. 26).The labels in the transfer functions refer to the titles of the four sets of input/output data in(a).

Figure 4.3. Initial attempt to estimate the discrete-time transfer function for the two-mass system in Figure 4.2.

Page 39: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

System Identification 33

5. The integrator that we were expecting in the transfer functions is not there.

6. The four sets of data input/output data resulted in dramatically different identified transfer

functions.

The last three items are, of course, of great concern, and a clear indication that we are not gettinga good transfer function.

Fixes. The fact that we are not seeing an integrator in the identified transfer functions is nottoo surprising, since our probe input signals are periodic square waves, which has no componentat the zero frequency. The input that has the most zero-frequency component is the square wavewith frequency .5Hz (cf. top-left plot in Figure 4.3(a)), for which less than a full period of data wasapplied to the system. Not surprisingly, that data resulted in the transfer function that is closer toan integrator (i.e., it is larger at low frequencies).

Since we know that the system has a structural pole at z “ 1, we should force it into the modelusing the technique seen in Section 3.3. Figure 4.4(a) shows the same four sets of input/output dataused to estimate the discrete-time transfer function, but the signal labeled “output” now correspondsto the signal y that we encountered in Section 3.3. The new identified transfer functions that appearin Figure 4.4(b) are now much more consistent, mostly exhibiting differences in phase equal to 360deg. However, the standard deviations associated with the numerator parameters continue to belarge, often exceeding the estimate. 2

4.2 Signal Scaling

For the computation of the least-squares estimate to be numerically well conditioned, it is importantthat the numerical values of both the inputs and the outputs have roughly the same order of magnitude.Because the units of these variable are generally quite different, this often requires scaling of thesevariables. It is good practice to scale both inputs and outputs so that all variable take “normal”

values in the same range, e.g., the interval r´1, 1s.

Attention! After identification, one must then adjust the system gain to reflect the scaling performedon the signals used for identification: Suppose that one takes the original input/output data set u, y

and constructs a new scaled data set u, y, using

upkq “ αuupkq, ypkq “ αyypkq, @k.

If one then uses u and y to identify the transfer function

Hpzq “ UpzqY pzq

“ αu

αy

UpzqY pzq ,

in order to obtain the original transfer function Hpzq from u to y, one need to reverse the scaling:

Hpzq “ UpzqY pzq “ αy

αuHpzq. 2

Example 4.2 (Two-cart with spring (cont.)). We can see in Figure 4.4(a), that the input and outputsignals used for identification exhibit vastly different scales. In fact, when drawn in the same axis,the output signals appears to be identically zero.

Fix. To minimize numerical errors, one can scale the output signal by multiplying it by a sufficientlylarge number so that it becomes comparable with the input. Figure 4.4(a) shows the same four setsof input/output data used to estimate the discrete-time transfer function, but the signal labeled“output” now corresponds to a scaled version of the signal y that we encountered in Section 3.3.

Page 40: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

34 João P. Hespanha

0.5 1 1.5

−2

−1

0

1

2

square_a2_f0.5.mat

input [v]output [m]

0.5 1 1.5

−2

−1

0

1

2

square_a2_f1.mat

input [v]output [m]

0.5 1 1.5

−2

−1

0

1

2

square_a2_f2.mat

input [v]output [m]

0.5 1 1.5

−4

−2

0

2

4

square_a4_f2.mat

input [v]output [m]

(a) Four sets of input/output data used to estimate the two-mass system in Figure 4.2. In allexperiments the input signal u is a square wave with frequencies .5Hz, 1Hz, 2Hz, and 2Hz,respectively, from left to right and top to bottom. In the first three plots the square waveswitches from -2v to +2v, whereas in the last plot it switches from -4v to +4v. The signallabeled “output” now corresponds to the signal y that we encountered in Section 3.3. Allsignals were sampled at 1KHz.

10−3

10−2

10−1

100

101

102

103

−150

−100

−50

0

50

f [Hz]

mag

nitu

de [d

B]

square_a2_f0.5.matsquare_a2_f1.matsquare_a2_f2.matsquare_a4_f2.mat

10−3

10−2

10−1

100

101

102

103

−200

−100

0

100

200

300

f [Hz]

phas

e [d

eg]

square_a2_f0.5.matsquare_a2_f1.matsquare_a2_f2.matsquare_a4_f2.mat

(b) Four discrete-time transfer functions estimated from the four sets of input/output data in(a), sampled at 1KHz. The transfer functions were obtained using the MATLAB R© command arx

with na “ 3, nb “ 4, and nk “ 0, which reflects an expectation of 3 poles in addition to theone at z “ 1 and no delay from u to y. No delay should now be expected since upkq can affectypk ` 1q, which appears directly in ypkq (See Note 20, p. 26). A pole at z “ 1 was insertedmanually into the transfer function returned by arx. The labels in the transfer functions referto the titles of the four sets of input/output data in (a).

Figure 4.4. Attempt to estimate the discrete-time transfer function for the two-mass system in Figure 4.2, forcing

a pole at z “ 1.

Page 41: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

System Identification 35

0.5 1 1.5

−2

−1

0

1

2

square_a2_f0.5.mat

input [v]output [m*5000]

0.5 1 1.5

−2

−1

0

1

2

square_a2_f1.mat

input [v]output [m*5000]

0.5 1 1.5

−2

−1

0

1

2

square_a2_f2.mat

input [v]output [m*5000]

0.5 1 1.5

−4

−2

0

2

4

square_a4_f2.mat

input [v]output [m*5000]

(a) Four sets of input/output data used to estimate the two-mass system in Figure 4.2. In allexperiments the input signal u is a square wave with frequencies .5Hz, 1Hz, 2Hz, and 2Hz,respectively, from left to right and top to bottom. In the first three plots the square waveswitches from -2v to +2v, whereas in the last plot it switches from -4v to +4v. The signallabeled “output” now corresponds to a scaled version of the signal y that we encountered inSection 3.3. All signals were sampled at 1KHz.

10−3

10−2

10−1

100

101

102

103

−150

−100

−50

0

50

f [Hz]

mag

nitu

de [d

B]

square_a2_f0.5.matsquare_a2_f1.matsquare_a2_f2.matsquare_a4_f2.mat

10−3

10−2

10−1

100

101

102

103

−200

−100

0

100

200

300

f [Hz]

phas

e [d

eg]

square_a2_f0.5.matsquare_a2_f1.matsquare_a2_f2.matsquare_a4_f2.mat

(b) Four discrete-time transfer functions estimated from the four sets of input/output data in(a), sampled at 1KHz. The transfer functions were obtained using the MATLAB R© command arx

with na “ 3, nb “ 4, and nk “ 0, which reflects an expectation of 3 poles in addition to theone at z “ 1 and no delay from u to y. A pole at z “ 1 was inserted manually into the transferfunction returned by arx and the output scaling was reversed back to the original units. Thelabels in the transfer functions refer to the titles of the four sets of input/output data in (a).

Figure 4.5. Attempt to estimate the discrete-time transfer function for the two-mass system in Figure 4.2, forcinga pole at z “ 1 and with appropriate output scaling.

Page 42: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

36 João P. Hespanha

Key observation. While the transfer functions identified do not show a significant improvements andthe standard deviations associated with the numerator parameters continue to be large, Figure 4.4(a)now shows a clue to further problems: the output signals exhibits significant quantization noise.

2

4.3 Choice of Sampling Frequency

For a discrete-time model to accurately capture the process’ continuous-time dynamics, the sam-pling frequency should be as large as possible. However, this often leads to difficulties in systemidentification.

As we have seen before, least-squares ARX identification amounts to finding the values for theparameters that minimize the sum of squares difference between the two sides of the followingequation:

ypkq “ ´βn´1ypk ´ 1q ´ ¨ ¨ ¨ ´ β1ypk ´ n ` 1q ` β0ypk ´ nq`` αmupk ´ n ` mq ` αm´1upk ´ n ` m ´ 1q ` ¨ ¨ ¨ ` α1upk ´ n ` 1q ` α0upk ´ nq. (4.4)

In particular, one is looking for values of the parameters that are optimal at predicting ypkq basedon inputs and outputs from time k ´ 1 back to time k ´ n.

When the sampling period is very short, all the output values

ypkq, ypk ´ 1q, . . . , ypk ´ nq

that appear in (4.4) are very close to each other and often their difference is smaller than onequantization interval of the analogue-to-digital converter (ADC). As shown in Figure 4.6, in this casethe pattern of output values that appear in (4.4) is mostly determined by the dynamics of the ADCconverter and the least-squares ARX model will contain little information about the process transferfunction.

0.96 0.98 1 1.02 1.04

−1.6

−1.5

−1.4

−1.3

−1.2

−1.1

−1

square_a2_f0.5.mat

input [v]output [m*5000]

0.96 0.98 1 1.02 1.04

1

1.2

1.4

1.6

1.8

2

square_a2_f1.mat

input [v]output [m*5000]

0.96 0.98 1 1.02 1.04

0.8

1

1.2

1.4

1.6

square_a2_f2.mat

input [v]output [m*5000]

0.96 0.98 1 1.02 1.04

2

2.5

3

3.5

square_a4_f2.mat

input [v]output [m*5000]

Figure 4.6. Magnified version of the four plots in Figure 4.5(a) showing the input and output signals around timet “ 1s. The patterns seen in the output signals are mostly determined by the dynamics of the ADC converter.

Page 43: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

System Identification 37

As we increase the sampling time, the difference between the consecutive output values increasesand eventually dominates the quantization noise. In practice, one wants to chose a sampling ratethat is large enough so that the Tustin transformation is valid but sufficiently small so that thequantization noise does not dominate. A good rule of thumb is to sample the system at a frequency20-40 times larger than the desired closed-loop bandwidth for the system.

Down-Sampling

It sometimes happens that the hardware used to collect data allow us to sample the system atfrequencies much larger than what is needed for identification—oversampling. In this case, onegenerally needs to down-sample the signals but this actually provides an opportunity to remove

measurement noise from the signals.

Suppose that ypkq and upkq have been sampled with a period Tlow but one wants to obtainMATLAB R© Hint 15. A signaly can by down-sampled as in(4.5) using bary=y(1:L:end).Down-sampling can also beachieved with the commandbary=downsample(y,L). Thiscommand requires MATLAB R©’ssignal processing toolbox.

signals ypkq and upkq sampled with period Thigh – L Tlow where L is some integer larger than one.

The simplest method to obtain ypkq and upkq consists of extracting only one out of each L

samples of the original signals:

ypkq “ ypLkq, upkq “ upLkq. (4.5)

Instead of discarding all the remaining samples, one can achieve some noise reduction by averaging,

MATLAB R© Hint 16. A signal y

can by down-sampled as in (4.6)using bary=(y(1:L:end-2)

+ y(2:L:end-1) +

y(3:L:end))/3.

as in

ypkq “ ypLk ´ 1q ` ypLkq ` ypLk ` 1q3

, (4.6)

upkq “ upLk ´ 1q ` upLkq ` upLk ` 1q3

, (4.7)

or even longer averaging. The down-sampled signals obtained in this way exhibit lower noise thanMATLAB R© Hint 17. Down-sampling with more sophis-ticated (and longer) filteringcan be achieved with thecommand resample, e.g.,bary=resample(y,1,L,1).This command requiresMATLAB R©’s signal process-ing toolbox. . . p. 42

the original ones because noise is being “averaged out.”

Example 4.3 (Two-cart with spring (cont.)). We can see, e.g., in Figure 4.4(b) that the system appearsto have an “interesting” dynamical behavior in the range of frequencies from .1 to 10Hz. “Interesting,”in the sense that the phase varies and the magnitude bode plot is not just a line. Since the samplingfrequency of 1kHz lies far above this range, we have the opportunity to down-sample the measuredsignals and remove some of the measurement noise that was evident in Figure 4.4(a).

Fix. To remove some noise quantization noise, we down-sampled the input and output signalsby a factor of 10 with the MATLAB R© resample command. The new discrete-time frequency istherefore now sampled only at 100Hz, but this still appears to be sufficiently large. Figure 4.7(a)shows the same four sets of input/output data used to estimate the discrete-time transfer function,down-sampled from the original 1KHz to 100Hz. By comparing this figure with Figure 4.5(a), we canobserve a significant reduction in the output noise level.

Key observation. The transfer functions identified show some improvement, especially because weare now starting to see some resonance, which would be expected in a system like this. Moreimportantly, now all the standard deviations associated with the numerator and denominator param-

eters are reasonably small when compared to the parameter estimates (ranging from 2.5 to 30 timessmaller than the estimates). 2

4.4 Choice of Model Order

A significant difficulty in parametric identification of ARX models is that to construct the regressionvector φpkq, one needs to know the degree n of the denominator. In fact, an incorrect choice for n

will generally lead to difficulties.

Page 44: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

38 João P. Hespanha

0.6 0.8 1 1.2 1.4 1.6−2

−1

0

1

2square_a2_f0.5.mat

input [v]output [m*500]

0.6 0.8 1 1.2 1.4 1.6−2

−1

0

1

2square_a2_f1.mat

input [v]output [m*500]

0.6 0.8 1 1.2 1.4 1.6−2

−1

0

1

2square_a2_f2.mat

input [v]output [m*500]

0.6 0.8 1 1.2 1.4 1.6−4

−2

0

2

4square_a4_f2.mat

input [v]output [m*500]

(a) Four sets of input/output data used to estimate the two-mass system in Figure 4.2. Inall experiments the input signal u is a square wave with frequencies .5Hz, 1Hz, 2Hz, and2Hz, respectively, from left to right and top to bottom. In the first three plots the square waveswitches from -2v to +2v, whereas in the last plot it switches from -4v to +4v. The signal labeled“output” corresponds to a scaled version of the signal y that we encountered in Section 3.3.All signals were down-sampled from 1 KHz to 100Hz.

10−2

10−1

100

101

102

−120

−100

−80

−60

−40

−20

0

20

f [Hz]

mag

nitu

de [d

B]

square_a2_f0.5.matsquare_a2_f1.matsquare_a2_f2.matsquare_a4_f2.mat

10−2

10−1

100

101

102

−200

−100

0

100

200

300

f [Hz]

phas

e [d

eg]

square_a2_f0.5.matsquare_a2_f1.matsquare_a2_f2.matsquare_a4_f2.mat

(b) Four discrete-time transfer functions estimated from the four sets of input/output data in(a), sampled at 1KHz. The transfer functions were obtained using the MATLAB R© command arx

with na “ 3, nb “ 4, and nk “ 0, which reflects an expectation of 3 poles in addition to theone at z “ 1 and no delay from u to y. A pole at z “ 1 was inserted manually into the transferfunction returned by arx and the output scaling was reversed back to the original units. Thelabels in the transfer functions refer to the titles of the four sets of input/output data in (a).

Figure 4.7. Attempt to estimate the discrete-time transfer function for the two-mass system in Figure 4.2, forcinga pole at z “ 1, with appropriate output scaling, and with the signals down-sampled to 100Hz.

Page 45: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

System Identification 39

1. Selecting a value for n too small will lead to mismatch between the measured data and themodel and the SSE will be large.

2. Selecting a value for n too large is called over-parameterization and it generally leads to R

being close to singular. To understand why, suppose we have a transfer function

Hpzq “ 1

z ´ 1,

but for estimation purposes we assumed that n “ 2 and therefore attempted to determineconstants αi , βi such that

Hpzq “ α2z2 ` α1z ` α0

z2 ` β1z ` β0.

If the model was perfect, it should be possible to match the data with any αi , βi such that

α2z2 ` α1z ` α0

z2 ` β1z ` β0“ z ´ p

pz ´ 1qpz ´ pq ô#

α2 “ 0, α1 “ 1, α0 “ ´p,

β1 “ ´1 ´ p, β0 “ p,(4.8)

where p can be any number. This means that the data is not sufficient to determine the valuesof the parameters α0, β0, β1, which translates into R being singular.

MATLAB R© Hint 18. When usingthe arx MATLAB R© command, sin-gularity of R can be inferred fromstandard deviations for the param-eters that are large when com-pared with the estimated param-eter values. . . p. 27

When there is noise, it will never be possible to perfectly explain the data and the smallestSSE will always be positive (either with n “ 1 or n “ 2). However, in general, differentvalues of p will result in different values for SSE . In this case, least-squares estimation willproduce the specific value of p that is better at “explaining the noise,” which is not physicallymeaningful.

When one is uncertain about which values to choose for m and n, the following procedure should beNote 24. When the number ofpoles n is chosen correctly, a num-ber of zeros m too large will gen-erally not lead to trouble so onemay as well chose the largest onethat is physically meaningful. If itis known that there is a delay ofat least d, one should make m “n´d [cf. equation (3.2)]. . . p. 24

followed:

1. Select for n the smallest possible integer that is physically meaningful (conceivably 0).

2. Do least-square estimation with m “ n.

(a) If the SSE is large and R is far from singular increase n and repeat the identification.

(b) If R is close to singular or the SSE did not decrease significantly, then n got too large,go back to the previous n and stop.

Note. Identifying a process trans-fer function with a pole-zero can-cellation, like in (4.8), will makecontrol extremely difficult sincefeedback will not be able to movethat “phantom” zero/pole. Thisis especially problematic if the“phantom” pole is unstable or veryslow.

One needs to exercise judgment in deciding when “the SSE is large” or when “R is far/close tosingular.” Physical knowledge about the model should play a major role in deciding model orders.Moreover, one should always be very concerned about identifying noise, as opposed to actuallyidentifying the process model.

Example 4.4 (Two-cart with spring (cont.)). Figure 4.8 shows results obtained for the input/outputdata set shown in the bottom-right plot of Figure 4.7(a). The procedure to estimate the discrete-time transfer functions was similar to that used to obtain the those in Figure 4.7(b), but we let theparameter na “ nb ´ 1 that defines the number of poles (excluding the integrator at z “ 1) rangefrom 1 to 12. The delay parameter nk was kept equal to 0.

As expected, the SSE error decreases as we increase na, but the standard deviation of thecoefficients generally increases as we increase na, and rapidly becomes unacceptably large. Theplot indicates that for na between 3 and 6 the parameter estimates exhibit relatively low variance.For larger values of na the decrease in SSE does not appear to be justify the increase in standarddeviation.

Page 46: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

40 João P. Hespanha

0 2 4 6 8 10 1210

−5

10−4

10−3

10−2

10−1

mea

n S

SE

per

sam

ple

poin

t

number of poles (excluding pole at z=1)

0 2 4 6 8 10 1210

−1

100

101

102

number of poles (excluding pole at z=1)

max

(std

dev

/est

imat

e)

(a) The y-axis of the top plot shows the average SSE error per sample and the y-axis of thebottom plot shows the highest (worst) ratio between a parameter standard deviation and itsvalue. Each point in the plots corresponds to the results obtained for a particular choice of themodel order. In particular, to obtain these two plots we varied from 1 to 12 the parameter na=nb

(shown in the x-axis) that defines the number of poles (excluding the integrator at z “ 1). Thedelay parameter nk was kept the same equal to 0.

10−2

10−1

100

101

102

−120

−100

−80

−60

−40

−20

0

f [Hz]

mag

nitu

de [d

B]

2345

10−2

10−1

100

101

102

−200

−100

0

100

200

300

f [Hz]

phas

e [d

eg]

2345

(b) Transfer functions corresponding to the identification experiments in (a). Each plot is labeledwith the corresponding number of poles (excluding the integrator at z “ 1).

Figure 4.8. Choice of model order. All results in this figure refer to the estimation of the discrete-time transferfunction for the two-mass system in Figure 4.2, using the set of input/output data shown in the bottom-right plotof Figure 4.7(a), forcing a pole at z “ 1, with appropriate output scaling, and with the signals down-sampledto 100Hz.

Page 47: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

System Identification 41

Key observation. While the results improved dramatically with respect to the original ones, thestandard deviations for the parameter estimates are still relatively high. We can see from Fig-ure 4.8(a) that even for na “ 4, at least one standard deviation is still above 20% of the value ofthe corresponding parameter. This means that the data used is still not sufficiently rich to achievea reliable estimate for the transfer function. 2

4.5 Combination of Multiple Experiments

As discussed in Section 4.1, the input used for system identification should be sufficiently rich tomake sure that the matrix R is nonsingular and also somewhat representative of the class of all

inputs that are likely to appear in the feedback loop. To achieve this, one could use a single verylong input signal upkq that contains a large number of frequencies, steps, chirp signals, etc. Inpractice, this is often difficult so an easier approach is to conduct multiple identification experiments,each with a different input signal uipkq. These experiments result in multiple sets of input/outputdata that can then be combined to identify a single ARX model.

MATLAB R© Hint 12. mergeallows one to combine datafor this type of multi-inputprocessing. . . p. 25

Suppose, for example, that one wants to identify the following ARX model with two poles andtwo zeros

Y pzqUpzq “ α2z

2 ` α1z ` α0

z2 ` β1z ` β0,

and that we want to accomplish this using on an input/output pair

`u1pkq, y1pkq

˘: k “ 1, 2, . . . , N1

(

of length N1 and another input/output pair

`u2pkq, y2pkq

˘: k “ 1, 2, . . . , N2

(

of length N2. One would construct

Φ “

»————————————–

y1p2q y1p1q u1p3q u1p2q u1p1qy1p3q y1p2q u1p4q u1p3q u1p2q

......

......

...y1pN1 ´ 1q y1pN1 ´ 2q u1pN1q u1pN1 ´ 1q u1pN1 ´ 2q

y2p2q y2p1q u2p3q u2p2q u2p1qy2p3q y2p2q u2p4q u2p3q u2p2q

......

......

...y2pN2 ´ 1q y2pN2 ´ 2q u2pN2q u2pN2 ´ 1q u2pN2 ´ 2q

fiffiffiffiffiffiffiffiffiffiffiffiffifl

, Y “

»————————————–

y1p3qy1p4q

...y1pN1qy2p3qy2p4q

...y2pN1q

fiffiffiffiffiffiffiffiffiffiffiffiffifl

and, according to Section 3.2, the least-squares estimate of

θ –“´β1 ´β0 αm α2 α1 α0

using all the available data is still given byMATLAB R© Hint 19. PHIzY com-

putes θ directly, from the matrixPHI“ Φ and the vector Y“ Y .

θ “ pΦ1Φq´1Φ1Y .

Example 4.5 (Two-cart with spring (cont.)). As noted before, we can see in Figure 4.8 that evenfor na “ 4, at least one standard deviation is still above 20% of the value of the correspondingparameter. This is likely caused by the fact that the all the results in this figure were obtained forthe input/output data set shown in the bottom-right plot of Figure 4.7(a). This input data will beexcellent to infer the response of the system to square waves of 2Hz, and possibly to other periodicinputs in this frequency range. However, this data set is relatively poor in providing information onthe system dynamics below and above this frequency.

Page 48: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

42 João P. Hespanha

Fix. By combining the data from the four sets of input/output data shown in Figure 4.7(a), weshould be able to decrease the uncertainty regarding the model parameters.

Figure 4.9 shows results obtained by combining all four sets of input/output data shown inFigure 4.7(a). Aside from this change, the results shown follow from the same procedure used toconstruct the plots in Figure 4.8.

Key Observation. As expected, the standard deviations for the parameter estimates decreased and,for na ď 4, all standard deviations are now below 15% of the values of the corresponding parameter.However, one still needs to combine more inputs to obtain a high-confidence model. In particular,the inputs considered provide relatively little data on the system dynamics above 2-4Hz since the2Hz square wave contains very little energy above its 2nd harmonic. One may also want to use alonger time horizon to get inputs with more energy at low frequencies.

Regarding the choice of the system order, we are obtaining fairly consistent Bode plots for 2-5poles (excluding the integrator at z “ 1), at least up to frequencies around 10Hz. If the systemis expected to operate below this frequency, then one should choose the simplest model, whichwould correspond to 2 poles (excluding the integrator at z “ 1). Otherwise richer input signals aredefinitely needed and will hopefully shed further light into the choice of the number of poles. 2

4.6 Closed-loop Identification

When the process is unstable, one cannot simply apply input probing signals to the open-loopsystems. In this case, a stabilizing controller C must be available to collect the identification data.Typically, this is a low performance controller that was designed using only a coarse process model.

One effective method commonly used to identify processes that cannot be probed in open-loopconsists of injecting an artificial disturbance d and estimating the closed-loop transfer function fromthis disturbance to the control input u and the process output y, as in Figure 4.10.

In this feedback configuration, the transfer functions from d to u and y are, respectively, givenby

Note 25. Why? Denoting by Uand D the Laplace transforms of uand d, respectively, we have thatU “ D ´ CPU , and thereforepI ` CPqU “ D, from which oneconcludes that U “ pI `CPq´1D.To obtain the transfer function toy, one simply needs to multiplythis by P . These formulas arevalid, even if the signals are vec-tors and the transfer functions arematrices.

Attention! There is a directfeedthrough term from d to u,which means that the transferfunction Tupsq will have no delayand therefore it will have thesame number of poles and zeros.

Tupsq “`I ` C psqPpsq

˘´1, Typsq “ Ppsq

`I ` C psqPpsq

˘´1.

Therefore, we can recover Ppsq from these two closed-loop transfer functions, by computing

Ppsq “ TypsqTupsq´1.

This formula can then be used to estimate the process transfer function from estimates of the twoclosed-loop transfer functions Typsq and Tupsq.

In closed-loop identification, if the controller is very good the disturbance will be mostly rejectedfrom the output and Typsq can become very small, leading to numerical errors and poor identification.For identification purposes a sluggish controller that does not do a good job at disturbance rejectionis desirable.

4.7 MATLAB R© Hints

MATLAB R© Hint 17 (resample). The command resample from the signal processing toolbox re-samples a signal at a different sampling rate and simultaneously performs lowpass filtering to removealiasing and noise. In particular,

bary=resample(y,M,L,F)

Page 49: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

System Identification 43

0 2 4 6 8 10 1210

−5

10−4

10−3

10−2

mea

n S

SE

per

sam

ple

poin

t

number of poles (excluding pole at z=1)

0 2 4 6 8 10 1210

−1

100

101

102

103

number of poles (excluding pole at z=1)

max

(std

dev

/est

imat

e)

(a) The y-axis of the top plot shows the average SSE error per sample and the y-axis of thebottom plot shows the highest (worst) ratio between a parameter standard deviation and itsvalue. Each point in the plots corresponds to the results obtained for a particular choice of themodel order. In particular, to obtain these two plots we varied from 1 to 12 the parameter na=nb

(shown in the x-axis) that defines the number of poles (excluding the integrator at z “ 1). Thedelay parameter nk was kept the same equal to 0.

10−2

10−1

100

101

102

−100

−80

−60

−40

−20

0

20

f [Hz]

mag

nitu

de [d

B]

2345

10−2

10−1

100

101

102

−200

−100

0

100

200

300

f [Hz]

phas

e [d

eg]

2345

(b) Transfer functions corresponding to the identification experiments in (a). Each plot is labeledwith the corresponding number of poles (excluding the integrator at z “ 1).

Figure 4.9. Choice of model order. All results in this figure refer to the estimation of the discrete-time transferfunction for the two-mass system in Figure 4.2, using all four sets of input/output data shown in Figure 4.7,forcing a pole at z “ 1, with appropriate output scaling, and with the signals down-sampled to 100Hz.

Page 50: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

44 João P. Hespanha

yu

d

´PpsqC psq

Figure 4.10. Closed-loop system

produces a signal bary with a sampling period that is L/M times that of y. Therefore, to reduce thesampling frequency one chooses L>M and the length of the signal ybar will be L/M times smallerthan that of y.

In computing each entry of bary, this function averages the values of F*L/M entries of y forwardsand backwards in time. In particular, selecting

bary=resample(y,1,L,1)

the signal bary will be a subsampled version of y with one sample of ybar for each L samples ofy and each sample of ybar will be computed using a weighted average of the 2L samples of y (Lforwards in time and another L backwards in time). 2

4.8 Exercises

4.1 (Input magnitude). A Simulink block that models a nonlinear spring-mass-damper system isprovided.

1. Use the Simulink block to generate the system’s response to step inputs with amplitude 0.25and 1.0 and no measurement noise.

2. For each set of data, use the least-squares method to estimate the systems transfer function.Try a few values for the degrees of the numerator and denominator polynomials m and n.Check the quality of the model by following the validation procedure outlines above.

Important: write MATLAB R© scripts to automate these procedures. These scripts should takeas inputs the simulation data upkq, ypkq, and the integers m, n.

3. Use the Simulink block to generate the system’s response to step inputs and measurementnoise with intensity 0.01.

For the best values of m and n determined above, plot the SSE vs. the step size. Whichstep-size leads to the best model? 2

4.2 (Model order). Use the data provided to identify the transfer function of the system. Use theprocedure outlined above to determine the order of the numerator and denominator polynomials. Plotthe largest and smallest singular value of R and the SSE as a function of n.Important: write MATLAB R© scripts to automate this procedure. These scripts should take as inputsthe simulation data upkq, ypkq, and the integers m, n. 2

4.3 (Sampling frequency). Consider a continuous-time system with transfer function

Ppsq “ 4π2

s2 ` πs ` 4π2.

1. Build a Simulink model for this system and collect input/output data for an input squarewave with frequency .25Hz and unit amplitude for two sampling frequencies Ts “ .25sec andTs “ .0005sec.

Page 51: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

System Identification 45

2. Identify the system’s transfer function without down-sampling.

3. Identify the system’s transfer function using the data collected with Ts “ .0005sec but down-sampled.

Important: write MATLAB R© scripts to automate this procedure. These scripts should take asinputs the simulation data upkq, ypkq, the integers m, n, and the down-sampling period L.

4. Briefly comment on the results. 2

Page 52: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

46 João P. Hespanha

Page 53: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

Chapter 5

Nonparametric Identification

Contents

5.1 Nonparametric Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475.2 Time-domain Identification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475.3 Frequency Response Identification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 495.4 MATLAB R© Hints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 515.5 To Probe Further . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 515.6 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52

5.1 Nonparametric Methods

Nonparametric identification attempts to directly determine the model of a system, without assuming

that its transfer function is rational and that we known the number of poles or zeros. The followingare typical problems in this class:

Problem 5.1 (Nonparametric frequency response identification). Determine the frequency response

HpejΩq over a range of frequencies Ω P rΩmin, Ωmaxs.or

Problem 5.2 (Nonparametric time response identification). Determine the impulse response hpkqfrom time k “ 0 to k “ N .

Problem 5.1 is useful for controller design based on loop-shaping or the Nyquist criterion, whereasProblem 5.2 is useful for controller design based on the Ziegler-Nichols rules to tune PID controllers[5]. For N large, one can also recover the transfer function from the impulse response by taking thez-transform:

MATLAB R© Hint 20. fft(h)computes the fast-Fourier-transform (FFT) of the signalhpkq, k P t1, 2, . . . , Nu, whichprovides the values of HpejΩqfor equally spaced frequenciesΩ “ 2πk

N , k P t0, 1, . . . , N ´ 1u.However, since we only care forvalues of Ω in the interval r0, πs,we should discard the second halfof fft’s output.

Hpzq “ Zrhpkqs “8ÿ

k“0

hpkqz´k «Nÿ

k“0

hpkqz´k ,

assuming that N is large enough so that hpkq « 0 for k ą N .

Throughout this chapter we will assume that the system is BIBO stable, i.e., that all poles of thetransfer function Hpzq have magnitude smaller than one or equivalently that hpkq converges to zeroexponentially fast.

A detailed treatment of this subject can be found, e.g., in [10, Chapter 7].

5.2 Time-domain Identification

We start by discussing a few methods used to solve the time response identification Problem 5.2.

47

Page 54: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

48 João P. Hespanha

5.2.1 Impulse Response Method

Note 26. The main weakness ofthe impulse-response method isthat impulses are rarely represen-tative of typical inputs that ap-pear in closed loop so, especiallyfor nonlinear systems, we estimatea regimen that may be far fromthe dynamics that will appear inclosed loop.

The impulse response of a system can be determines directly by starting with the system at rest andapplying an impulse at the input :

upkq “#

α k “ 0

0 k ­“ 0.

The output will be a (scaled) version of the impulse response, possibly corrupted by some measurementnoise npkq:

ypkq “ αhpkq ` npkq.Therefore

hpkq “ ypkqα

´ npkqα

Hopefully the noise term npkqα is small when compared to hpkq and one can use the followingestimate for the impulse response:

hpkq “ ypkqα

, k P t0, 1, . . . , Nu.

Attention! The choice of α is generally critical to obtain a good estimate for the impulse response:

(i) |α | should be large to make sure that npkqα is indeed negligible when compared to hpkq;Note 27. Note that the estimatehpkq differs from the true valuehpkq, precisely by:

hpkq “ hpkq ` npkqα

.

(ii) |α | should be small to make sure that the process does not leave the region where a linearmodel is valid and where it is safe to operate it open-loop.

As one increases α , a simple practical test to check if one is leaving the linear region of operationis to do identification both with some α ą 0 and ´α ă 0. In the linear region of operation, theidentified impulse-response does not change. See also the discussion in Section 4.1. 2

5.2.2 Step Response

Note 28. In general, steps aremore representative than pulsesin feedback loops so, in that re-spect, the step response is a bettermethod than the impulse response.

The impulse response of a system can also be determined by starting with the system at rest andapplying an step at the input :

upkq “#

α k ě 0

0 k ă 0.

The z-transform of the output will be given by

Y pzq “ HpzqUpzq ` Npzq “ Hpzq α

1 ´ z´1` Npzq,

where Npzq denotes the z-transform of measurement noise. Solving for Hpzq we obtain:

Hpzq “ Y pzq ´ z´1Y pzqα

´ Npzq ´ z´1Npzqα

Taking inverse z-transforms, we conclude that

hpkq “ ypkq ´ ypk ´ 1qα

´ npkq ´ npk ´ 1qα

.

Hopefully the noise term npkq´npk´1qα

is small when compared to hpkq, and we can use followingestimate for the impulse response:

hpkq “ ypkq ´ ypk ´ 1qα

, k P t0, 1, . . . , Nu.

Page 55: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

System Identification 49

Attention! The main weakness of the step-response method is that it can amplify noise because in

the worst case npkq´npk´1qα

can be twice as large as npkqα

(when npk ´ 1q “ ´npkq). Although thismay seem unlikely, it is not unlikely to have all the npkq independent and identically distributedwith zero mean and standard deviation σ . In this case,

Note 29. Why?. . . p. 51

StdDev”npkq

α

ı“ σ

α, StdDev

”npkq ´ npk ´ 1qα

ı“ 1.41 σ

α,

which means that the noise is amplified by approximately 41%. 2

5.2.3 Other Inputs

One can determine the impulse response of a system using any input and not just a pulse- or step-input. Take an arbitrary input upkq, with z-transform Upzq. The z-transform of the output will begiven by

Y pzq “ HpzqUpzq ` Npzq,

where Npzq denotes the z-transform of measurement noise. Solving for Hpzq we obtain:

Hpzq “ U´1pzq`Y pzq ´ Npzq

˘

Taking inverse z-transforms, we conclude thatNote 30. The inverse z-transformof the product of two z-transformsis equal to the convolution of theinverse z-transforms of the fac-tors. . . p. 49

hpkq “ Z´1rU´1pzqs ‹ Z

´1“Y pzq ´ Npzq

‰“ Z

´1rU´1pzqs ‹`ypkq ´ npkq

˘,

where the ‹ denotes the (discrete-time) convolution operation. Hopefully the noise term is small

MATLAB R© Hint 21. The identifi-cation toolbox command impulse

performs impulse response estima-tion for arbitrary inputs. . . p. 51

when compared to hpkq, and we can use following estimate for the impulse response:

hpkq “ Z´1rU´1pzqs ˚ ypkq, k P t0, 1, . . . , Nu.

Note 30 (Discrete-time convolution and z-transform). Given two discrete-time signals x1pkq, x2pkq,k P t0, 1, 2, . . . u, their (discrete-time) convolution is a third discrete-time signal defined by

px1 ‹ x2qpkq –

8ÿ

k“0

x1pkqx2pn ´ kq, @k P t0, 1, 2, . . . u.

It turns out that the z-transform of the convolution of two signals can be easily computed by takingthe product of the z-transforms of the original signals. Specifically,

Zrx1 ‹ x2s “ X1pzq X2pzq, (5.1)

where X1pzq and X2pzq denote the z-transforms of x1pkq and x2pkq, respectively.

Applying the inverse z-transform to both sides of (5.1), we also conclude that

Z´1“X1pzq X2pzq

‰“ x1 ‹ x2,

which shows that we can obtain the inverse z-transform of the product of two z-transforms by doingthe convolution of the inverse z-transforms of the factors. 2

5.3 Frequency Response Identification

We now consider a couple of methods used to solve the frequency response identification Problem 5.1.

Page 56: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

50 João P. Hespanha

5.3.1 Sine-wave Testing

Suppose that one applies an sinusoidal input of the form,Note 7. Discrete-time angularfrequencies Ω take values from0 to π. When operating with asample period Ts , to generatea discrete-time signal udpkqthat corresponds to the sampledversion of the continuous-timesignal ucptq “ A cospωtq,@t ě 0, we should selectΩ “ ωTs “ 2πfTs . . . p. 13

upkq “ α cospΩkq, @k P t1, 2, . . . , Nu. (5.2)

Since we are assuming that Hpzq is BIBO stable, the measured output is given by

ypkq “ α AΩ cos`Ωk ` φΩ

˘` εpkq ` npkq, (5.3)

where

1. AΩ – |HpejΩ| and φΩ – =HpejΩq are the magnitude and phase of the transfer function Hpzqat z “ ejΩ;

2. εpkq is a transient signal that converges to zero as fast as cγk , where γ is the magnitude ofthe pole of Hpzq with largest magnitude and c some constant; and

3. npkq corresponds to measurement noise.

Note 31. To minimize the errorscaused by noise, the amplitudeα should be large. However, itshould still be sufficiently small sothat the process does not leave thelinear regime.

When npkq is much smaller than αAΩ and for k sufficiently large so that εpkq is negligible, we have

ypkq « αAΩ cos`Ωk ` φΩ

˘.

This allows us to recover both AΩ – |HpejΩ| and φΩ – =HpejΩq from the magnitude and phaseof ypkq. Repeating this experiment for several inputs (5.3) with distinct frequencies Ω, one obtainsseveral points in the Bode plot of Hpzq and, eventually, one estimates the frequency response HpejΩqover the range of frequencies of interest.

5.3.2 Correlation Method

Especially when there is noise, it may be difficult to determine the amplitude and phase of ypkq byinspection. The correlation method aims at accomplishing this task.

Suppose that the input upkq in (5.2) was applied, resulting in the measured output ypkq givenby (5.3). In the correlation method we compute

KΩ –1

T

Tÿ

k“1

e´jΩkypkq “ 1

T

Tÿ

k“1

´cospΩkq ´ j sinpΩkq

¯ypkq.

Using the expression for ypkq in (5.3), we conclude after fairly straightforward algebraic manipulationsthat

Note 32. Why?. . . p. 52

KΩ “ α

2HpejΩq ` α

2TH˚pejΩqe´2jΩ´e´2jΩpT `1q

1 ´ e´2jΩ` 1

T

Tÿ

k“1

e´jΩk`εpkq ` npkq

˘.

As T Ñ 8, the second term converges to zero and the summation at the end converges to theNote 33. Since the process isbounded, εpkq converges to zeroand therefore it has no pure sinu-soids. However, a periodic noiseterm with frequency exactly equalto Ω would lead to trouble.

Note 34. Even though the termdue to εpkq does not lead to trou-ble as T Ñ 8, it is still a goodidea to start collecting data onlyafter the time at which ypkq ap-pears to have stabilized into apure sinusoid.

z-transform of εpkq ` npkq at the point z “ e´jΩ. We thus conclude that

KΩ Ñ α

2HpejΩq ` lim

T Ñ8

1

T

`Epe´jΩq ` Npe´jΩq

˘,

where Epzq and Npzq denote the z-transforms of epkq and npkq, respectively. As long as npkq andepkq do not contain pure sinusoidal terms of frequency Ω, the z-transforms are finite and thereforethe limit is equal to zero. This leads to the following estimate for HpejΩq

Note 35. KΩ is a complex numberso we get estimates for the ampli-tude and phase of HpejΩq.

HpejΩq “ 2

αKΩ,

which is valid for large T .

Page 57: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

System Identification 51

Attention! The main weaknesses of the frequency response methods are:

(i) To estimate HpejΩq at a single frequency, one still needs a long input (i.e., T large). In practice,this leads to a long experimentation period to obtain the Bode plot over a wide range offrequencies.

(ii) It requires that we apply very specific inputs (sinusoids) to the process. This may not be possible(or safe) in certain applications. Especially for processes that are open-loop unstable.

(iii) We do not get a parametric form of the transfer function; and, instead, we get the Bode plotdirectly. This prevent the use of control design methods that are not directly based on theprocess’ Bode plot.

Its key strengths are

(i) It is typically very robust with respect to measurement noise since it uses a large amount ofdata to estimate a single point in the Bode plot.

(ii) It requires very few assumptions on the transfer function, which may not even by rational. 2

5.4 MATLAB R© Hints

MATLAB R© Hint 21 (impulse). The command impulse from the identification toolbox performsimpulse response estimation from data collected with arbitrary inputs. To use this command onemust

1. Create a data object that encapsulates the input/output data using:

data=iddata(y,u),

where u and y are vectors with the input and output data.

2. Plot the estimated impulse response using:

impulse(dat),

or compute the response using

model=impulse(data),

where m is a MATLAB R© object with an impulse-response model. The impulse response is givenby model.b. 2

5.5 To Probe Further

Note 29 (Noise in step-response method). When npkq and npk ´ 1q are independent, we have

Varrnpkq ´ npk ´ 1qs “ Varrnpkqs ` Varrnpk ´ 1qs.

Therefore

StdDev”npkq ´ npk ´ 1q

α

ı“c

Var”npkq ´ npk ´ 1q

α

ı

“c

Varrnpkqs ` Varrnpk ´ 1qsα2

When, both variables have the same standard deviation σ , we obtain

StdDev”npkq ´ npk ´ 1q

α

ı“

c2σ 2

α2“

?2 σ

α. 2

Page 58: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

52 João P. Hespanha

Note 32 (Correlation method). In the correlation method one computes

KΩ –1

T

Tÿ

k“1

e´jΩkypkq “ 1

T

Tÿ

k“1

`cospΩkq ´ j sinpΩkq

˘ypkq

Using the expression for ypkq in (5.3), we conclude that

KΩ “ α

TAΩ

Tÿ

k“1

´cospΩkq cospΩk ` φΩq ´ j sinpΩkq cospΩk ` φΩq

¯` 1

T

Tÿ

k“1

e´jΩk`εpkq ` npkq

˘.

Applying the trigonometric formulas cos a cos b “ 12 pcospa ´ bq ` cospa ` bqq and sin a cos b “

12 psinpa ´ bq ` sinpa ` bqq, we further conclude that

KΩ “ αAΩ

2T

Tÿ

k“1

´cos φΩ ` cos

`2Ωk ` φΩ

˘` j sin φΩ ´ j sin

`2Ωk ` φΩ

˘¯` 1

T

Tÿ

k“1

ejΩk`εpkq ` npkq

˘

“ αAΩ

2T

Tÿ

k“1

ejφΩ ` αAΩ

2T

Tÿ

k“1

e´2jΩk´jφΩ ` 1

T

Tÿ

k“1

e´jΩk`εpkq ` npkq

˘

“ α

2HpejΩq ` α

2TH˚pejΩq

Tÿ

k“1

e´2jΩk ` 1

T

Tÿ

k“1

e´jΩk`εpkq ` npkq

˘,

where we used the fact that AΩejφΩ is equal to the value HpejΩq of the transfer function at z “ ejΩ

and AΩe´jφΩ is equal to its complex conjugate H˚pejΩq. By noticing that the second term is thesummation of a geometric series, we can simplify this expression to

Note 36. Recall that the sum of ageometric series is given by

Tÿ

k“1

rk “ r ´ rT `1

1 ´ r

.

KΩ “ α

2HpejΩq ` α

2TH˚pejΩqe´2jΩ´e´2jΩpT `1q

1 ´ e´2jΩ` 1

T

Tÿ

k“1

e´jΩk`εpkq ` npkq

˘2

5.6 Exercises

5.1 (Step response). A Simulink block that models a pendulum with viscous friction is provided.

1. Use the Simulink block (without noise) to estimate the system’s impulse response hpkq usingboth the impulse and step response methods.

What is the largest value α of the input magnitude for which the system still remains withinthe approximately linear region of operation?

Hint: to make sure that the estimate is good you can compare the impulses response fromsteps and impulses.

2. Turn on the noise in the Simulink block and repeat the identification procedure above for arange of values for α . For both methods, plot the error

řk hαpkq ´ hpkq vs. α , where hαpkq

denotes the estimate obtained for an input with magnitude α . What is your conclusion?

Take the estimate hpkq determined in 1 for the noise-free case as the ground truth hpkq. 2

5.2 (Correlation method). Modify the Simulink block provided for Exercise 5.1 to accept a sinusoidalinput.

1. Estimate the system’s frequency response HpejΩq at a representative set of (log-spaced)frequencies Ωi using the correlation method.

Select an input amplitude α for which the system remains within the approximately linearregion of operation.

Page 59: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

System Identification 53

2. Turn on the noise in the Simulink block and repeat the identification procedure above for a

range of values for α . Plot the errorř

i HαpejΩi q ´ HpejΩi q vs. α , where HαpejΩi q denotesthe estimate obtained for an input with magnitude α . What is your conclusion?

Take the estimate HpejΩq determined in 1 for the noise-free case as the ground truth HpejΩq.

3. Compare your best frequency response estimate HpejΩq, with the frequency responses thatyou would obtain by taking the Fourier transform of the best impulse response hpkq that youobtained in Exercise 5.1.

Hint: Use the MATLAB R© command fft to compute the Fourier transform. This command givesyou HpejΩq from Ω “ 0 to Ω “ 2π so you should discard the second half of the Fouriertransform (corresponding to Ω ą π). 2

Page 60: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

54 João P. Hespanha

Page 61: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

Part II

Robust Control

55

Page 62: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and
Page 63: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

Introduction to Robust Control

For controller design purposes it is convenient to imagine that we know an accurate model for theprocess, e.g., its transfer function. In practice, this is hardly ever the case:

1. When process models are derived from first principles, they always exhibit constants that canonly be determined up to some error.

E.g., the precise values of masses, moments of inertia, and friction coefficients in models derivedfrom Newton’s laws; or resistances, capacitances, and gains, in electrical circuits.

2. When one identifies a model experimentally, noise and disturbances generally lead to differentresults as the identification experiment is repeated multiple times. Which experiment gave thetrue model? The short answer is none, all models obtained have some error.

3. Processes change due to wear and tear so even if a process was perfectly identified beforestarting operation, its model will soon exhibit some mismatch with respect to the real process.

The goal of this chapter is to learn how to take process model uncertainty into account, whiledesigning a feedback controller.

Pre-requisites

1. Laplace transform, continuous-time transfer functions, frequency responses, and stability.

2. Classical continuous-time feedback control design using loop-shaping.

3. Knowledge of MATLAB/Simulink.

Further reading A more extensive coverage of robust control can be found, e.g., in [4].

57

Page 64: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

58 João P. Hespanha

Page 65: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

Chapter 6

Robust stability

Contents

6.1 Model Uncertainty . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 596.2 Nyquist Stability Criterion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 626.3 Small Gain Condition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 636.4 MATLAB R© Hints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 656.5 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66

6.1 Model Uncertainty

Suppose we want to control the spring-mass-damper system in Figure 6.1, which has the following

ym

k

u

bMeasuring the mass’ vertical position y withrespect to the rest position of the spring, weobtain from Newton’s law:

m:y “ ´b 9y ´ ky ` u

Figure 6.1. Spring-mass-damper system.

transfer function from the applied force u to the spring position y

Ppsq “ 1

ms2 ` bs ` k. (6.1)

Typically, the mass m, the friction coefficient b, and the spring constant k would be identifiedexperimentally (or taken from some specifications sheet) leading to confidence intervals for theseparameters and not just a single value:

m P rm0 ´ δ1, m0 ` δ1s, b P rb0 ´ δ2, b0 ` δ2s, k P rk0 ´ δ3, k0 ` δ3s.

The values with subscript 0 are called the nominal values for the parameters and the δi are calledthe maximum deviations from the nominal value.

In practice, this means that there are many admissible transfer functions for the process—onefor each possible combination of m, b, and k in the given intervals. Figure 6.2 shows the Bode plot

MATLAB R© Hint 22. bode(sys)draws the Bode plot of the systemsys. . . p. 13

of (6.1) for different values of the parameters m, b, and k . The idea behind robust control is to designa single controllers that achieves acceptable performance (or at least stability) for every admissibleprocess transfer function.

59

Page 66: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

60 João P. Hespanha

−60

−50

−40

−30

−20

−10

0

10

20

Mag

nitu

de (

dB)

10−1

100

101

−180

−135

−90

−45

0

Pha

se (

deg)

Bode Diagram

Frequency (rad/sec)

Figure 6.2. Bode plot of Ppsq “ 1ms2`bs`k

, for different values of m P r.9, 1.1s, b P r.1, .2s, and k P r2, 3s. Notehow the different values of the parameters lead to different values for the resonance frequency. One can seein the phase plot that it may be dangerous to have the cross-over frequency near the “uncertain” resonancefrequency since the phase margin may very a lot depending on the system parameters. In particular, one processtransfer function may lead to a large phase margin, whereas another one to an unstable closed-loop system.

6.1.1 Additive Uncertainty

In robust control one starts by characterizing the uncertainty in terms of the process’ frequencyresponse. To this effect on selects a nominal process transfer function P0psq and, for each admissibleprocess transfer function Ppsq, one defines:

∆apsq – Ppsq ´ P0psq, (6.2)

which measures how much Ppsq deviates from P0psq. This allows us to express any admissibletransfer function Ppsq as in Figure 6.3. Motivated by the diagram in Figure 6.3, ∆apsq is called anadditive uncertainty block. P0psq should correspond to the “most likely” transfer function, so that

+

+

yu

∆apsq

P0psq

Ppsq∆apsq – Ppsq ´ P0psq

õPpsq “ P0psq ` ∆apsq

Figure 6.3. Additive uncertainty

the additive uncertainty block is as small as possible. In the example above, one would typicallychoose the transfer function corresponding to the nominal parameter values:

P0psq “ 1

m0s2 ` b0s ` k0.

To obtain a characterization of the uncertainty purely in the frequency domain, one needs to specifyhow large ∆apjωq may be for each frequency ω. This is done by determining a function ℓapωqsufficiently large so that for every admissible process transfer function Ppsq we have

|∆apjωq| “ |Ppjωq ´ P0pjωq| ď ℓapωq, @ω.

Page 67: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

Robust Control 61

When one has available all the admissible Ppsq (or a representative set of them—such as in Fig-ure 6.2), one can determine ℓapωq by simply plotting |Ppjωq ´ P0pjωq| vs. ω for all the Ppsq andchoosing for ℓapωq a function larger than all the plots. Since in general it is not feasible to plot all

|Ppjωq ´ P0pjωq|, one should provide some “safety-cushion” when selecting ℓapωq. Figure 6.4 showsℓapωq for the Bode plots in Figure 6.2.

10−1

100

101

−100

−80

−60

−40

−20

0

20

Magnitude (dB)

Freq

uenc

y (rad

/sec)

Figure 6.4. Additive uncertainty bounds for the process Bode plots in Figure 6.2 with P0psq –1

m0s2`b0s`k0,

m0 “ 1, b0 “ 1.5, k0 “ 2.5. The solid lines represent possible plots for |Ppjωq ´ P0pjωq| and the dashed onerepresents the uncertainty bound ℓapωq. Note the large uncertainty bound near the resonance frequency. Weshall show shortly how to design a controller that stabilizes all processes for which the additive uncertaintyfalls below the dashed line.

6.1.2 Multiplicative Uncertainty

The additive uncertainty in (6.2) measures the difference between Ppsq and P0psq in absolute termsand may seem misleadingly large when both Ppsq and P0psq are large—e.g., at low frequencieswhen the process has a pole at the origin. To overcome this difficulty one often defines instead

∆mpsq –Ppsq ´ P0psq

P0psq , (6.3)

which measures how much Ppsq deviates from P0psq, relative to the size of Popsq. We can now expressany admissible transfer function Ppsq as in Figure 6.5, which motivates calling ∆mpsq a multiplicative

uncertainty block. To characterize a multiplicative uncertainty one determines a function ℓmpωq

+

+

yu

∆mpsq

P0psq

Ppsq∆mpsq –

Ppsq ´ P0psqP0psq

õPpsq “ P0psq

`1 ` ∆mpsq

˘

Figure 6.5. Multiplicative uncertainty

sufficiently large so that for every admissible process transfer function Ppsq we have

|∆mpjωq| “ |Ppsq ´ P0psq||P0psq| ď ℓmpωq, @ω.

One can determine ℓmpωq by plotting |Ppsq´P0psq||P0psq| vs. ω for all admissible Ppsq (or a representative

set of them) and choosing ℓmpωq to be larger than all the plots. Figure 6.6 shows ℓmpωq for the Bodeplots in Figure 6.2.

Page 68: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

62 João P. Hespanha

10−1

100

101

−100

−80

−60

−40

−20

0

20

Magnitude (dB)

Freq

uenc

y (rad

/sec)

Figure 6.6. Multiplicative uncertainty bounds for the process Bode plots in Figure 6.2 with P0psq –1

m0s2`b0s`k0,

m0 “ 1, b0 “ 1.5, k0 “ 2.5. The solid lines represent possible plots for |Ppjωq´P0pjωq||P0pjωq|

and the dashed one

represents the uncertainty bound ℓmpωq. Note the large uncertainty bound near the resonance frequency. Weshall show shortly how to design a controller that stabilizes all processes for which the multiplicative uncertaintyfalls below the dashed line.

6.2 Nyquist Stability Criterion

The first question we address is: Given a specific feedback controller C psq, how can we verify that itstabilizes every admissible process Ppsq. When the admissible processes are described in terms of amultiplicative uncertainty block, this amounts to verifying that the closed-loop system in Figure 6.7 isstable for every ∆mpjωq with norm smaller than ℓmpωq. This can be done using the Nyquist stability

+

+

+

yur

∆mpsq

P0psqC psq

|∆mpjωq| ď ℓmpωq, @ω

Figure 6.7. Unity feedback configuration with multiplicative uncertainty

criterion, which we review next.

The Nyquist criterion is used to investigate the stability of the negative feedback connection inNote. Figure 6.8 can representthe closed-loop system in Fig-ure 6.7 if we choose Gpsq –

`1 `

∆mpsq˘PpsqCpsq.

Figure 6.8. We briefly summarize it here. The textbook [5, Section 6.3] provides a more detailed

+

yrGpsq

Figure 6.8. Negative feedback

description of it with several examples.

6.2.1 The Nyquist Plot

The first step consists of drawing the Nyquist plot, which is done by evaluating Gpjωq from ω “ ´8MATLAB R© Hint 23.nyquist(sys) draws theNyquist plot of the systemsys. . . p. 65

to ω “ `8 and plotting it in the complex plane. This leads to a closed-curve that is alwayssymmetric with respect to the real axis. This curve should be annotated with arrows indicating thedirection corresponding to increasing ω.

Page 69: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

Robust Control 63

6.2.2 The Nyquist Criterion

Count the number #ENC of clockwise encirclements by the Nyquist plot of the point ´1. To do this,we draw a ray from ´1 to 8 in any direction and add one each time the Nyquist plot crosses theray in the clockwise direction (with respect to the origin of the ray) and subtract one each time itcrosses the ray in the counter-clockwise direction. The final count gives #ENC.

Nyquist Stability Criterion. The total number of unstable (i.e., in the right-hand-side plane) closed-

loop poles (#CUP) is given by

#CUP “ #ENC ` #OUP,

where #OUP denotes the number of unstable (open-loop) poles of Gpsq. To have a stable closed-loop

one thus needs

#ENC “ ´#OUP. 2

Attention! Any poles of Gpsq on the imaginary axis should be moved slightly to the left of the axisto avoid divisions by zero. E.g.,

Gpsq “ s ` 1

sps ´ 3q ÝÑ Gεpsq « s ` 1

ps ` εqps ´ 3qGpsq “ s

s2 ` 4“ s

ps ` 2jqps ´ 2jq ÝÑ Gεpsq « s

ps ` ε ` 2jqps ` ε ´ 2jq “ s

ps ` εq2 ` 4,

for a small ε ą 0. The criterion should then be applied to the “perturbed” transfer function Gεpsq.If we conclude that the closed-loop is stable for Gεpsq with very small ε, then the closed-loop withGpsq will also be stable and vice-versa. 2

Figure 6.9 shows the Nyquist plot of

G0psq “ C psqP0psq, (6.4)

for the nominal process model

P0psq –1

m0s2 ` b0s ` k0, m0 “ 1, b0 “ 1.5, k0 “ 2.5, (6.5)

(used in Figures 6.4 and 6.6) and a PID controller

C psq –10

s` 15 ` 5s, (6.6)

To obtain this plot, we moved the single controller pole on the imaginary axis to the left-hand sideof the complex plane. Since this led to an open loop gain with no unstable poles (#OUP “ 0) andthere are no encirclements of ´1 (#ENC “ 0), we conclude that the closed-loop system is stable.This means that the given PID controller C psq stabilizes, at least, the nominal process P0psq. Itremains to check if it also stabilizes every admissible process model with multiplicative uncertainty.

6.3 Small Gain Condition

Consider the closed-loop system in Figure 6.7 and suppose that we are given a controller C psq thatstabilizes the nominal process P0psq, i.e., the closed-loop is stable when ∆mpsq “ 0. Our goal is tofind out if the closed-loop remains stable for every ∆mpjωq with norm smaller than ℓmpωq.

Since C psq stabilizes P0psq, we know that the Nyquist plot of the nominal (open-loop) transferfunction

G0psq “ C psqP0psq,

Page 70: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

64 João P. Hespanha

−50 0 50 100 150 200 250 300 350 400−200

−150

−100

−50

0

50

100

150

200Nyquist Diagram

Real Axis

Imag

inar

y A

xis

−20 −15 −10 −5 0 5 10 15 20 25 30−20

−15

−10

−5

0

5

10

15

20Nyquist plot for 1st controller

Real Axis

Imag

inar

y A

xis

Figure 6.9. Nyquist plot for the (open-loop) transfer function in (6.4). The right figure shows a zoomed view ofthe origin. To avoid a pole over the imaginary axis, in these plots we moved the pole of the controller from 0 to´.01.

has the “right” number of encirclements (#ENC “ ´#OUP, where #OUP is the number of unstablepoles of G0psq. To check is the closed-loop is stable from some admissible process transfer function

Ppsq “ P0psq`1 ` ∆mpsq

˘,

we need to draw the Nyquist plot ofNote. We are assuming that Gpsqand G0psq have the same num-ber of unstable poles #OUP andtherefore stability is achieved forthe same number of encirclements#ENC “ ´#OUP. In practicethis means that the uncertaintyshould not change the stability ofany pole.

Gpsq “ C psqPpsq “ C psqP0psq`1 ` ∆mpsq

˘“ G0psq ` G0psq∆mpsq

and verify that we still get the same number of encirclements.

GpjωqG0pjωq

|Gpjωq ´ G0pjωq|

|1 ` G0pjωq|

´1

Figure 6.10. Nyquist plot derivation of the small-gain conditions

The Nyquist plots of Gpsq and G0psq differ by

|Gpjωq ´ G0pjωq| “ |G0pjωq∆mpjωq| ď |G0pjωq| ℓmpωq,

A simple way to make sure that Gpjωq and G0pjωq have the same number of encirclements is to askthat the maximum difference between the two be smaller than the distance from G0pjωq to the point´1, i.e.,

|1 ` G0pjωq| ą |G0pjωq| ℓmpωq ô |G0pjωq||1 ` G0pjωq| ă 1

ℓmpωq @ω.

This leads to the so called small-gain condition:

Page 71: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

Robust Control 65

Small-gain Condition. The closed-loop system in Figure 6.7 is stable for every ∆mpjωq with norm Note. A mnemonic to remember(6.7) is that the transfer func-tion whose norm needs to besmall is precisely the transferfunction “seen” by the ∆m blockin Figure 6.7. This mnemonicalso “works” for additive uncer-tainty. . . p. 67

MATLAB R© Hint 24. To check if(6.7) holds for a specific sys-tem, draw 20 log10

1ℓmpωq “

´20 log10 ℓmpωq on top of themagnitude Bode plot of thecomplementary sensitivity functionand see if the latter always liesbelow the former.

smaller than ℓmpωq, provided that

ˇˇ C pjωqP0pjωq1 ` C pjωqP0pjωq

ˇˇ ă 1

ℓmpωq , @ω. (6.7)

The transfer function on the left-hand-side of (6.7) is precisely the complementary sensitivity function:

T0psq – 1 ´ S0psq, S0psq –1

1 ` C psqP0psqfor the nominal process. So (6.7) can be interpreted as requiring the norm of the nominal complemen-tary sensitivity function to be smaller than 1ℓmpωq, @ω. For this reason (6.7) is called a small-gain

condition.

Figure 6.11 shows the Bode plot of the complementary sensitivity function for the nominal pro-cess in (6.5) and the PID controller in (6.6). In the same plot we can see the 20 log10

1ℓmpωq “

´20 log10 ℓmpωq, for the ℓmpωq in Figure 6.6. Since the magnitude plot of T0pjωq is not always belowthat of 1

ℓmpωq , we conclude that the system may be unstable for some admissible processes. However,

if we redesign our controller to consist of an integrator with two lags

C psq “ .005ps ` 5q2

sps ` .5q2, (6.8)

the magnitude plot of T0pjωq is now always below that of 1ℓmpωq and we conclude that we have

stability for every admissible process. In this case, the price to pay was a low bandwidth. Thisexample illustrates a common problem in the control of systems with uncertainty: it is not possible Note. Recall that the complemen-

tary sensitivity function is alsothe closed-loop transfer functionfor the reference r to the outputy. Therefore good tracking re-quires this function to be close to1, whereas to reject large uncer-tainty we need this function to bemuch smaller than 1.

to get good reference tracking over ranges of frequencies for which there is large uncertainty.

10−1

100

101

102

−90

−45

0

Pha

se (

deg)

−30

−25

−20

−15

−10

−5

0

5

10

Mag

nitu

de (

dB)

Bode Diagram

Frequency (rad/sec) .

Figure 6.11. Verification of the small gain condition for the nominal process (6.5), the multiplicative uncertaintyin Figure 6.6, and the PID controller (6.6). The solid line corresponds to the Bode plot of the complementarysensitivity function T0psq and the dashed line to 1

ℓmpωq(both in dB).

6.4 MATLAB R© Hints

MATLAB R© Hint 23 (nyquist). The command nyquist(sys) draws the Nyquist plot of the systemsys. To specify the system you can use any of the commands in Matlab hint 22.

Page 72: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

66 João P. Hespanha

10−2

10−1

100

101

102

103

−450

−360

−270

−180

−90

0

Pha

se (

deg)

−60

−40

−20

0

20

40

Mag

nitu

de (

dB)

Bode Diagram

Frequency (rad/sec) .

Figure 6.12. Verification of the small gain condition for the nominal process (6.5), the multiplicative uncertaintyin Figure 6.6, and the integrator with 2 lags controller (6.8). The solid line corresponds to the Bode plot of thecomplementary sensitivity function T0psq and the dashed line to 1

ℓmpωq(both in dBs).

Especially when there are poles very close to the imaginary axis (e.g., because they were actuallyon the axis and you moved them slightly to the left), the automatic scale may not be very goodbecause it may be hard to distinguish the point ´1 from the origin. In this case, you can use thenzoom features of MATLAB to see what is going on near ´1: Try clicking on the magnifying glassand selecting a region of interest; or try left-clicking on the mouse and selecting “zoom on (-1,0)”(without the magnifying glass selected.) 2

6.5 Exercises

6.1 (Unknown parameters). Suppose one want to control the orientation of a satellite with respectto its orbital plane by applying a thruster’s generated torque. The system’s transfer function is giveby

Ppsq –10pbs ` kq

s2ps2 ` 11pbs ` kqq ,

where the values of the parameters b and k are not exactly known, but it is known that

.09 ď k ď .4 .006 ď b ď .03.

Find a nominal model and compute the corresponding additive and multiplicative uncertainty bounds. 2

6.2 (Noisy identification). The Simulink block provided corresponds to a discrete-time system withtransfer function

Hpzq “ α1z ` α0

z2 ` β1z ` β0.

1. Use least-squares to estimate the 4 coefficients of the transfer function. Repeat the identifi-cation experiment 25 times to obtain 25 estimates of the system’s transfer functions.

2. Convert the discrete-time transfer functions so obtained to continuous-time using the Tustintransformation.

Hint: Use the MATLAB command d2c.

Page 73: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

Robust Control 67

3. Select a nominal model and compute the corresponding additive and multiplicative uncertaintybounds. 2

6.3 (Small gain). For the nominal process model and multiplicative uncertainty that you obtained inExercise 6.2, use the small gain condition to verify if the following controllers achieve stability forall admissible process models:

C1psq “ .3 C2psq “ 2

s ` .1C3psq “ 20

s ´ 30C4psq “ 5ps ` 1q

ps ` 2qps ` 3q C5psq “ 2ps ` 1qps ` .3q2

Justify your answers with appropriate Bode plots. 2

6.4 (Robustness vs. performance). Justify the statement: “It is not possible to get good referencetracking over ranges of frequencies for which there is large uncertainty.” 2

6.5 (Additive uncertainty). Derive a small-gain condition similar to (6.7) for additive uncertainty.Check if the mnemonic in Sidebar 6.3 still applies.

Hint: With additive uncertainty, the open-loop gain is given by

Gpsq “ C psqPpsq “ C psq`P0psq ` ∆apsq

˘“ G0psq ` C psq∆apsq,

which differs from G0psq by C psq∆apsq. 2

Page 74: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

68 João P. Hespanha

Page 75: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

Chapter 7

Control design by loop shaping

Contents

7.1 The Loop-shaping Design Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 697.2 Open-loop vs. closed-loop specifications . . . . . . . . . . . . . . . . . . . . . . . . . 697.3 Open-loop Gain Shaping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 737.4 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74

7.1 The Loop-shaping Design Method

The goal of this chapter is to briefly review the loop-shaping control design method for SISO systems. Note. The loop-shaping designmethod is covered extensively, e.g.,in [5].

The basic idea behind loop shaping is to convert the desired specifications on the closed-loop system

yur

d

n

e

´

`

`

`PpsqC psq

Figure 7.1. Closed-loop system

in Figure 7.1 into constraints on the open-loop gain

Lpsq – C psqP0psq.

The controller C psq is then designed so that the open-loop gain Lpsq satisfies these constraints.The shaping of Lpsq can be done using the classical methods briefly mentioned in Section 7.3 andexplained in much greater detail in [5, Chapter 6.7]. However, it can also be done using LQR statefeedback, as discussed in Section 9.5, or using LQG/LQR output feedback controllers, as we shallsee in Section 10.6.

7.2 Open-loop vs. closed-loop specifications

We start by discussing how several closed-loop specifications can be converted into constraints onthe open-loop gain Lpsq.

69

Page 76: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

70 João P. Hespanha

Stability. Assuming that the open-loop gain has no unstable poles, the stability of the closed-loopsystem is guaranteed as long as the phase of the open-loop gain is above ´180˝ at the cross-overfrequency ωc , i.e., at the frequency for whichNotation. The distance between

the phase of Lpjωcq and ´180˝

is called the phase margin. SeeFigure 7.2.

|Lpjωcq| “ 1.

´1

PM

Lpjωq

Im

Re

Figure 7.2. Phase margin (PM).

Overshoot. Larger phase margins generally correspond to a smaller overshoot for the step responseof the closed-loop system. The following rules of thumb work well when the open-loop gain Lpsq hasa pole at the origin, an additional real pole, and no zeros:Note. Additional zeros and poles

at frequencies significantly abovethe cross over generally have lit-tle effect and can be ignored.However, additional dynamics be-low or around the cross-over fre-quency typically affect the over-shoot; and make determining theneeded phase margin to achieve adesired overshoot a trial and errorprocess.

Lpsq “ k

sps ` pq , p ą 0,

The following rules of thumb are useful to determine the value of the phase margin needed to obtainthe desired overshoot:

Phase margin overshoot65˝ ď 5%60˝ ď 10%45˝ ď 15%

Reference tracking. Suppose that one wants the tracking error to be at least kT ! 1 times smallerthan the reference, over the range of frequencies r0, ωT s. In the frequency domain, this can beNote. Typically one wants to track

low frequency references, whichjustifies the requirement for equa-tion (7.1) to hold in an interval ofthe form r0, ωT s.

expressed by

|Epjωq||Rpjωq| ď kT , @ω P r0, ωT s, (7.1)

where Epsq and Rpsq denote the Laplace transforms of the tracking error e – r ´ y and thereference signal r , respectively, in the absence of noise and disturbances. For the closed-loopsystem in Figure 7.1,

Epsq “ 1

1 ` LpsqRpsq.

Therefore (7.1) is equivalent to

1

|1 ` Lpjωq| ď kT , @ω P r0, ωT s ô |1 ` Lpjωq| ě 1

kT, @ω P r0, ωT s. (7.2)

This condition is guaranteed to hold by requiring thatNote 37. Why? . . . p. 70

|Lpjωq| ě 1

kT` 1, @ω P r0, ωT s. (7.3)

Note 37 (Condition (7.3)). For (7.2) to hold, we need the distance from Lpjωq to the point ´1 toalways exceed 1kT . As one can see in Figure 7.3, this always hold if Lpjωq remains outside a circleof radius 1 ` 1kT . 2

Page 77: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

Robust Control 71

´11kT

1kT

` 1

Im

Re

Figure 7.3. Justification for why (7.3) guarantees that (7.2) holds.

Disturbance rejection. Suppose that one wants input disturbances to appear in the output atten-uated at least kD ! 1 times, over the range of frequencies rωD1

, ωD2s. In the frequency domain, this Note. Typically one wants to re-

ject low-frequency disturbancesand therefore ωD1

and ωD2in (7.4)

generally take low values.

can be expressed by

|Y pjωq||Dpjωq| ď kD , @ω P rωD1

, ωD2s, (7.4)

where Y psq and Dpsq denote the Laplace transforms of the output y and the input disturbance d,respectively, in the absence of reference and measurement noise. For the closed-loop system inFigure 7.1,

Y psq “ P0psq1 ` LpsqDpsq,

and therefore (7.4) is equivalent to

|P0pjωq||1 ` Lpjωq| ď kD , @ω P rωD1

, ωD2s ô |1 ` Lpjωq| ě |P0pjωq|

kD, @ω P rωD1

, ωD2s.

This condition is guaranteed to hold as long as one requires that

|Lpjωq| ě |P0pjωq|kD

` 1, @ω P rωD1, ωD2

s. (7.5)

Noise rejection. Suppose that one wants measurement noise to appear in the output attenuatedat least kN ! 1 times, over the range of frequencies rωN , 8q. In the frequency domain, this can be Note. Typically one needs to re-

ject high frequencies noise, whichjustifies the requirement for equa-tion (7.6) to hold in an interval ofthe form rωN , 8q.

expressed by

|Y pjωq||Npjωq| ď kN , @ω P rωN , 8q, (7.6)

where Y psq and Npsq denote the Laplace transforms of the output y and the measurement noise n,respectively, in the absence of reference and disturbances. For the closed-loop system in Figure 7.1,

Y psq “ ´ Lpsq1 ` LpsqNpsq, (7.7)

and therefore (7.6) is equivalent to

|Lpjωq||1 ` Lpjωq| ď kN , @ω P rωN , 8q ô

ˇˇ1 ` 1

Lpjωqˇˇ ě 1

kN, @ω P rωN , 8q.

Page 78: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

72 João P. Hespanha

This condition is guaranteed to hold as long as one requires that

ˇˇ 1

Lpjωqˇˇ ě 1

kN` 1, @ω P rωN , 8q ô |Lpjωq| ď kN

1 ` kN, @ω P rωN , 8q. (7.8)

Robustness with respect to multiplicative uncertainty Suppose that one wants the closed-loop toremain stable for every multiplicative uncertainty ∆mpjωq with norm smaller than ℓmpωq. This canbe expressed by

|Lpjωq||1 ` Lpjωq| ď 1

ℓmpωq , @ω, (7.9)

which is equivalent toNote. While this condition is sim-ilar to the one appearing in (7.7),we now need it to hold for ev-ery frequency and we no longerhave the “luxury” of simply requir-ing |Lpjωq| to be small for everyfrequency.

ˇˇ1 ` 1

Lpjωqˇˇ ě ℓmpωq, @ω. (7.10)

We have two options to make sure that (7.10) hold:

1. As in the discussion for noise rejection, we can require |Lpjωq| to be small. In particular,reasoning as before we may require that

ˇˇ 1

Lpjωqˇˇ ě ℓmpωq ` 1, ô |Lpjωq| ď 1

1 ` ℓmpωq (7.11)

This condition will hold for frequencies for which we can make |Lpjωq| small, typically highfrequencies.

2. Alternatively, (7.10) may hold even when |Lpjωq| large, provided that ℓmpωq is small. Inparticular, since

ˇˇ1 ` 1

Lpjωqˇˇ ě 1 ´

ˇˇ 1

Lpjωqˇˇ,

the condition (7.10) holds, provided that we require that

1 ´ˇˇ 1

Lpjωqˇˇ ě ℓmpωq ô |Lpjωq| ě 1

1 ´ ℓmpωq (7.12)

This condition will hold for frequencies for which |Lpjωq| is large, typically low frequencies.

From the two conditions (7.11)–(7.12), one generally needs to be mostly concerned about (7.11). Thisis because when ℓmpωq is small, (7.10) will generally hold. However, when ℓmpωq is large for (7.10)to hold we need Lpjωq to be small, which corresponds to the condition (7.11). Hopefully, ℓmpωq willonly be large at high frequencies, for which we do not need (7.3) or (7.5) to hold.

Table 7.1 and Figure 7.4 summarize the constraints on the open-loop gain Lpjωq discussed above.

Attention! The conditions derived above for the open-loop gain Lpjωq are sufficient for the originalclosed-loop specifications to hold, but they are not necessary. When the open-loop gain “almost”verifies the conditions derived, it may be worth it to check directly if it verifies the original closed-loopconditions.

This is actually crucial for the conditions (7.11)–(7.12) that arise from robustness with respect tomultiplicative uncertainty, because around the crossover frequency |Lpjωcq| « 1 will not satisfyeither of these conditions, but it will generally satisfy the original condition (7.9) (as long as ℓmpωqis not too large). 2

Page 79: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

Robust Control 73

closed-loop specification open-loop constraint

overshoot ď 10% (ď 5%) phase margin ě 60 deg (ě 65 deg)|Epjωq||Rpjωq| ď kT , @ω P r0, ωT s |Lpjωq| ě 1

kT` 1, @ω P r0, ωT s

|Y pjωq||Dpjωq| ď kD , @ω P rωD1

, ωD2s |Lpjωq| ě |P0pjωq|

kD` 1, @ω P rωD1

, ωD2s

|Y pjωq||Npjωq| ď kN , @ω P rωN , 8q |Lpjωq| ď kN

1 ` kN, @ω P rωN , 8q

|Lpjωq||1 ` Lpjωq| ď 1

ℓmpωq , @ω |Lpjωq| ď 1

1 ` ℓmpωq´

or |Lpjωq| ě 1

1 ´ ℓmpωq¯

Table 7.1. Summary of the relationship between closed-loop specifications and open-loop constraints for theloop shaping design method

|Lpjωq|

ω

ωT

1

kT` 1

ωD2

|P0pjωq|kD

` 1

ωN

kN

1 ` kN

1

1 ´ ℓmpωq

1

1 ` ℓmpωq

Figure 7.4. Typical open-loop specifications for the loop shaping design method

7.3 Open-loop Gain Shaping

In classical lead/lag compensation, one starts with a basic unit-gain controller

C psq “ 1

and “adds” to it appropriate blocks to shape the desired open-loop gain Note. One actually does not “add”to the controller. To be precise,one multiplies the controller byappropriate gain, lead, and lagblocks. However, this does cor-respond to additions in the mag-nitude (in dBs) and phase Bodeplots.

Lpsq – C psqP0psq,so that it satisfies the appropriate open-loop constraints. This shaping can be achieved using threebasic tools.

1. Proportional gain. Multiplying the controller by a constant k moves the magnitude Bode plotup and down, without changing its phase.

2. Lead compensation. Multiplying the controller by a lead block with transfer function

Cleadpsq “ T s ` 1

αT s ` 1, α ă 1

increases the phase margin when placed at the cross-over frequency. Figure 7.5(a) shows theBode plot of a lead compensator. Note. A lead compensator also in-

creases the cross-over frequency,so it may require some trial anderror to get the peak of the phaseright at the cross-over frequency.

3. Lag compensation. Multiplying the controller by a lag block with transfer function

Clagpsq “ sz ` 1

sp ` 1, p ă z

decreases the high-frequency gain. Figure 7.5(b) shows the Bode plot of a lag compensator. Note. A lag compensator also in-creases the phase, so it can de-crease the phase margin. To avoidthis, one should only introducelag compensation away from thecross-over frequency.

Page 80: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

74 João P. Hespanha

7.4 Exercises

7.1 (Loop-shape 1). Consider again the nominal process model and multiplicative uncertainty thatyou obtained in Exercise 6.2. Design a controller for this process that achieves stability for all

admissible process models and that exhibits:

1. zero steady-state error to a step input,

2. Phase Margin no smaller then 60degrees,

3. steady-state error for sinusoidal inputs with frequencies ω ă 0.1rad/sec smaller than 1/50(´34dB), and

4. Rise time no slower than .3sec. 2

7.2 (Loop-shape 2). Consider the following nominal transfer function ans uncertainty bound:

P0psq “ 1

sp1 ` s5qp1 ` s20q , ℓmpωq “ |Lpjωq|,

where

Lpsq –2.5

p1 ` s20q2.

Use loop shaping to design a controller that achieves stability for all admissible process models andthat exhibits:

1. steady-state error to a ramp input no larger than .01,

2. Phase Margin no smaller then 45degrees,

3. steady-state error for sinusoidal inputs with frequencies ω ă 0.2rad/sec smaller than 1/250(´50dB), and

4. attenuation of measurement noise by at least a factor of 100 (´40dB) for frequencies greaterthan 200rad/sec. 2

Page 81: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

Robust Control 75

1

1

α

1

T

1

αT

ωmax “ 1?αT

φmax

(a) Lead

1

p

zp z

ωmax “ ?pz

(b) Lag

Figure 7.5. Bode plots of lead/lag compensators. The maximum lead phase angle is given by φmax “ arcsin 1´α1`α

;

therefore, to obtain a desired given lead angle φmax one sets α “ 1´sin φmax

1`sin φmax.

Page 82: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

76 João P. Hespanha

Page 83: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

Part III

LQG/LQR Controller Design

77

Page 84: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and
Page 85: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

Introduction to LQG/LQR Controller

Design

In optimal control one attempts to find a controller that provides the best possible performance withrespect to some given measure of performance. E.g., the controller that uses the least amount ofcontrol-signal energy to take the output to zero. In this case the measure of performance (also calledthe optimality criterion) would be the control-signal energy.

In general, optimality with respect to some criterion is not the only desirable property for acontroller. One would also like stability of the closed-loop system, good gain and phase margins,robustness with respect to unmodeled dynamics, etc.

In this section we study controllers that are optimal with respect to energy-like criteria. Theseare particularly interesting because the minimization procedure automatically produces controllers

that are stable and somewhat robust. In fact, the controllers obtained through this procedure aregenerally so good that we often use them even when we do not necessarily care about optimizing

for energy. Moreover, this procedure is applicable to multiple-input/multiple-output processes forwhich classical designs are difficult to apply.

Pre-requisites

1. Basic knowledge of state-space models (briefly reviewed here)

2. Familiarity with basic vector and matrix operations.

3. Knowledge of MATLAB/Simulink.

Further reading A more extensive coverage of LQG/LQR controller design can be found, e.g., in [8].

79

Page 86: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

80 João P. Hespanha

Page 87: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

Chapter 8

Review of State-space models

Contents

8.1 State-space Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 818.2 Input-output Relations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 828.3 Realizations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 838.4 Controllability and Observability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 838.5 Stability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 848.6 MATLAB R© Hints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84

8.1 State-space Models

Consider the system in Figure 8.1 with m inputs and k outputs. A state-space model for this system

uptq P Rm

yptq P Rk

9x “ fpx, uqy “ gpx, uq

Figure 8.1. System with m inputs and k outputs

relates the input and output of a system using the following first-order vector ordinary differentialequation

9x “ fpx, uq, y “ gpx, uq. (8.1)

where x P Rn is called the state of system. In this Chapter we restrict our attention to linear

time-invariant (LTI) systems for which the functions fp¨, ¨q and gp¨, ¨q are linear. In this case, (8.1)MATLAB R© Hint 25.ss(A,B,C,D) creates a LTIstate-space model with realiza-tion (8.2). . . p. 84

has the special form

9x “ Ax ` Bu, y “ Cx ` Du, (8.2)

where A is a n ˆ n matrix, B a n ˆ m matrix, C a k ˆ n matrix, and D a k ˆ m matrix.

Example 8.1 (Aircraft roll-dynamics). Figure 8.2 shows the roll-angle dynamics of an aircraft [12,p. 381]. Defining

x –“θ ω τ

‰1

we conclude that

9x “ Ax ` Bu

81

Page 88: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

82 João P. Hespanha

roll-angle

roll-rate= ˙

applied torque

9θ “ ω

9ω “ ´.875ω ´ 20τ

9τ “ ´50τ ` 50u

Figure 8.2. Aircraft roll-angle dynamics

with

A –

»–

0 1 00 ´.875 ´200 0 ´50

fifl , B –

»–

0050

fifl .

If we have both θ and ω available for control, we can define

y –“θ ω

‰1 “ Cx ` Du

with

C –

„1 0 00 1 0

, D –

„00

. 2

8.2 Input-output Relations

Note 1. The (unilateral) Laplacetransform of a signal xptq is givenby

Xpsq –

ż 8

0e´stxptqdt.

See [5, Appendix A] for a review ofLaplace transforms.

The transfer-function of this system can be found by taking Laplace transforms of (8.2):#

9x “ Ax ` Bu,

y “ Cx ` Du,

LÝÝÝÝÝÑ#

sX psq “ AX psq ` BUpsq,Y psq “ CX psq ` DUpsq,

where X psq, Upsq, and Y psq denote the Laplace transforms of xptq, uptq, and yptq. Solving for X psq,we get

psI ´ AqX psq “ BUpsq ô X psq “ psI ´ Aq´1BUpsq

and therefore

Y psq “ C psI ´ Aq´1BUpsq ` DUpsq “`C psI ´ Aq´1B ` D

˘Upsq.

DefiningMATLAB R© Hint 1.tf(num,den) creates a transfer-function with numerator anddenominator specified by num,den. . . p. 12

MATLAB R© Hint 2. zpk(z,p,k)creates a transfer-function withzeros, poles, and gain specified byz, p, k. . . p. 12

MATLAB R© Hint 26.tf(sys_ss) and zpk(sys_ss)

compute the transfer-functionof the state-space modelsys_ss. . . p. 84

T psq – C psI ´ Aq´1B ` D,

we conclude that

Y psq “ T psq Upsq. (8.3)

To emphasize the fact that T psq is a k ˆ m matrix, we call it the transfer-matrix of the system (8.2).

The relation (8.3) between the Laplace transforms of the input and the output of the system isonly valid for zero initial conditions, i.e., when xp0q “ 0. The general solution to the system (8.2) inthe time domain is given by

xptq “ eAtxp0q `ż t

0

eApt´sqBupsqds, (8.4)

yptq “ CeAtxp0q `ż t

0

CeApt´sqBupsqds ` Duptq, @t ě 0. (8.5)

Page 89: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

LQG/LQR Controller Design 83

Equation (8.4) is called the variation of constants formula.MATLAB R© Hint 27. expm com-putes the exponential of a ma-trix. . . p. 84

Example 8.2 (Aircraft roll-dynamics). The transfer-function for the state-space model in Example 8.1is given by:

T psq “«

´1000sps`.875qps`50q

´1000ps`.875qps`50q

ff

2

8.3 Realizations

Consider a transfer-matrix

T psq “

»———–

T11psq T12psq ¨ ¨ ¨ T1mpsqT21psq T22psq ¨ ¨ ¨ T2mpsq

......

. . ....

Tk1psq Tk2psq ¨ ¨ ¨ Tkmpsq

fiffiffiffifl ,

where all the Tij psq are given by a ratio of polynomials with the degree of the numerator smallerthan or equal to the degree of the denominator. It is always possible to find matrices A, B, C , D such

MATLAB R© Hint 28.ss(sys_tf) computes a re-alization of the transfer-functionsys_tf. . . p. 84

that

T psq “ C psI ´ Aq´1B ` D.

This means that it is always possible to find a state-space model like (8.2) whose transfer-matrix isprecisely T psq. The model (8.2) is called a realization of T psq. Attention! Realizations are not

unique, i.e., several state-spacemodels may have the same trans-fer function.8.4 Controllability and Observability

The system (8.2) is said to be controllable when given any initial state xi P Rn, any final state

xf P Rn, and any finite time T , one can find an input signal uptq that takes the state of (8.2) from

xi to xf in the interval of time 0 ď t ď T , i.e., when there exists an input uptq such that

xf “ eAT xi `ż T

0

eApT ´sqBupsqds.

To determine if a system is controllable, one can compute the controllability matrix, which is definedMATLAB R© Hint 29. ctrb(sys)computes the controllabilitymatrix of the state-space systemsys. Alternatively, one can usedirectly ctrb(A,B). . . p. 85

MATLAB R© Hint 30. rank(M)computes the rank of a matrix M.

by

C –“B AB A2B ¨ ¨ ¨ An´1B

‰.

The system is controllable if and only if this matrix has rank equal to the size n of the state vector.

The system (8.2) is said to be observable when one can determine the initial condition xp0q bysimply looking at the input and output signals uptq and yptq on a certain interval of time 0 ď t ď T ,i.e., one can solve

yptq “ CeAtxp0q `ż t

0

CeApt´sqBupsqds ` Duptq, @ 0 ď t ď T ,

uniquely for the unknown xp0q. To determine if a system is observable, one can compute theMATLAB R© Hint 31. obsv(sys)computes the controllabilitymatrix of the state-space systemsys. Alternatively, one can usedirectly obsv(A,C). . . p. 85

observability matrix, which is defined by

O –

»—————–

C

CA

CA2

...CAn´1

fiffiffiffiffiffifl

.

The system is observable if and only if this matrix has rank equal to the size n of the state vector.

Page 90: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

84 João P. Hespanha

Example 8.3 (Aircraft roll-dynamics). The controllability and observability matrices for the state-space model in Example 8.1 are given by:

C “

»–

0 0 ´10000 ´1000 5087550 ´2500 125000

fifl , O “

»——————–

1 0 00 1 00 1 00 ´.875 ´200 ´.875 ´200 .7656 1017.5

fiffiffiffiffiffiffifl

.

Both matrices have rank 3 so the system is both controllable and observable. 2

8.5 Stability

The system (8.2) is asymptotically stable when all eigenvalues of A have negative real parts. In thisMATLAB R© Hint 32. eig(A)computes the eigenvalues of thematrix A. . . p. 85

case, for any bounded input uptq the output yptq and the state xptq are also bounded, i.e.,

uptq ď c1, @t ě 0 ñ yptq ď c2, xptq ď c3 @t ě 0.

Moreover, if uptq converges to zero as t Ñ 8, then xptq and yptq also converge to zero as t Ñ 8.

Example 8.4 (Aircraft roll-dynamics). The eigenvalues of the matrix the A matrix for the state-spacemodel in Example 8.1 are t0, ´.875, ´50u so the system is not asymptotically stable. 2

8.6 MATLAB R© Hints

MATLAB R© Hint 25 (ss). The command sys_ss=ss(A,B,C,D) assigns to sys_ss a MATLAB LTIstate-space model with realization

9x “ Ax ` Bu, y “ Cx ` Du.

Optionally, one can specify the names of the inputs, outputs, and state to be used in subsequentplots as follows:

sys_ss=ss(A,B,C,D,...

’InputName’,’input1’,’input2’,...,...

’OutputName’,’output1’,’output2’,...,...

’StateName’,’input1’,’input2’,...)

The number of elements in the bracketed lists must match the number of inputs,outputs, and statevariables. 2

MATLAB R© Hint 26 (tf). The commands tf(sys_ss) and zpk(sys_ss) compute the transfer-function of the state-space model sys_ss specified as in Matlab Hint 25.

tf(sys_ss) stores (and displays) the transfer function as a ratio of polynomials on s.

zpk(sys_ss) stores (and displays) the polynomials factored as the product of monomials (for thereal roots) and binomials (for the complex roots). This form highlights the zeros and poles of thesystem. 2

MATLAB R© Hint 28 (ss). The command ss(sys_tf) computes the state-space model of the transferfunction sys specified as in Matlab Hints 1 or 2. 2

MATLAB R© Hint 27 (expm). The command expm(M) computes the matrix exponential eM. With thesymbolic toolbox, this command can be used to compute eAt symbolically as follows:

Page 91: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

LQG/LQR Controller Design 85

syms t

expm(A*t)

The first command defines t as a symbolic variable and the second computes eAt (assuming that thematrix A has been previously defined). 2

MATLAB R© Hint 29 (ctrb). The command ctrb(sys) computes the controllability matrix of thesystem sys. The system must be specified by a state-space model using, e.g., sys=ss(A,B,C,D),where A,B,C,D are a realization of the system. Alternatively, one can use directly ctrb(A,B). 2

MATLAB R© Hint 31 (obsv). The command obsv(sys) computes the observability matrix of thesystem sys. The system must be specified by a state-space model using, e.g., sys=ss(A,B,C,D),where A,B,C,D are a realization of the system. Alternatively, one can use directly obsv(A,C). 2

MATLAB R© Hint 32 (eig). The command eig(A) computes the eigenvalues of the matrix A. Alter-natively, eig(sys) computes the eigenvalues of the A matrix for a state-space system sys specifiedby sys=ss(A,B,C,D), where A,B,C,D are a realization of the system. 2

Page 92: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

86 João P. Hespanha

Page 93: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

Chapter 9

Linear Quadratic Regulation (LQR)

Contents

9.1 Feedback Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 879.2 Optimal Regulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 889.3 State-Feedback LQR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 899.4 Stability and Robustness . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 909.5 Loop-shaping Control using LQR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 929.6 MATLAB R© Hints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 949.7 To Probe Further . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 959.8 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96

9.1 Feedback Configuration

Figure 9.1 shows the feedback configuration for the Linear quadratic regulation (LQR) problem.

−yptq P R

k

zptq P Rℓ

uptq P Rm

processcontroller

Figure 9.1. Linear quadratic regulation (LQR) feedback configuration. Note the negative feedback and theabsence of a reference signal. Reference signals will be introduced in Chapter 11.

In this configuration, the state-space model of the process is of the form

9x “ Ax ` Bu, y “ Cx, z “ Gx ` Hu. (9.1)

and has two distinct outputs:

1. The measured output yptq P Rk corresponds to the signal(s) that can be measured and are

therefore available for control. If the controller transfer-matrix is C psq, we have

Y psq “ ´C psqUpsq,

where Y psq and Upsq denote the Laplace transforms of the process input uptq and the measuredoutput yptq, respectively.

2. The controlled output zptq P Rℓ corresponds to a signal that one would like to make as small

as possible in the shortest possible amount of time.

87

Page 94: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

88 João P. Hespanha

Sometimes zptq “ yptq, which means that our control objective is to make the whole measuredoutput very small. However, when the output yptq is a vector, often one simply needs to makeone of the measured outputs y1ptq small. In this case, one chooses zptq “ y1ptq.

Note 38. In the context of Exam-ple 8.1, one could imagine that,while both and θ and ω canbe measured, one may mostlywant to regulate the roll angleθ. . . p. 81

In some situations one chooses

zptq “„y1ptq9y1ptq

,

which means that we want to make both the measured output y1ptq and its derivative 9y1ptqvery small. Many other options are possible.

The choice of z should be viewed as a design parameter. In Section 9.5 we will study theimpact of this choice in the performance of the closed-loop.

9.2 Optimal Regulation

The LQR problem is defined as follows:

Problem 9.1 (Optimal LQR). Find the controller transfer-matrix C psq that makes the following cri-Notation 5. Given an m-vector,

v ““v1 v2 ¨ ¨ ¨ vm

‰,

v denotes the Euclidean norm ofv , i.e.,

v “ v 1v “´ mÿ

i“1

v2i

¯ 12.

terion as small as possible

JLQR –

ż 8

0

zptq2 ` ρ uptq2dt, (9.2)

where ρ is a positive constant. 2

The termż 8

0

zptq2dt

corresponds to the energy of the controlled output and the term

ż 8

0

uptq2dt

to the energy of the control input. In LQR one seeks a controller that minimizes both energies.However, decreasing the energy of the controlled output will require a large control input, and asmall control input will lead to large controlled outputs. The role of the constant ρ is to establish atrade-off between these conflicting goals.

1. When we chose ρ very large, the most effective way to decrease JLQR is to employ a smallcontrol input, at the expense of a large controlled output.

2. When we chose ρ very small, the most effective way to decrease JLQR is to obtain a very smallcontrolled output, even if this is achieved at the expense of employing a large control input.

Often the optimal LQR problem is defined more generally and consists of finding the controllerNote 39. The most general formfor the quadratic criteria isż 8

0x1Qx ` u1Ru ` 2x1Nu dt

. . . p. 95

transfer-matrix C psq that minimizes

JLQR –

ż 8

0

zptq1Qzptq ` ρu1ptqRuptqdt, (9.3)

Page 95: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

LQG/LQR Controller Design 89

where Q is an ℓ ˆ ℓ symmetric positive-definite matrix, R an m ˆ m symmetric positive-definiteNote 40. Other choices for thematrices Q and R are possiblebut one should always choose bothmatrices to be positive-definite.We recall that a symmetric q ˆq matrix M is positive-definite ifx1Mx ą 0, for every nonzero vec-tor x P R

q . . . p. 95

matrix, and ρ a positive constant.

Bryson’s rule A first choice for the matrices Q and R in (9.3) is given by the Bryson’s rule [5,p. 537]: select Q and R diagonal with

Qii “ 1

maximum acceptable value of z2i

, i P t1, 2, . . . , ℓu

Rj j “ 1

maximum acceptable value of u2j

, j P t1, 2, . . . , mu,

which corresponds to the following criteria

JLQR –

ż 8

0

´ ℓÿ

i“1

Qii ziptq2 ` ρ

mÿ

j“1

Rj j uj ptq2¯

dt.

In essence the Bryson’s rule scales the variables that appear in JLQR so that the maximum acceptable

value for each term is one. This is especially important when the units used for the differentcomponents of u and z make the values for these variables numerically very different from eachother.

Although Bryson’s rule sometimes gives good results, often it is just the starting point to atrial-and-error iterative design procedure aimed at obtaining desirable properties for the closed-loopsystem. In Section 9.5 we will discuss systematic methods to chose the weights in the LQR criterion.

9.3 State-Feedback LQR

In the state-feedback version of the LQR problem (Figure 9.2), we assume that the whole state x

can be measured and therefore it is available for control.

−xptq P R

n

zptq P Rℓ

uptq P Rm

processcontroller

Figure 9.2. Linear quadratic regulation (LQR) with state feedback

Solution to the optimal state-feedback LQR Problem 9.1. The optimal state-feedback LQR controllerMATLAB R© Hint 33. lqr com-putes the optimal state-feedbackcontroller gain K . . . p. 94

for the criteria (9.3) is a simple matrix gain of the form

u “ ´Kx (9.4)

where K is the m ˆ n matrix given by

K “ pH 1QH ` ρRq´1pB1P ` H 1QGq

and P is the unique positive-definite solution to the following equation

A1P ` PA ` G1QG ´ pPB ` G1QHqpH 1QH ` ρRq´1pB1P ` H 1QGq “ 0,

known as the Algebraic Riccati Equation (ARE). 2

Page 96: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

90 João P. Hespanha

9.4 Stability and Robustness

The state-feedback control law (9.4), results in a closed-loop system of the formNote 41. A system 9x “ Ax `Bu is asymptotically stable whenall eigenvalues of A have neg-ative real parts. See Sec-tion 8.5. . . p. 84

9x “ pA ´ BK qx.

A crucial property of LQR controller design is that this closed-loop is asymptotically stable (i.e., allthe eigenvalues of A ´ BK have negative real part) as long as the following two conditions hold:

1. The system (9.1) is controllable.Note 42. The definitions and testsfor controllability and observ-ability are reviewed in Sec-tion 8.4. . . p. 83

2. The system (9.1) is observable when we ignore y and regard z as the sole output .

Attention! When selecting themeasured output z , it is importantto verify that the observabilitycondition is satisfied.

Perhaps even more important is the fact that LQR controllers are inherently robust with respect

to process uncertainty. To understand why, consider the open-loop transfer-matrix from the process’input u to the controller’s output u (Figure 9.3). The state-space model from u to u is given by

−x

uu

9x “ Ax ` BuK

Figure 9.3. State-feedback open-loop gain

9x “ Ax ` Bu, u “ ´Kx,

which corresponds to the following open-loop negative feedback m ˆ m transfer-matrixNote. In a negative-feedbackconfiguration, the output of theprocess is multiplied by ´1 beforebeing connected to the input ofthe controller. Often a referencesignal is also added to the inputof the controller.

Lpsq “ K psI ´ Aq´1B.

We focus our attention in single-input processes (m “ 1), for which Lpsq is a scalar transfer-function

Note. LQR controllers also exhibitrobustness properties for multiple-input processes. However, in thiscase Lpsq is a m ˆ m transfer-matrix and one needs a multi-variable Nyquist criterion.

and the following holds:

Kalman’s Inequality. When H 1G “ 0, the Nyquist plot of Lpjωq does not enter a circle of radius

one around ´1, i.e.,

|1 ` Lpjωq| ě 1, @ω P R. 2

Kalman’s Inequality is represented graphically in Figure 9.4 and has several significant implications,which are discussed next.

´1´2

60o

Lpjωq

Im

Re

Figure 9.4. Nyquist plot for a LQR state-feedback controller

Page 97: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

LQG/LQR Controller Design 91

Positive gain margin If the process’ gain is multiplied by a constant k ą 1, its Nyquist plot simplyexpands radially and therefore the number of encirclements does not change. This corresponds to apositive gain margin of `8.

Negative gain margin If the process’ gain is multiplied by a constant .5 ă k ă 1, its Nyquistplot contracts radially but the number of encirclements still does not change. This corresponds to anegative gain margin of 20 log10p.5q “ ´6dB.

Phase margin If the process’ phase increases by θ P r´60, 60s degrees, its Nyquist plots rotatesby θ but the number of encirclements still does not change. This corresponds to a phase margin of

˘60 degrees.

+

+−

xu

∆mpsq

9x “ Ax ` BuK

|∆mpjωq| ď ℓmpωq, @ω

Figure 9.5. Unity feedback configuration with multiplicative uncertainty

Multiplicative uncertainty Kalman’s inequality guarantees thatNote 43. Why?... p. 95ˇ

ˇ Lpjωq1 ` Lpjωq

ˇˇ ď 2. (9.5)

Since, we known that the closed-loop system in Figure 9.5 remains stable for every multiplicativeuncertainty block ∆mpjωq with norm smaller than ℓmpωq, as long as

ˇˇ Lpjωq1 ` Lpjωq

ˇˇ ă 1

ℓmpωq , (9.6)

we conclude that an LQR controller provides robust stability with respect to any multiplicative

uncertainty with magnitude smaller than 12 , because we then have

ˇˇ Lpjωq1 ` Lpjωq

ˇˇ ď 2 ă 1

ℓmpωq .

However, much larger additive uncertainties may be admissible: e.g., when Lpjωq " 1, (9.6) willhold for ℓmpωq almost equal to 1; and when Lpjωq ! 1, (9.6) will hold for ℓmpωq almost equal to1Lpjωq " 1.

Attention! Kalman’s inequality is only valid when H 1G “ 0. When this is not the case, LQRcontrollers can be significantly less robust. This limits to same extent the controlled outputs thatcan be placed in z .

For example, consider the process 9x “ Ax ` Bu and suppose that we want to regulate a particularoutput y1 “ C1x . Choosing

z “ y1 “ C1x

leads to G “ C1 and H “ 0 and therefore H 1G “ 0, for which Kalman’s inequality holds. However,choosing

z “„y1

9y1

“„C1x

C1 9x

“„

C1x

C1Ax ` C1Bu

“„

C1

C1A

x `

„0

C1B

u,

Page 98: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

92 João P. Hespanha

leads toNote. If the transfer function fromu to y1 has two more poles thanzeros, then one can show thatC1B “ 0 and H “ 0. In this case,Kalman’s inequality holds also forthis choice of z .

G “„

C1

C1A

, H “

„0

C1B

,

and therefore

H 1G “ B1C 11C1A,

which may not be equal to zero. 2

9.5 Loop-shaping Control using LQR

Although Bryson’s rule sometimes gives good results, it may not suffice to satisfy tight controlspecifications. We will see next a few other rules that allow us to actually do loop shaping usingLQR. We restrict our attention to the single-input case (m “ 1) and R “ 1, Q “ I , which correspondsto

JLQR –

ż 8

0

zptq2 ` ρ uptq2dt.

Low-frequency open-loop gain For the range of frequencies for which |Lpjωq| " 1 (typically lowMATLAB R© Hint 34.sigma(sys) draws thenorm-Bode plot of the sys-tem sys. . . p. 94

frequencies), we have that

|Lpjωq| « PzpjωqaH 1H ` ρ

where

Pzpsq – GpsI ´ Aq´1B ` H

is the transfer function from the control signal u to the controlled output z . To understand theimplications of this formula, it is instructive to consider two fairly typical cases:

1. When z “ y1, with y1 – C1x scalar, we have

|Lpjωq| « |P1pjωq|aH 1H ` ρ

.

where

P1psq – C1psI ´ Aq´1B

is the transfer function from the control input u to the output y1. In this case,

(a) the “shape” of the magnitude of the open-loop gain Lpjωq is determined by the magnitudeNote. Although the magnitude ofLpjωq mimics the magnitude ofP1pjωq, the phase of the open-loop gain Lpjωq always leads toa stable closed-loop with an ap-propriate phase margin.

of the transfer function from the control input u to the output y1;

(b) the parameter ρ moves the magnitude Bode plot up and down (more precisely H 1H ` ρ).

2. When z ““y1 γ 9y1

‰1, we can show that

Note 44. Why?. . . p. 95 |Lpjωq| « |1 ` jγω| |P1pjωq|aH 1H ` ρ

. (9.7)

In this case the low-frequency open-loop gain mimics the process transfer function from u toy, with an extra zero at 1γ and scaled by 1?

H1H`ρ. Thus

(a) ρ moves the magnitude Bode plot up and down (more precisely H 1H ` ρ),

(b) large values for γ lead to a low-frequency zero and generally result in a larger phasemargin (above the minimum of 60 degrees) and smaller overshoot in the step response.

Note 45. The introduction of theoutput γ 9y1 has an effect sim-ilar to that of lead compensa-tion in classical control (see Sec-tion 7.3). . . p. 73

Unfortunately, in LQR there is noequivalent to a lag compensator todecrease the high-frequency gain.We will see in Section 10.6 thatthis limitation of LQR can be over-

However, this is often achieved at the expense of a slower response.

Page 99: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

LQG/LQR Controller Design 93

High-frequency open-loop gain For ω " 1, we have that

|Lpjωq| « c

ω?

ρ,

for some constant c. We thus conclude the following:

1. LQR controllers always exhibit a high-frequency magnitude decay of ´20dB/decade.

2. The cross-over frequency is approximately given by

c

ωcross?

ρ« 1 ô ωcross « c?

ρ,

which shows that the cross-over frequency is proportional to 1?ρ and generally small values

for ρ result in faster step responses.

Attention! The (slow) ´20dB/decade magnitude decrease is the main shortcoming of state-feedbackLQR controllers because it may not be sufficient to clear high-frequency upper bounds on the open-loop gain needed to reject disturbances and/or for robustness with respect to process uncertainty.We will see in Section 10.6 that this can actually be improved with output-feedback controllers.

2

Example 9.1 (Aircraft roll-dynamics). Figure 9.6 shows Bode plots of the open-loop gain Lpsq “K psI ´ Aq´1B for several LQR controllers obtained for the aircraft roll-dynamics in Example 8.1. The

10−2

10−1

100

101

102

103

−180

−135

−90

Pha

se (

deg)

−40

−20

0

20

40

60

80

From: u To: Out(1)

Mag

nitu

de (

dB)

rho = 0.01rho = 1rho = 100u to roll anglegamma = 0.01

Open−loop Bode Diagrams

Frequency (rad/sec)

(a) Open-loop gain for several values of ρ. This param-eter allow us to move the whole magnitude Bode plot upand down.

10−2

10−1

100

101

102

103

−180

−135

−90

Pha

se (

deg)

−40

−20

0

20

40

60

80

From: u To: Out(1)

Mag

nitu

de (

dB)

gamma = 0.01gamma = 0.1gamma = 0.3u to roll angle(rho = 0.01)

Open−loop Bode Diagrams

Frequency (rad/sec)

(b) Open-loop gain for several values of γ . Larger valuesfor this parameter result in a larger phase margin.

Figure 9.6. Bode plots for the open-loop gain of the LQR controllers in Example 9.1. As expected, for lowfrequencies the open-loop gain magnitude matches that of the process transfer function from u to θ (but withsignificantly lower/better phase) and at high-frequencies the gain’s magnitude falls at ´20dB/decade.

controlled output was chosen to be z –“θ γ 9θ

‰1, which corresponds to

G –

„1 0 00 γ 0

, H –

„00

.

The controllers were obtained with R “ 1, Q “ I2ˆ2, and several values for ρ and γ . Figure 9.6(a)shows the open-loop gain for several values of ρ and Figure 9.6(b) shows the open-loop gain forseveral values of γ .

Figure 9.7 shows Nyquist plots of the open-loop gain Lpsq “ K psI ´ Aq´1B for different choices

of the controlled output z . In Figure 9.7(a) z –“θ 9θ

‰1, which corresponds to

Page 100: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

94 João P. Hespanha

−5 −4 −3 −2 −1 0 1 2−3

−2

−1

0

1

2

3

−1−2

π/3

From: u To: uuOpen−loop Nyquist Diagram (rho = 1, gamma = 0.1)

Real Axis

Imag

inar

y A

xis

(a) H 1G “ 0

−5 −4 −3 −2 −1 0 1 2−3

−2

−1

0

1

2

3

−1−2

π/3

From: u To: uuOpen−loop Nyquist Diagram

Real Axis

Imag

inar

y A

xis

(b) H 1G ‰ 0

Figure 9.7. Bode plots for the open-loop gain of the LQR controllers in Example 9.1

G –

„1 0 00 1 0

, H –

„00

.

In this case, H 1G “ r 0 0 0 s and Kalman’s inequality holds as can be seen in the Nyquist plot. In

Figure 9.7(b), the controlled output was chosen to be z –“θ 9τ

‰1, which corresponds to

G –

„1 0 00 0 ´50

, H –

„050

.

In this case we have H 1G “ r 0 0 ´2500 s and Kalman’s inequality does not hold. We can see fromthe Nyquist plot that the phase and gain margins are very small and there is little robustness withrespect to unmodeled dynamics since a small perturbation in the process can lead to an encirclementof the point ´1. 2

9.6 MATLAB R© Hints

MATLAB R© Hint 33 (lqr). The command [K,S,E]=lqr(A,B,QQ,RR,NN) computes the optimalstate-feedback LQR controller for the process

9x “ Ax ` Bu

with criteria

J –

ż 8

0

xptq1QQxptq ` u1ptqRRuptq ` 2x 1ptqNNuptqdt.

For the criterion in (9.2) one should select

QQ “ G1G, RR “ H 1H ` ρI, NN “ G1H

and for the criterion (9.3)

QQ “ G1QG, RR “ H 1QH ` ρR, NN “ G1QH.

(cf. Sidebar 39). This command returns the optimal state-feedback matrix K, the solution P to thecorresponding Algebraic Riccati Equation, and the poles E of the closed-loop system. 2

MATLAB R© Hint 34 (sigma). The command sigma(sys) draws the norm-Bode plot of the systemsys. For scalar transfer functions this command plots the usual magnitude Bode plot but for vectortransfer function it plots the norm of the transfer function versus the frequency. 2

Page 101: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

LQG/LQR Controller Design 95

9.7 To Probe Further

Note 39 (General LQR). The most general form for a quadratic criteria is

J –

ż 8

0

xptq1Qxptq ` u1ptqRuptq ` 2x 1ptqNuptqdt. (9.8)

Since z “ Gx ` Hu, the criterion in (9.2) is a special form of (9.8) with

Q “ G1G, R “ H 1H ` ρI, N “ G1H

and (9.3) is a special form of (9.8) with

Q “ G1QG, R “ H 1QH ` ρR, N “ G1QH.

For this criteria, the optimal state-feedback LQR controller is still of the form

u “ ´K x

but now K is given by

K “ R´1pB1P ` Nq

and P is a solution to the following Algebraic Riccati Equation (ARE)

A1P ` PA ` Q ´ pPB ` NqR´1pB1P ` N 1q “ 0. 2

Note 40. A symmetric k ˆ k matrix M is positive-definite if

x 1Mx ą 0,

for every nonzero vector x P Rk . Positive-definite matrices are always nonsingular and their inverses

are also positive-definite.

To test if a matrix is positive define one can compute its eigenvalues. If they are all positive theMATLAB R© Hint 32. eig(A)computes the eigenvalues of thematrix A. . . p. 85

matrix is positive-definite, otherwise it is not. 2

Note 43 (Multiplicative uncertainty). Since the Nyquist plot of Lpjωq does not enter a circle ofradius one around ´1, we have that

|1 ` Lpjωq| ě 1 ñˇˇ 1

1 ` Lpjωq

ˇˇ “

ˇˇ1 ´ Lpjωq

1 ` Lpjωq

ˇˇ ď 1 ñ

ˇˇ Lpjωq1 ` Lpjωq

ˇˇ ď 2. 2

Note 44 (Equation (9.7)). When z ““y γ 9y

‰1, we have that

z “„

y

γ 9y

“„

Cx

γCAx ` γCBu

ñ G “

„C

γCA

, H “

„0

γCB

.

In this case,

Pzpsq “„

PypsqγsPypsq

“„

1γs

Pypsq,

where Pypsq – C psI ´ Aq´1B, and therefore

|Lpjωq| «a

1 ` γ2ω2 |Pypjωq|aH 1H ` ρ

“ |1 ` jγω| |Pypjωq|aH 1H ` ρ

. 2

Page 102: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

96 João P. Hespanha

9.8 Exercises

9.1. Verify using the diagram in Figure 11.1 that, for the single-input case (m “ 1), the closed-looptransfer function Tupsq from the reference r to the process input u is given by

Tupsq “ 1

1 ` LpKF ` Nq,

where Lpsq “ K psI ´ Aq´1B, and the closed-loop transfer function Tz from the reference r to thecontrolled output z is given by

Tzpsq “ 1

1 ` LPzpKF ` Nq,

where Pzpsq “ GpsI ´ Aq´1B ` H . 2

9.2. Consider an inverted pendulum operating near the upright equilibrium position, with linearizedmodel given by

„9θ:θ

“„

0 1gℓ

´ bmℓ2

„θ9θ

`„

01

mℓ2

T

where T denotes an applied torque, θ the pendulum’s angle with a vertical axis pointing up, andℓ “ 1m, m “ 1Kg, b “ .1N/m/s, g “ 9.8m/s2.

1. Design a PD controller using LQR

2. Design a PID controller using LQR

Hint: Consider an “augmented” process model with state θ, 9θ, zptq “şt

0 θpsqds. 2

Page 103: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

Chapter 10

LQG/LQR Output Feedback

Contents

10.1 Output Feedback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9710.2 Full-order Observers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9710.3 LQG Estimation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9810.4 LQG/LQR Output Feedback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9910.5 Separation Principle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10010.6 Loop-gain Recovery . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10010.7 Loop Shaping using LQR/LQG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10210.8 MATLAB R© Hints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10210.9 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102

10.1 Output Feedback

The state-feedback LQR formulation considered in Chapter 9.3 suffered from the drawback that theoptimal control law

uptq “ ´Kxptq (10.1)

required the whole state x of the process to be measurable. An possible approach to overcome thisdifficulty is to estimate the state of the process based solely on the measured output y, and use

uptq “ ´K xptq

instead of (10.1), where xptq denotes an estimate of the process’ state xptq. In this chapter weconsider the problem of constructing state estimates.

10.2 Full-order Observers

Consider a process with state-space model

9x “ Ax ` Bu, y “ Cx, (10.2)

where y denotes the measured output, u the control input. We assume that x cannot be measuredand our goal to estimate its value based on y.

Suppose we construct the estimate x by replicating the process dynamics as in

9x “ Ax ` Bu. (10.3)

97

Page 104: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

98 João P. Hespanha

To see if this would generate a good estimate for x , we can define the state estimation error e – x´x

and study its dynamics. From (10.2) and (10.3), we conclude that

9e “ Ax ´ Ax “ Ae.

This shows that when the matrix A is asymptotically stable the error e converges to zero for any

input u, which is good news because it means that x eventually converges to x as t Ñ 8. However,when A is not stable e is unbounded and x grow further and further apart from x as t Ñ 8. Toavoid this, one includes a correction term in (10.3):

9x “ Ax ` Bu ` Lpy ´ yq, y “ C x, (10.4)

where y should be viewed as an estimate of y and L a given n ˆ k matrix. When x is equal (or veryclose) to x , then y will be equal (or very close) to y and the correction term Lpy ´ yq plays no role.However, when x grows away from x , this term will (hopefully!) correct the error. To see how thiscan be done, we re-write the estimation error dynamics now for (10.2) and (10.4):

9e “ Ax ´ Ax ´ LpCx ´ C xq “ pA ´ LC qe.

Now e converges to zero as long as A ´ LC is asymptotically stable, It turns out that, even whenA is unstable, in general we will be able to select L so that A ´ LC is asymptotically stable. Thesystem (10.4) can be re-write as

9x “ pA ´ LC qx ` Bu ` Ly, (10.5)

and is called a full-order observer for the process. Full-order observers have two inputs—the process’Note. “Full-order” refers to thefact that the size of its state x isequal to the size of the process’state x , even though the output ymay directly provide the values ofsome components of x .

control input u and its measured output y—and a single output—the state estimate x . Figure 10.1shows how a full-order observer is connected to the process.

z

y

x

u

9x “ Ax ` Bu

9x “ pA ´ LC qx ` Bu ` Ly

Figure 10.1. Full-order observer

10.3 LQG Estimation

Any choice of L in (10.4) for which A ´ LC is asymptotically stable will make x converge to x , aslong at the process dynamics is given by (10.2). However, in general the output y is affected bymeasurement noise and the process dynamics are also affected by disturbance. In light of this, amore reasonable model for the process is

9x “ Ax ` Bu ` Bd, y “ Cx ` n, (10.6)

where d denotes a disturbance and n measurement noise. In this we need to re-write the estimationerror dynamics for (10.6) and (10.4), which leads to

9e “ Ax ` Bd ´ Ax ´ LpCx ` n ´ C xq “ pA ´ LC qe ` Bd ´ Ln.

Because of n and d, the estimation error will generally not converge to zero, but we would still like itto remain small by appropriate choice of the matrix L. This motivates the so called Linear-quadratic

Gaussian (LQG) estimation problem:

Page 105: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

LQG/LQR Controller Design 99

Problem 10.1 (Optimal LQG). Find the matrix gain L that minimizes the asymptotic expected value Note. A zero-mean white noiseprocess n has an autocorrelationof the form

Rnpt1, t2q – E“npt1q n1pt2q

“ QN δpt1 ´ t2q.

Such process is wide-sense sta-tionary in the sense that its meanis time-invariant and its autocor-relation Rpt1, t2q only depends onthe difference τ – t1 ´ t2 . Itspower spectrum is the same for ev-ery frequency ω and given by

Snpωq –

ż 8

´8Rpτqe´jωτdτ “ QN .

of the estimation error:

JLQG – limtÑ8

E“eptq2

‰,

where dptq and nptq are zero-mean Gaussian noise processes (uncorrelated from each other) withpower spectrum

Sdpωq “ QN , Snpωq “ RN , @ω. 2

Solution to the optimal LQG Problem 10.1. The optimal LQG estimator gain L is the n ˆ k matrix

MATLAB R© Hint 35. kalmancomputes the optimal LQGestimator gain L. . . p. 102

given by

L “ PC 1R´1N

and P is the unique positive-definite solution to the following Algebraic Riccati Equation (ARE)

Note 40. A symmetric qˆq matrixM is positive definite if x1Mx ą0, for every nonzero vector x PR

q . . . p. 95

AP ` PA1 ` BQN B1 ´ PC 1R´1N CP “ 0.

When one uses the optimal gain L in (10.5), this system is called the Kalman-Bucy filter.

A crucial property of this system is that A ´ LC is asymptotically stable as long as the followingtwo conditions hold:

1. The system (10.6) is observable.

2. The system (10.6) is controllable when we ignore u and regard d as the sole input.

Different choices of QN and RN result in different estimator gains L:

1. When RN is very small (when compared to QN ), the measurement noise n is necessarily smallso the optimal estimator interprets a large deviation of y from y as an indication that theestimate x is bad and needs to be correct. In practice, this lead to large matrices L and fastpoles for A ´ LC .

2. When RN is very large, the measurement noise n is large so the optimal estimator is much moreconservative in reacting to deviations of y from y. This generally leads to smaller matrices L

and slow poles for A ´ LC .

We will return to the selection of QN and RN in Section 10.6.

10.4 LQG/LQR Output Feedback

We now go back to the problem of designing an output-feedback controller for the process:

9x “ Ax ` Bu, y “ Cx, z “ Gx ` Hu.

Suppose that we designed a state-feedback controller

u “ ´Kx (10.7)

that solves an LQR problem and constructed an LQG state-estimator

9x “ pA ´ LC qx ` Bu ` Ly.

We can obtain an output-feedback controller by using the estimated state x in (10.7), instead of theMATLAB R© Hint 36.reg(sys,K,L) computes theLQG/LQR positive output-feedback controller for the processsys with regulator gain K andestimator gain L. . . p. 102

true state x . This leads to the following output-feedback controller

9x “ pA ´ LC qx ` Bu ` Ly “ pA ´ LC ´ BK qx ` Ly, u “ ´K x,

with negative-feedback transfer matrix given by

C psq “ K psI ´ A ` LC ` BK q´1L.

This is usually known as an LQG/LQR output-feedback controller and the resulting closed-loop isshown in Figure 10.2.

Page 106: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

100 João P. Hespanha

´

eT “ ´y

y

z

u9x “ Ax ` Bu

z “ Gx ` Hu

y “ Cx

9x “ pA ´ LC ´ BK qx ´ LeT

u “ ´K x

Figure 10.2. LQG/LQR output-feedback

10.5 Separation Principle

The first question to ask about an LQG/LQR controller is whether or not the closed-loop system willbe stable. To answer this question we collect all the equations that defines the closed-loop system:

9x “ Ax ` Bu, y “ Cx, (10.8)

9x “ pA ´ LC qx ` Bu ` Ly, u “ ´K x. (10.9)

To check the stability of this system it is more convenient to consider the dynamics of the estimationerror e – x ´ x instead of the the state estimate x . To this effect we replace in the above equationsx by x ´ e, which yields:

9x “ Ax ` Bu “ pA ´ BK qx ` BKe, y “ Cx,

9e “ pA ´ LC qe, u “ ´K px ´ eq.

This can be written in matrix notation as„

9x9e

“„A ´ BK BK

0 A ´ LC

„x

e

, y “

“C 0

‰ „x

e

.

Separation Principle. The eigenvalues of the closed-loop system (10.8) are given by those of theNote. Any eigenvalue of a blockdiagonal matrix must be an eigen-value of one of the diagonal blocks.

state-feedback regulator dynamics A ´ BK together with those of state-estimator dynamics A ´ LC .

In case these both matrices are asymptotically stable, then so is the closed-loop (10.8).

10.6 Loop-gain Recovery

We saw in Sections 9.4 and 9.5 that state-feedback LQR controllers have desirable robustnessproperties and that we can shape the open-loop gain by appropriate choice of the LQR weightingparameter ρ and the choice of the controlled output z . It turns out that we can, to some extent,recover the LQR open-loop gain for the LQG/LQR controller.

Loop-gain recovery. Suppose that the process is single-input/single-output and has no zeros in theright half-place. SelectingNote. B “ B corresponds to an

input disturbance since the pro-cess becomes

9x “ Ax ` Bu ` Bd

“ Ax ` Bpu ` dq.

B – B, QN – 1, RN – σ, σ ą 0,

the open-loop gain for the output-feedback LQG/LQR controller converges to the open-loop gain for

the state-feedback LQR state-feedback controller over a range of frequencies r0, ωmaxs as we make

σ Ñ 0, i.e.,

C pjωqPpjωq σ Ñ 0ÝÝÝÝÝÝÝÝÑ K pjωI ´ 1q´1B, @ω P r0, ωmaxs

In general, the larger ωmax is, the smaller σ needs to be for the gains to match.

Page 107: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

LQG/LQR Controller Design 101

Attention! 1. To achieve loop-gain recovery we need to chose RN – σ , even if this does not

accurately describe the noise statistics. This means that the estimator may not be optimal forthe actual noise.

2. One should not make σ smaller than necessary because we do not want to recover the (slow)´20dB/decade magnitude decrease at high frequencies. In practice we should make σ just Note. We need loop recovery up

to the cross-over frequency tomaintain the desired phase mar-gin, otherwise the LQG/LQR con-troller may have a phase marginthat is much smaller than that ofthe original LQR controller.

small enough to get loop recovery until just above or at cross-over. For larger values of ω, theoutput-feedback controller may actually behave much better than the state-feedback one.

3. When the process has zeros in the right half-plane, loop-gain recovery will generally only workup to the frequencies of the nonminimum-phase zeros.

When the zeros are in the left half-plane but close to the axis, the closed-loop will not be veryrobust with respect to uncertainty in the position of the zeros. This is because the controllerwill attempt to cancel these zeros. 2

Example 10.1 (Aircraft roll-dynamics). Figure 10.3(a) shows Bode plots of the open-loop gain forthe state-feedback LQR state-feedback controller vs. the open-loop gain for several output-feedbackLQG/LQR controller obtained for the aircraft roll-dynamics in Example 8.1. The LQR controller was

10−2

10−1

100

101

102

103

−180

−135

−90

Pha

se (

deg)

−80

−60

−40

−20

0

20

40

60

80

From: u To: Out(1)

Mag

nitu

de (

dB)

sigma = 0.01sigma = 1e−05sigma = 1e−08LQR loop−gain(rho = 0.01, gamma=0.1)

Open−loop Bode Diagrams

Frequency (rad/sec)

(a) Open-loop gain

0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 20

0.5

1

1.5

sigma = 0.01sigma = 1e−05sigma = 1e−08LQR loop−gain(rho = 0.01, gamma=0.1)

Step Response

Time (sec)

Am

plitu

de

(b) Closed-loop step response

Figure 10.3. Bode plots and closed-loop step response for the open-loop gain of the LQR controllers in Exam-ples 10.1, 11.2.

designed using the controlled output z –“θ γ 9θ

‰1, γ “ .1 and ρ “ .01. For the LQG state-

estimators we used B “ B and RN “ σ for several values of σ . We can see that, as σ decreases,

Page 108: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

102 João P. Hespanha

the range of frequencies over which the open-loop gain of the output-feedback LQG/LQR controllermatches that of the state-feedback LQR state-feedback increases. Moreover, at high frequencies theoutput-feedback controllers exhibit much faster (and better!) decays of the gain’s magnitude. 2

10.7 Loop Shaping using LQR/LQG

We can now summarize the procedure to do open-loop gain shaping using LQG/LQR, to be contrastedwith the classical lead-lag compensation briefly recalled in Section 7.3:Note. A significant diference be-

tween this procedure and that dis-cussed in Section 7.3, is that sta-bility of the closed loop is now al-ways automatically guaranteed.

1. Start by designing the LQR gain K assuming that the full state can be measured to obtain anappropriate loop gain in the low-frequency range, up to the cross-over frequency.

This can be done using the procedure described in Section 9.5, where

(a) the parameter ρ can be used to move the move the magnitude Bode plot up and down,and

(b) the parameter γ can be used to improve the phase margin.

2. Use LQG to achieve loop-gain recovery up to the cross-over frequency.

This can be done using the procedure described in Section 10.6, by decreasing σ just to thepoint where one gets loop recovery until just above or at the cross-over frequency. Hopefully,this still permits satisfying any high-frequency constraints for the loop gain.

10.8 MATLAB R© Hints

MATLAB R© Hint 35 (kalman). The command [est,L,P]=kalman(sys,QN,RN) computes the op-timal LQG estimator gain for the process

9x “ Ax ` Bu ` BBd, y “ Cx ` n, (10.10)

where dptq and nptq are uncorrelated zero-mean Gaussian noise processes with covariance matrices

E“dptq d1pτq

‰“ δpt ´ τqQN, E

“nptq n1pτq

‰“ δpt ´ τqRN.

The variable sys should be a state-space model created using sys=ss(A,[B BB],C,0). ThisAttention! The process model sysshould have the D matrix equal tozero, even though (10.10) seems toimply otherwise.

command returns the optimal estimator gain L, the solution P to the corresponding algebraic Riccatiequation, and a state-space model est for the estimator. The inputs to est are ru; ys, and itsoutputs are ry; xs.For loop transfer recovery (LTR), one should set

BB “ B, QN “ I, RN “ σ I, σ Ñ 0. 2

MATLAB R© Hint 36 (reg). The function reg(sys,K,L) computes a state-space model for a positiveAttention! Somewhat unexpect-edly, the command reg producesa positive feedback controller.

output feedback LQG/LQR controller for the process with state-space model sys with regulator gainK and estimator gain L. 2

10.9 Exercises

10.1. Consider an inverted pendulum on a cart operating near the upright equilibrium position, withlinearized model given by

»——–

p9p9θ:θ

fiffiffifl “

»——–

0 1 0 00 0 ´2.94 00 0 0 10 0 11.76 0

fiffiffifl

»——–

p9p

θ9θ

fiffiffifl `

»——–

0.325

0´.3

fiffiffifl F

Page 109: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

LQG/LQR Controller Design 103

where F denotes a force applied to the cart, p the cart’s horizontal position, and θ the pendulum’sangle with a vertical axis pointing up.

1. Design an LQG/LQR output-feedback controller that uses only the angle θ and the positionof the cart p.

2. Design an LQG/LQR output-feedback controller that uses the angle θ, the angular velocity 9θ,the position of the cart p, and its derivative using LQG/LQR (full-state feedback).

Why use LQG when the state is accessible? 2

Page 110: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

104 João P. Hespanha

Page 111: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

Chapter 11

Set-point control

Contents

11.1 Nonzero Equilibrium State and Input . . . . . . . . . . . . . . . . . . . . . . . . . . . 10511.2 State feedback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10611.3 Output feedback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10711.4 MATLAB R© Hints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10711.5 To Probe Further . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107

11.1 Nonzero Equilibrium State and Input

Often one does not want to make z as small as possible, but instead make it converge as fast aspossible to a given constant set-point value r . This can be achieved by making the state x and theinput u of the process (9.1) converge to values x˚ and u˚ for which

Ax˚ ` Bu˚ “ 0, r “ Gx˚ ` Hu˚. (11.1)

The right equation makes sure that z will be equal to r when x and u reach x˚ and u˚, respectively.The left-equation makes sure that when these values are reached, 9x “ 0 and therefore x will remainequal to x˚, i.e., x˚ is an equilibrium state.

Given the desired set-point r for x , computing x˚ and u˚ is straightforward because (11.1) is a Note. When the process transfer-function has an integrator, onegenerally gets u˚ “ 0.

system of linear equations and in general the solution to these equations is of the form

x˚ “ Fr, u˚ “ Nr. (11.2)

For example, when the number of inputs to the process m is equal to the number of controlled outputs Note. The matrix“

A BG H

‰is invert-

ible unless the process’ transfer-function from u to z has a zeroat the origin. This derivative ef-fect will always make z convergeto zero when the input convergesto a constant.

MATLAB R© Hint 37. When thenumber of process inputs mis larger than or equal to thenumber of controlled outputs ℓ ,the matrices F and N in (11.2)can be easily computed usingMATLAB R© . . . p. 107

ℓ , we have

„A B

G H

„x˚

“„0r

ô

„x˚

“„

A B

G H

´1 „0r

, (11.3)

and F is an n ˆ ℓ matrix given by the top n rows and right-most ℓ columns of“

A BG H

‰´1and N is an

m ˆ ℓ matrix given by the bottom m rows and right-most ℓ columns of“

A BG H

‰´1.

Attention! When the number of process inputs m is larger than the number of controlled outputs ℓ

we have an over-actuated system and the system of equations (11.1) will generally have multiplesolutions. One of them is

„x˚

“„

A B

G H

1 ˆ„A B

G H

„A B

G H

1˙´1 „0r

. (11.4)

105

Page 112: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

106 João P. Hespanha

In this case, we can still express x˚ and u˚ as in (11.2).

When the number of process inputs m is smaller than the number of controlled outputs ℓ we havean under-actuated system and the system of equations (11.1) may not have a solution. In fact, asolution will only exists for some specific references r . However, when it does exist, the solution canstill express x˚ and u˚ as in (11.2). 2

11.2 State feedback

When one wants z to converge to a given set-point value r , the state-feedback controller should beNote 46. Why?. . . p. 107

u “ ´K px ´ x˚q ` u˚ “ ´Kx ` pKF ` Nqr, (11.5)

where x˚ and u˚ are given by (11.2) and K is the gain of the optimal regulation problem. Thecorresponding control architecture is shown in Figure 11.1. The state-space model for the closed-loop system is given by

9x “ Ax ` Bu “ pA ´ BK qx ` BpKF ` Nqrz “ Gx ` Hu “ pG ´ HK qx ` HpKF ` Nqr.

−+ +

+r

x

x˚z

u

9x “ Ax ` BuKF

N

Figure 11.1. Linear quadratic set-point control with state feedback

Example 11.1 (Aircraft roll-dynamics). Figure 11.2 shows step responses for the state-feedbackLQR controllers in Example 9.1, whose Bode plots for the open-loop gain are shown in Figure 9.6.Figure 11.2(a) shows that smaller values of ρ lead to faster responses and Figure 11.2(b) shows that

0 1 2 3 4 5 60

0.2

0.4

0.6

0.8

1

1.2

1.4

rho = 0.01rho = 1rho = 100gamma = 0.01

Step Response

Time (sec)

Am

plitu

de

(a)

0 1 2 3 4 5 60

0.2

0.4

0.6

0.8

1

1.2

1.4

gamma = 0.01gamma = 0.1gamma = 0.3(rho = 0.01)

Step Response

Time (sec)

Am

plitu

de

(b)

Figure 11.2. Step responses for the closed-loop LQR controllers in Example 11.1

larger values for γ lead to smaller overshoots (but slower responses). 2

Page 113: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

LQG/LQR Controller Design 107

11.3 Output feedback

When one wants z to converge to a given set-point value r , the output-feedback LQG/LQR controllershould be

Note 47. Why?. . . p. 108

9x “ pA ´ LC ´ BK qx ` LpCx˚ ´ yq, u “ K x ` u˚, (11.6)

where x˚ and u˚ are given by (11.2). The corresponding control architecture is shown in Figure 11.3.The state-space model for the closed-loop system is given by Note. When z “ y, we have

G “ C , H “ 0 and in this caseCx˚ “ r . This corresponds toCF “ 1 in Figure 11.3. When theprocess has an integrator we getN “ 0 and obtain the usual unity-feedback configuration.

„9x9x

“„

Ax ` BpK x ` u˚qpA ´ LC ´ BK qx ` LpCx˚ ´ Cxq

“„

A BK

´LC A ´ LC ´ BK

„x

x

`„

BN

LCF

r

z “ Gx ` HpK x ` u˚q ““G HK

‰ „x

x

` HNr

+ − +

+r

y

Cx˚z

u

9x “ Ax ` Bu

y “ Cx

9x “ pA ´ LC ´ BK qx ` Lv

u “ K xCF

N

Figure 11.3. LQG/LQR set-point control

Example 11.2 (Aircraft roll-dynamics). Figure 10.3(b) shows step responses for the output-feedbackLQG/LQR controllers in Example 10.1, whose Bode plots for the open-loop gain are shown in Fig-ure 10.3(a). We can see that smaller values of σ lead to a smaller overshoot mostly due to a largergain margin. 2

11.4 MATLAB R© Hints

MATLAB R© Hint 37. When the number of process inputs m is larger than or equal to the numberof controlled outputs ℓ , the matrices F and N in (11.2) that correspond to the equilibria in either(11.3) or (11.4) can be computed using the following MATLAB R© commands:

M=pinv([A,B;G,H]);

F=M(1:n,end-l+1:end);

N=M(end-n+1:end,end-l+1:end);

where n denotes the size of the state and l the number of controlled outputs. 2

11.5 To Probe Further

Note 46 (Set-point control with state-feedback). To understand why (11.5) works, suppose we define

z “ z ´ r, x “ x ´ x˚, u “ u ´ u˚.

Then

9x “ Ax ` Bu “ Apx ´ x˚q ` Bpu ´ u˚q ` Ax˚ ` Bu˚

z “ Gx ` Hu ´ r “ Gpx ´ x˚q ` Hpu ´ u˚q ` Gx˚ ` Hu˚ ´ r

Page 114: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

108 João P. Hespanha

and we conclude that

9x “ Ax ` Bu, z “ Gx ` Hu. (11.7)

By selecting the control signal in (11.5), we are setting

u “ u ´ u˚ “ ´K px ´ x˚q “ ´K x,

which is the optimal state-feedback LQR controller that minimizes

JLQR –

ż 8

0

`zptq1Qzptq

˘` ρ

`u1ptqRuptq

˘dt,

This controller makes the system (11.7) asymptotically stable and therefore x , u, z all converge tozero as t Ñ 8, which means that z converges to r . 2

Note 47 (Set-point control with output-feedback). To understand why (11.6) works suppose we define

z “ z ´ r, x “ x ´ x˚ ` x .

Then

9x “ pA ´ LC qx (11.8)

9x “ pA ´ BK qx ´ LC x (11.9)

z “ Gpx ´ xq ` HK x ´ r. (11.10)

1. Since A ´ LC is asymptotically stable, we conclude from (11.8) that x Ñ 0 as t Ñ 8.

In practice, we can view the state x of the controller as an estimate of x˚ ´ x .

2. Since A ´ BK is asymptotically stable and x Ñ 0 as t Ñ 8, we conclude from (11.9) thatx Ñ 0 as t Ñ 8.

3. Since x Ñ 0 and x Ñ 0 as t Ñ 8, we conclude from (11.10) that z Ñ r as t Ñ 8. 2

11.1. Verify equations (11.8), (11.9), and (11.10). 2

Page 115: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

Part IV

Nonlinear Control

109

Page 116: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and
Page 117: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

Introduction to Nonlinear Control

uptq P Rm

xptq P Rn

9x “ fpx, uq

uptq P Rm

xptq P Rn

u “ kpxq

9x “ fpx, uq

Figure 11.4. Nonlinear process with m inputs Figure 11.5. Closed-loop nonlinear system withstate-feedback

In this section we consider the control of nonlinear systems such as the one shown in Figure 11.4.Our goal is to construct a state-feedback control law of the form Note. This control-law implicitly

assumes that the whole state x canbe measured.u “ kpxq

that results in adequate performance for the closed-loop system

9x “ f`x, kpxq

˘.

Typically, at least we want x to be bounded and converge to some desired reference value r .

Pre-requisites

1. Basic knowledge of nonlinear ordinary differential equations.

2. Basic knowledge of continuous-time linear controller design.

3. Familiarity with basic vector and matrix operations.

Further reading A more extensive coverage of nonlinear control can be found, e.g., in [9].

111

Page 118: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

112 João P. Hespanha

Page 119: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

Chapter 12

Feedback linearization controllers

Contents

12.1 Feedback Linearization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11312.2 Generalized Model for Mechanical Systems . . . . . . . . . . . . . . . . . . . . . . . . 11412.3 Feedback Linearization of Mechanical Systems . . . . . . . . . . . . . . . . . . . . . . 11612.4 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117

12.1 Feedback Linearization

In feedback linearization control design, we decompose the control signal u into two componentswith distinct functions:

u “ unl ` v,

where

1. unl is used to “cancel” the process’ nonlinearities, and

2. v is used to control the resulting linear system.

u

y

Fdragg

From Newton’s law:

m:y “ Fdrag ´ mg ` u

“ ´1

2cρA 9y| 9y| ´ mg ` u,

where m is the vehicle’s mass, g gravity’s ac-celeration, Fdrag “ ´ 1

2 cρA 9y| 9y| the drag force,and u an applied force.

Figure 12.1. Dynamics of a vehicle moving vertically in the atmosphere

113

Page 120: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

114 João P. Hespanha

To understand how this is done, consider the vehicle shown in Figure 12.1 moving vertically in theNote. For large objects movingthrough air, the air resistance isapproximately proportional to thesquare of the velocity, correspond-ing to a drag force that opposesmotion, given by

Fdrag “ ´ 1

2cρA 9y| 9y|

where ρ is the air density, A thecross-sectional area, and c thedrag coefficient, which is 0.5 for aspherical object and can reach 2for irregularly shaped objects [11].Fdrag always points in the oppositedirection of 9y.

atmosphere. By choosing

u “ unlp 9yq ` v, unlp 9yq –1

2cρA 9y| 9y| ` mg,

we obtain

m:y “ ´1

2cρA 9y| 9y| ´ mg ` punlp 9yq ` vq “ v ñ :y “ 1

mv.

In practice, we transformed the original nonlinear process into a (linear) double integrator withtransfer function from v to y given by

T psq –1

ms2.

We can now use linear methods to find a controller for v that stabilizes the closed-loop. E.g., a PDNote. Any linear method can beused to design the controller forv , but we shall see shortly thatrobustness with respect to multi-plicative uncertainty is importantfor the closed-loop.

controller of the form

v “ KPe ` KD 9e, e – r ´ y.

Figure 12.2 shows a diagram of the overall closed-loop system. From an “input-output” perspective,the system in the dashed block behaves as a linear system with transfer function T psq –

1ms2 .

+ +

+−

r e uv

unl

y

1

2cρA 9y| 9y| ` mg

m:y “ ´1

2cρA 9y| 9y| ´ mg ` uKPe ` KD 9e

Figure 12.2. Feedback linearization controller.

12.2 Generalized Model for Mechanical Systems

The equations of motion of many mechanical systems can be written in the following general formNote. These include robot-arms,mobile robots, airplanes, heli-copters, underwater vehicles, hov-ercraft, etc.

Mpqq:q ` Bpq, 9qq 9q ` Gpqq “ F, (12.1)

where

• q P Rk is a k-vector with linear and/or angular positions called the vector of generalized

coordinates;

• F P Rk is a k-vector with applied forces and/or torques called the vector of generalized forces;

• Gpqq is a k-vector sometimes called the vector of conservative forces;

• Mpqq is a k ˆ k non-singular symmetric positive-definite matrix called the mass matrix ; andNote 40. A symmetric qˆq matrixM is positive definite if x1Mx ą0, for every nonzero vector x PR

q . . . p. 95

Page 121: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

Nonlinear Control 115

• Bpq, 9qq is a k ˆ k matrix sometimes called the centrifugal/Coriolis/friction matrix, for systemswith no friction we generally have

9q1Bpq, 9qq 9q “ 0, @ 9q P Rk

whereas for systems with friction

9q1Bpq, 9qq 9q ě 0, @ 9q P Rk ,

with equality only when 9q “ 0.

Examples

θ

g

m

θ1

θ2

ℓ1

ℓ2

m1

m2

Figure 12.3. Inverted pendulum Figure 12.4. Two-link robot manipulator

Example 12.1 (Inverted pendulum). The dynamics of the inverted pendulum shown in Figure 12.3 aregiven by

mℓ2:θ “ mgℓ sin θ ´ b 9θ ` T ,

where T denotes a torque applied at the base, and g is the gravity’s acceleration. This equation canbe identified with (12.1), provided that we define Note. When the pendulum is at-

tached to a cart and the input u isthe cart’s acceleration :z , we haveT “ ´mℓu cos θ but this makesthe problem more difficult, espe-cially around θ “ ˘π2. Why?

q – θ, F – T , Mpqq – mℓ2, Bpqq – b, Gpqq – ´mgℓ sin θ. 2

Example 12.2 (Robot arm). The dynamics of the robot-arm with two revolution joints shown inFigure 12.4 can be written as in (12.1), provided that we define

q –

„θ1

θ2

, F –

„τ1

τ2

.

where τ1 and τ2 denote torques applied at the joints. For this system

Mpqq –

„ℓ22 m2

2 ` 2ℓ1ℓ2 cos θ2 ` ℓ21 pm1 ` m2q ℓ2

2 ` ℓ1ℓ2m2 cos θ2

ℓ22 m2 ` ℓ1ℓ2m2 cos θ2 ℓ2

2 m2

Bpq, 9qq –

„´2m2ℓ1ℓ2

9θ2 sin θ2 ´m2ℓ1ℓ29θ2 sin θ2

m2ℓ1ℓ29θ1 sin θ2 0

Gpqq – g

„m2ℓ2 cospθ1 ´ θ2q ` pm1 ` m2qℓ1 cos θ1

m2ℓ2 cospθ1 ´ θ2q

.

where g is the gravity’s acceleration [2, p. 202–205]. 2

Page 122: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

116 João P. Hespanha

x

y

θ

ℓFp

Fs

Figure 12.5. Hovercraft

Example 12.3 (Hovercraft). The dynamics of the hovercraft shown in Figure 12.5 can be written asin (12.1), provided that we define

q –

»–

x

y

θ

fifl , F –

»–

pFs ` Fpq cos θ ´ Fℓ sin θ

pFs ` Fpq sin θ ` Fℓ cos θ

ℓpFs ´ Fpq

fifl ,

where Fs, Fp, and Fℓ denote the starboard, portboard, and lateral fan forces. The vehicle in thephotograph does not have a lateral fan, which means that Fℓ “ 0. It is therefore called underactuated

because the number of controls (Fs and Fp) is smaller than the number of degrees of freedom (x , y,and θ). For this system

Mpqq –

»–

m 0 00 m 00 0 J

fifl , Bpqq –

»–

dv 0 00 dv 00 0 dω

fifl ,

where m “ 5.5 kg is the mass of the vehicle, J “ 0.047 kg m2 its rotational inertia, dv “ 4.5 thecoefficient of linear friction, dω “ .41 the coefficient of rotational friction, and ℓ “ 0.123 m themoment arm of the forces. In these equations, the geometry and mass centers of the vehicle areassumed to coincide [3]. 2

12.3 Feedback Linearization of Mechanical Systems

A mechanical system is called fully actuated when one has control over the whole vector or generalizedforces. For such systems we regard u – F as the control input and we can use feedback linearizationto design nonlinear controllers. In particular, choosing

F “ u “ unlpq, 9qq ` Mpqq v, unlpq, 9qq – Bpq, 9qq 9q ` Gpqq,

we obtain

Mpqq:q ` Bpq, 9qq 9q ` Gpqq “ Bpq, 9qq 9q ` Gpqq ` Mpqq v ô :q “ v.

Expanding the k-vectors :q and v in their components, we obtain»———–

:q1

:q2

...:qk

fiffiffiffifl “

»———–

v1

v2

...vk

fiffiffiffifl

and therefore we can select each vi as if we were designing a controller for a double integrator

:qi “ vi.

Page 123: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

Nonlinear Control 117

Attention! Measurement noise can lead to problems in feedback linearization controllers. When themeasurements of q and 9q are affected by noise, we have

Mpqq:q ` Bpq, 9qq 9q ` Gpqq “ unlpq ` n, 9q ` wq ` Mpq ` nq v,

where n is measurement noise in the q sensors and w the measurement noise in the 9q sensors. Inthis case

Mpqq:q ` Bpq, 9qq 9q ` Gpqq “ Bpq ` n, 9q ` wqp 9q ` wq ` Gpq ` nq ` Mpq ` nq v (12.2)

and (with some work) one can show that

:q “`I ` ∆

˘v ` d, (12.3)

where Note. See Exercise 12.1. p. 117

∆ – Mpqq´1`Mpq ` nq ´ Mpqq

˘,

d – Mpqq´1´`

Bpq ` n, 9q ` wq ´ Bpq, 9qq˘

9q ` Bpq ` n, 9q ` wqw ` Gpq ` nq ´ Gpqq¯

.

Since ∆ and d can be very large, with feedback linearization controllers it is particularly importantto make sure that the controller selected for v is robust with respect to multiplicative uncertaintyand good at rejecting disturbances.

12.4 Exercises

12.1. Verify that (12.3) is indeed equivalent to (12.2), by solving the latter equation with respect to:q. 2

12.2. Design a feedback linearization controllers to drive the inverted pendulum in Example 12.1to the up-right position. Use the following values for the parameters: ℓ “ 1 m, m “ 1 kg,b “ .1 N m´1s´1, and g “ 9.8 m s´2. Verify the performance of your system in the presence ofmeasurement noise using Simulink. 2

Page 124: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

118 João P. Hespanha

Page 125: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

Chapter 13

Lyapunov Stability

Contents

13.1 Lyapunov Stability . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11913.2 Lyapunov Stability Theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12113.3 Exercise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12213.4 LaSalle’s Invariance Principle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12213.5 Liénard Equation and Generalizations . . . . . . . . . . . . . . . . . . . . . . . . . . . 12313.6 To Probe Further . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12513.7 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125

13.1 Lyapunov Stability

Although feedback linearization provides a simple method to design controllers for nonlinear systems.The resulting controllers are sometimes very sensitive to measurement noise because it prevents aperfect cancellation of the nonlinearities. It turns out that such cancellation is not always needed.

Consider again the vehicle shown in Figure 12.1 and suppose that we simply want to control itsvelocity 9y. For simplicity, we assume that the applied force u is constant and larger than mg (i.e.,there is an excess upward force) and that the units were chosen so that all constant coefficient arenumerically equal to 1:

:y “ ´ 9y| 9y| ` 1.

Since

´ 9y| 9y| ` 1 “ 0 ô 9y “ 1,

we conclude that 1 is the only equilibrium-point for the system, i.e.,

9yptq “ 1, @t ě 0,

is the only possible constant trajectory for the system. A question that may then arise is:

Will 9yptq converge to 1 as t Ñ 8, when 9yp0q ­“ 1?

To study this question we will consider an “error” system that looks at the difference from 9y to theequilibrium-point 1. Defining x – 9y ´ 1, we conclude that

9x “ ´px ` 1q|x ` 1| ` 1. (13.1)

and the previous question could be reformulated as

119

Page 126: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

120 João P. Hespanha

Will xptq converge to 0 as t Ñ 8, when xp0q ­“ 0?

To address this question, suppose that we define

V pxq “ x2

and compute V ’s derivative with respect to time using the chain rule:

9V ptq “ dV`xptq

˘

dt“ BV

Bx9x “ 2x

`´ px ` 1q|x ` 1| ` 1

˘“#

´2x2px ` 2q x ě ´1

2xpx2 ` 2x ` 2q x ă ´1.(13.2)

Figure 13.1 shows the right-hand-side of the above equation as a function of x . Three conclusions

−2 −1.5 −1 −0.5 0 0.5 1 1.5 2−35

−30

−25

−20

−15

−10

−5

0

x

9 V

Figure 13.1. 9V vs. x

can be drawn from here:

Boundedness For every initial condition xp0q, |xptq| will remain bounded for all t ě 0, i.e., it willnot blow up. This is because V

`xptq

˘“ x2ptq cannot increase.

Stability If we start xp0q very close to zero, then xptq will remain very close to zero for all timest ě 0. This is because V

`xptq

˘“ x2ptq will always be smaller or equal than V

`xp0q

˘.

Convergence xptq Ñ 0 as t Ñ 8. This is because the right-hand side of (13.2) is only equal to

zero when x “ 0 and therefore 9V will be strictly negative for any nonzero x .

This finally provides an answer to the previous questions: Yes! x Ñ 0 as t Ñ 8.

When a system exhibits these three properties we say that the origin is globally asymptotically

stable. This notion of stability for nonlinear systems was originally proposed by Aleksandr Lyapunovand now carries his name.

Definition 13.1 (Lyapunov stability). Given a system

9x “ fpxq, t ě 0, x P Rn, (13.3)

we say that:

(i) the trajectories are globally bounded if for every initial condition xp0q, there exists a scalarα`xp0q

˘ě 0 such that

ˇxptq

ˇď α

`xp0q

˘, @t ě 0;

Page 127: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

Nonlinear Control 121

(ii) the origin is globally stable if the trajectories are globally bounded and αpxp0qq Ñ 0 asxp0q Ñ 0;

(iii) the origin is globally asymptotically stable if it is globally stable and in addition xptq Ñ 0 ast Ñ 8.

Attention! The requirement (ii) is rather subtle but very important. In essence, it says that if wechoose the initial condition xp0q very close to the origin, then the upper bound αpxp0qq will also bevery small and the whole trajectory stays very close to the origin. 2

13.2 Lyapunov Stability Theorem

The technique used before to conclude that the origin is globally asymptotically stable for thesystem (13.1) is a special case of a more general method proposed by Aleksandr M. Lyapunov. Hismain contribution to nonlinear control was the realization that an appropriate choice of the function

V pxq could make proving stability very simple. In the example above (and in fact in most one-dimensional systems) V pxq “ x2 works well, but for higher dimensional systems the choice of V pxqis critical.

Lyapunov Stability Theorem. Suppose that there exists a scalar-valued function V : Rn Ñ R with

the following properties:

(i) V pxq is differentiable;

(ii) V pxq is positive definite, which means that V p0q “ 0 and

V pxq ą 0, @x ‰ 0.

(iii) V pxq is radially unbounded, which means that V pxq Ñ 8 whenever x Ñ 8;

(iv) ∇xV pxq ¨ fpxq is negative definite, which means that ∇xV p0q ¨ fp0q “ 0 andNotation 6. Given a scalar func-tion of n variables fpx1, . . . , xmq,∇x f denotes the gradient of f , i.e.,

∇x fpx1, x2, . . . , xmq “”

BfBx1

BfBx2

¨ ¨ ¨ BfBxm

ı.

∇xV pxq ¨ fpxq ă 0, @x ‰ 0.

Then the origin is globally asymptotically stable for the system (13.3). The function V pxq is called

Note 48. What is the intuition be-hind Lyapunov’s stability theo-rem? p. 121

a Lyapunov function. 2

The function V pxq “ x2 considered before satisfies all the conditions of the Lyapunov StabilityTheorem for the system (13.1) so our conclusion that the origin was globally asymptotically stableis consistent with this theorem.

Note 48 (Lyapunov Stability Theorem). When the variable x is a scalar,

9V ptq “ dV`xptq

˘

dt“ BV

Bx9x “ BV

Bxfpxq,

but when x and f are n-vectors, i.e.,

9x “ fpxq ô

»———–

9x1

9x2

...9xn

fiffiffiffifl “

»———–

f1pxqf2pxq

...fnpxq

fiffiffiffifl ,

we haveNote 49. These derivatives existbecause of condition (i) in Lya-punov Stability Theorem.

9V ptq “ dV`xptq

˘

dt“

nÿ

i“1

BV

Bxi

9xi “ BV

Bxifipxq “ ∇xV pxq ¨ fpxq.

Condition (iv) thus requires V pxq to strictly decrease as long x ‰ 0. Because of condition (ii), x ‰ 0is equivalent to V pxq ą 0 so V pxq must decrease all the way to zero.

Since V pxq is only zero at zero and condition (iii) excludes the possibility that V pxq Ñ 0 as x Ñ 8,this necessarily implies that x Ñ 0 as t Ñ 8. 2

Page 128: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

122 João P. Hespanha

Example 13.1. Consider the following system

:y ` p1 ` | 9y|qpy ` 9yq “ 0.

Defining x ““x1 x2

‰1–

“y 9y

‰1, this system can be written as 9x “ fpxq as follows:

9x1 “ x2,

9x2 “ ´p1 ` |x2|qpx1 ` x2q.

Suppose we want to show that the origin is globally asymptotically stable. A “candidate” LyapunovNote. Finding a Lyapunov func-tion is more an art than a sci-ence. Fortunately several “artists”already discovered Lyapunov formany systems of interest.

function for this system is

V pxq – x21 ` px1 ` x2q2.

This function satisfies the requirements (i)–(iii). Moreover,

∇xV pxq ¨ fpxq “ 2x1 9x1 ` 2px1 ` x2qp 9x1 ` 9x2q“ 2x1x2 ` 2px1 ` x2q

`x2 ´ p1 ` |x2|qpx1 ` x2q

˘

“ 2x1p´x1 ` x1 ` x2q ` 2px1 ` x2q`x2 ´ p1 ` |x2|qpx1 ` x2q

˘

“ ´2x21 ` 2px1 ` x2q

`x1 ` x2 ´ p1 ` |x2|qpx1 ` x2q

˘

“ ´2x21 ´ 2|x2|px1 ` x2q2 ď 0.

Since we only have equality to zero when x1 “ x2 “ 0, we conclude that (iv) also holds and thereforeV pxq is indeed a Lyapunov function and the origin is globally asymptotically stable. 2

13.3 Exercise

13.1. The average number of data-packets sent per second by any program that uses the TCPprotocol (e.g., ftp) evolves according to an equation of the form:

9r “ 1

RT T 2´ 2

3pdroprpr ` dq,

where r denotes the average sending rate, RT T denotes the round-trip time for one packet inseconds, pdrop the probability that a particular packet will be dropped inside the network, and d

the average sending rate of other data-flows using the same connection. All rates are measured inpackets per second. Typically one packet contains 1500bytes.

1. Find the equilibrium-point req for the sending rate.

Hint: When d “ 0, your expression should simplify to

req “a

32

RT T?

pdrop.

This is known as the “TCP-friendly” equation.

2. Verify that the origin is globally asymptotically stable for the system with state x – r ´ req.2

13.4 LaSalle’s Invariance Principle

Consider now the system

:y ` 9y| 9y| ` y3 “ 0

Page 129: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

Nonlinear Control 123

Defining x ““x1 x2

‰1–

“y 9y

‰1, this system can be written as 9x “ fpxq as follows:

9x1 “ x2, (13.4)

9x2 “ ´x2|x2| ´ x31 . (13.5)

A candidate Lyapunov function for this system is

V pxq –x2

2

2` x4

1

4.

This function satisfies the requirements (i)–(iii). However,

∇xV pxq ¨ fpxq “ x2 9x2 ` x31 9x1 “ ´|x2|x2

2

and therefore it does not satisfy (iv) because

∇xV pxq ¨ fpxq “ 0 for x2 “ 0, x1 ‰ 0.

However,

∇xV pxq ¨ fpxq “ 0 ñ x2 “ 0

so V can only stop decreasing if x2 converges to zero. Moreover, if we go back to (13.5) we seethat x2ptq “ 0, @t must necessarily imply that x1ptq “ 0, @t . So although V pxq is not a Lyapunovfunction, it can still be used to prove that the origin is globally asymptotically stable. The argumentjust used to prove that the origin is asymptotically stable is due to J. P. LaSalle:

LaSalle’s Invariance Principle. Suppose that there exists a scalar-valued function V : Rn Ñ R thatNote 50. In general, LaSalle’s In-variance Principle is stated in amore general form. . . p. 125

satisfies the conditions (i)–(iii) of the Lyapunov Stability Theorem as well as

(iv)’ ∇xV pxq ¨ fpxq is negative semi-definite, which means that

∇xV pxq ¨ fpxq ď 0, @x,

and, in addition, for every solution xptq for which

∇xV`xptq

˘¨ f`xptq

˘“ 0, @t ě 0 (13.6)

we must necessarily have that

xptq “ 0, @t ě 0. (13.7)

Then the origin is globally asymptotically stable for the system (13.3). In this case the function V pxqis called a weak Lyapunov function. 2

13.5 Liénard Equation and Generalizations

LaSalle’s Invariance principle is especially useful to prove stability for systems with dynamics de-scribed by the Liénard equation:

Note 51. The system consideredin Section 13.4 was precisely ofthis form.

:y ` bpy, 9yq 9y ` λpyq “ 0,

where y is a scalar and bpy, 9yq, λpyq are functions such that

bpy, 9yq ą 0, @ 9y ­“ 0 (13.8)

λpyq ‰ 0, @y ­“ 0 (13.9)

Λpyq –

ż y

0

λpzqdz ą 0, @y ­“ 0 (13.10)

limyÑ8

Λpyq “ 8. (13.11)

Page 130: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

124 João P. Hespanha

This type of equation arises in numerous mechanical systems from Newton’s law.

Defining x ““x1 x2

‰1–

“y 9y

‰1, the Liénard equation can be written as 9x “ fpxq as follows:

9x1 “ x2, (13.12)

9x2 “ ´bpx1, x2qx2 ´ λpx1q. (13.13)

A candidate Lyapunov function for this system isNote. This is how we got the Lya-punov function for the system inSection 13.4. Verify!

V pxq –x2

2

2` Λpx1q. (13.14)

This function satisfies the requirements (i)–(iii) of the Lyapunov Stability Theorem andNote. Recall that (i) asked forV pxq to be differentiable, (ii)asked for V pxq to be positive defi-nite, and (iii) asked for V pxq to beradially unbounded.

∇xV pxq ¨ fpxq “ x2 9x2 ` λpx1q 9x1 “ ´bpx1, x2qx22 ď 0,

since bpx1, x2q ą 0 for every x2 ‰ 0 [cf. (13.8)]. Moreover, from (13.8) we conclude that

∇xV pxq ¨ fpxq “ 0 ñ x2 “ 0.

Because of (13.13), any trajectory with x2ptq “ 0, @t necessarily must have λ`x1ptq

˘“ 0, @t , which

in turn implies that x1ptq “ 0, @t because of (13.9). Therefore V pxq is a weak Lyapunov functionand the origin is globally asymptotically stable.

The type of weak Lyapunov function used for the Liénard equation can also be used for higher-order dynamical system of the form

Mpqq:q ` Bpq, 9qq 9q ` Lq “ 0, (13.15)

where q is a k-vectors and Mpqq, Bpq, 9qq, and L are k ˆ k matrices with Mpqq and L symmetricand positive definite.

Defining

x “„x1

x2

„q9q

P R

2k ,

the system (13.15) can be written as 9x “ fpxq as follows:

9x1 “ x2,

9x2 “ ´Mpx1q´1´

Bpx1, x2qx2 ` Lx1

¯.

A candidate Lyapunov function for this system is

V pxq –1

2x 1

2Mpx1qx2 ` 1

2x 1

1Lx1. (13.16)

This function satisfies the requirements (i)–(iii) andNote. Using the product rule:dpx1Mxq

dt “ dxdt

1Mx ` x1M dx

dt `x1 dM

dt x . But since dxdt

1Mx is a

scalar, it is equal to its transpose

and we get dpx1Mxqdt “ 2x1M dx

dt `x1 dM

dt x .

∇xV pxq ¨ fpxq “ x 12Mpx1q 9x2 ` 1

2x 1

2

´dMpx1qdt

¯x2 ` 9x 1

1Lx1

“ ´x 12

´Bpx1, x2q ´ 1

2

dMpx1qdt

¯x2.

Using LaSalle’s Invariance Principle, we conclude that the origin is globally asymptotically stable aslong as

Bpx1, x2q ´ 1

2

dMpx1qdt

is positive definite. This will be used shortly to design controllers for mechanical systems.

Page 131: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

Nonlinear Control 125

13.6 To Probe Further

Note 50 (LaSalle’s Invariance Principle). LaSalle’s Invariance Principle is generally stated in thefollowing form.

LaSalle’s Invariance Principle. Suppose that there exists a scalar-valued function V : Rn Ñ R that

satisfies the conditions (i)–(iii) of Lyapunov Stability Theorem as well as

(iv)” ∇xV pxq ¨ fpxq is negative semi-definite, which means that

∇xV pxq ¨ fpxq ď 0, @x.

Then the origin is globally stable for the system (13.3). Moreover, let E denote the set of all points

for which ∇xV pxq ¨ fpxq “ 0, i.e.,

E – x P R

n : ∇xV pxq ¨ fpxq “ 0(,

and let M be the largest invariant set for the system (13.3) that is fully contained in E . Then every Note. A set M is said to be invari-ant for the system (13.3) if everytrajectory that starts inside M willremain inside this set forever.

solution to (13.3) approaches M as t Ñ 8. In case M only contains the origin, the origin is globally

asymptotically stable for the system (13.3).

The condition (iv)’ that appeared in Section (iv), requires that any solution xptq that stays inside theset E forever, must necessarily be the identically zero [see equation (13.6)]. This means that the setM can only contain the origin, because otherwise there would be another solution xptq that wouldstart inside M Ă E and stay inside this set forever. 2

13.7 Exercises

13.2. For the following systems, show that the origin is asymptotically stable using the Lyapunovfunction provided.

#9x “ ´x ` y ´ xy2

9y “ ´x ´ y ´ x2yV px, yq “ x2 ` y2 (13.17)

#9x “ ´x3 ` y4

9y “ ´y3px ` 1q V px, yq “ x2 ` y2 (13.18)

#9x “ ´x ` 4y

9y “ ´x ´ y3V px, yq “ x2 ` 4y2 (13.19)

#9x “ x ` 4y

9y “ ´2x ´ 5yV px, yq “ ax2 ` bxy ` cy2 (13.20)

For the last system, determine possible values for the constants a, b, and c (recall that V must bepositive definite). 2

13.3. For the following systems, show that the origin is asymptotically stable using the Lyapunovfunction provided.

#9x “ y

9y “ ´x ´ yV px, yq “ x2 ` y2 (13.21)

#9x “ y

9y “ ´y|y| ´ 3xV px, yq “ ax2 ` by2 (13.22)

For the last system, determine possible values for the constants a and b (recall that V must bepositive definite). 2

13.4. Consider the hovercraft model in Example 12.3. Show that if the generalized force vector isset to F “ ´q, then the origin is globally asymptotically stable. 2

Page 132: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

126 João P. Hespanha

Page 133: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

Chapter 14

Lyapunov-based Designs

Contents

14.1 Lyapunov-based Controllers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12714.2 Application to Mechanical Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12814.3 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129

14.1 Lyapunov-based Controllers

In Lyapunov-based designs one starts by selecting a candidate Lyapunov function and then choosesthe control signal for which the chosen Lyapunov function does indeed decrease along the trajectoriesof the closed-loop system.

To understand how this can be done, consider again the vehicle shown in Figure 12.1 with unitschosen so that all constant coefficient are numerically equal to 1

:y “ ´ 9y| 9y| ´ 1 ` u

and suppose we want y to converge to some constant reference value r . Defining the tracking errore – y ´ r , we conclude that

:e “ ´ 9e| 9e| ´ 1 ` u.

Setting the state

x “„x1

x2

„e9e

the dynamics of the system can be written as 9x “ fpx, uq as follows:

9x1 “ x2 (14.1)

9x2 “ ´x2|x2| ´ 1 ` u, (14.2)

and we would like to make the origin globally asymptotically stable.

In view of what we saw for the Liénard equation, we will try to make Note. Compare with equation(13.14). Essentially, we areaiming for λpx2q – x2 , which

would lead to Λpx1q “ λx212 .

We will find other options inExercise 14.1. p. 129

V pxq –x2

2

2` λ

x21

2, λ ą 0

a Lyapunov function for the system by appropriate choice of u. This function satisfies the requirements(i)–(iii) and

∇xV pxq ¨ fpx, uq “ x2 9x2 ` λx1 9x1 “ ´x22 |x2| ` x2p´1 ` u ` λx1q.

127

Page 134: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

128 João P. Hespanha

A simple way to make the system Lyapunov stable is then to select

´1 ` u ` λx1 “ 0 ô u “ 1 ´ λx1 “ 1 ´ λpy ´ rq,

which leads to

∇xV pxq ¨ fpx, uq “ ´x22 |x2|,

and therefore the candidate V pxq becomes a weak Lyapunov function for the closed-loop:

9x1 “ x2,

9x2 “ ´x2|x2| ´ 1 ` upx1q “ ´x2|x2| ´ λx1.

Attention! A feedback linearization controller for (14.2) would cancel both the nonlinearity ´x2|x2|and the ´1 terms, using a controller of the form

upx1, x2q “ 1 ` x2|x2| ´ KPx1 ´ KDx2, KP , KD ą 0.

However, in the presence of measurement noise this would lead to the following closed-loop system

9x1 “ x2

9x2 “ ´x2|x2| ´ 1 ` upx1 ` n1, x2 ` n2q “ ´KPx1 ´ KDx2 ` d

where d is due to the noise and is equal to

d – ´KPn1 ´ KDn2 ´ x2|x2| ` x2|x2 ` n2| ` n2|x2 ` n2|.

The main difficulty with this controller is that n2 appears in d multiplied by x2 so even with littlenoise, d can be large if x2 is large.

Consider now the Lyapunov-based controllerNote. This controller does not at-tempt to cancel the term x2|x2|that actually helps in making 9V ă0.

upx1q “ 1 ´ λx1

also in the presence of noise:

9x1 “ x2

9x2 “ ´x2|x2| ´ 1 ` upx1 ` n1q “ ´x2|x2| ´ λx1 ` d, d “ ´λn1.

This controller is not affected at all by noise in the measurement of x2 “ 9y and the noise in themeasurement of x1 “ y ´ r is not multiplied by the state. 2

14.2 Application to Mechanical Systems

Consider again a fully actuated mechanical system of the following form

Mpqq:q ` Bpq, 9qq 9q ` Gpqq “ u (14.3)

and suppose that we want to make q converge to some constant value r . Defining

x “„x1

x2

„q ´ r

9q

P R

2k ,

the system (14.3) can be written as 9x “ fpx, uq as follows:

9x1 “ x2,

9x2 “ ´Mpx1 ` rq´1´

Bpx1 ` r, x2qx2 ` Gpx1 ` rq ´ u¯

.

Page 135: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

Nonlinear Control 129

Based on what we saw in Section 13.5, we will try to make Note. Compare this V pxq withequation (13.16). p. 124

V pxq –1

2x 1

2Mpx1 ` rqx2 ` γ1

2x 1

1x1, γ1 ą 0

a Lyapunov function for the system by appropriate choice of u. This function satisfies the requirements(i)–(iii) and

∇xV pxq ¨ fpxq “ x 12Mpx1 ` rq 9x2 ` 1

2x 1

2

´dMpx1 ` rqdt

¯x2 ` γ1 9x 1

1x1

“ ´x 12

´Bpx1 ` r, x2qx2 ´ 1

2

dMpx1 ` rqdt

x2 ` Gpx1 ` rq ´ u ´ γ1x1

¯.

Since in general x 12Bpx1 ` r, x2qx2 ď 0, a simple way to make the system Lyapunov stable is to select

´ 1

2

dMpx1 ` rqdt

x2 ` Gpx1 ` rq ´ u ´ γ1x1 “ γ2x2

ô u “ ´1

2

dMpx1 ` rqdt

x2 ` Gpx1 ` rq ´ γ1x1 ´ γ2x2

“ ´1

2

dMpqqdt

9q ` Gpqq ´ γ1pq ´ rq ´ γ2 9q,

which leads to

∇xV pxq ¨ fpxq “ ´x 12Bpx1 ` r, x2qx2 ´ γ2x

12x2.

and therefore the candidate V pxq becomes a weak Lyapunov function for the closed-loop.

Attention! For several mechanical system

x 12

´Bpx1 ` r, x2qx2 ´ 1

2

dMpx1 ` rqdt

¯x2 ě 0.

For those systems it suffices to select

Gpx1 ` rq ´ u ´ γ1x1 “ γ2x2 ô u “ Gpx1 ` rq ´ γ1x1 ´ γ2x2 (14.4)

“ Gpqq ´ γ1pq ´ rq ´ γ2 9q,

which leads to

∇xV pxq ¨ fpxq “ ´x 12

´Bpx1 ` r, x2qx2 ´ 1

2

dMpx1 ` rqdt

¯x2 ´ x 1

2Bpx1 ` r, x2qx2 ´ γ2x12x2

ď ´γ2x12x2. 2

The controller (14.4) corresponds to the control architecture shown in Figure 14.1. This controllerresembles the feedback linearization controller in Figure 12.2, with the key difference that now thegravity term is cancelled, but not the friction term. 2

14.3 Exercises

14.1. Design a controller for the system (14.2) using the following candidate Lyapunov function

V pxq –x2

2

2` λx1 arctanpx1q, λ ą 0.

What is the maximum value of u that this controller requires? Can you see an advantage of usingthis controller with respect to the one derived before? 2

Page 136: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

130 João P. Hespanha

`

`

´

´

uq

9q

rγ1p¨q

γ2

Gp¨q

Process

Figure 14.1. Control architectrure corresponding to the Lyapunov-based controller in (14.4).

14.2. Consider again system (14.2) and the following candidate Lyapunov function

V pxq –x2

2

2` λx1 arctanpx1q, λ ą 0.

Find a Lyapunov-based control law upx1, x2q that keeps

∇xV pxq ¨ fpx, uq ď ´x22 |x2|,

always using the u with smallest possible norm. This type of controller is called a point-wise

min-norm controller and is generally very robust with respect to process uncertainty. 2

14.3. Design a Lyapunov based controller for the inverted pendulum considered in Exercise 12.2 andcompare its noise rejection properties with the feedback linearization controller previously designed.

2

14.4. Re-design the controller in Exercise 14.3 to make sure that the control signal always remainsbounded. Investigate its noise rejection properties.

Hint: Draw inspiration from Exercises 14.1 and 14.2. 2

Page 137: Topics in Undergraduate Control Systems Designmotion.me.ucsb.edu/ME106A-Spring2013/handouts/lecturenotes-jph-9... · 2.6 Exercises ... and impulse/step/frequency responses ... and

Bibliography

[1] R. Adrain. Research concerning the probabilities of the errors which happen in making observa-tions. The Analyst, I:93–109, 1808. Article XIV.

[2] J. J. Craig. Introduction to Robotics Mechanics and Control. Addison Wesley, Reading, MA, 1986.

[3] L. Cremean, W. Dumbar, D. van Gogh, J. Hickey, E. Klavins, J. Meltzer, and R. Murray. TheCaltech multi-vehicle wireless testbed. In Proc. of the 41st Conf. on Decision and Contr., Dec.2002.

[4] G. E. Dullerud and F. Paganini. A Course in Robust Control Theory. Number 36 in Texts inApplied Mathematics. Springer, New York, 1999.

[5] G. F. Franklin, J. D. Powell, and A. Emami-Naeini. Feedback Control of Dynamic Systems.Prentice Hall, Upper Saddle River, NJ, 4th edition, 2002.

[6] C. F. Gauss. Theoria motus corporum coelestium in sectionibus conicis solem ambientum (thetheory of the motion of heavenly bodies moving around the sun in conic sections). Hamburg,Germany, 1809. URL http://134.76.163.65/agora_docs/137784TABLE_OF_CONTENTS.

html.

[7] B. Hayes. Science on the farther shore. American Scientist, 90(6):499–502, Nov. 2002.

[8] J. P. Hespanha. Linear Systems Theory. Princeton Press, Princeton, New Jersey, Sept. 2009.ISBN13: 978-0-691-14021-6. Information about the book, an errata, and exercises are availableat http://www.ece.ucsb.edu/~hespanha/linearsystems/.

[9] H. K. Khalil. Nonlinear Systems. Prentice Hall, Englewood Cliffs, NJ, 3rd edition, 2002.

[10] L. Ljung. System Identification: Theory for the user. Information and System Sciences Series.Prentice Hall, Upper Saddle River, NJ, 2nd edition, 1999.

[11] R. A. Serway and R. J. Beichner. Physics for Scientists and Engineers. Brooks Cole, 5th edition,1999.

[12] J. V. Vegte. Feedback Control Systems. Prentice Hall, Englewood Cliffs, NJ, 3rd edition, 1994.

[13] K. Zhou, J. C. Doyle, and K. Glover. Robust and Optimal Control. Prentice Hall, EnglewoodCliffs, NJ, 1996.

131