CDT Autonomous and Intelligent Machines & Systems Introduction to Modern Control MT 2016 Alessandro Abate
Lecture 2 First-order ordinary differential equations (ODE) Solution of a linear ODE Hints to nonlinear case and linearization procedure From continuous to discrete time: simulation of an ODE From state-space models to frequency domain: Transfer functions Alessandro Abate 1
Linear Ordinary Differential Equations (Linear ODE) Recall dynamical model for spring-damper system: q(t) = 1 m ( c( q(t)) kq(t) + u(t)) We ve seen it can be formulated as: { ẋ1 (t) = x 2 (t) ẋ 2 (t) = 1 m ( c(x 2(t)) kx 1 (t) + u(t)) Introduce linear approximation of nonlinear term (e.g., arctan): c(x 2 (t)) c x 2 (t) Consider output equation: y(t) = x 1 (t) Alessandro Abate 2
Consider state vector [ x1 (t) x 2 (t) ] Obtain state-space representation as linear ODE: d dt [ ] [ ] [ x1 (t) 0 1 x1 (t) = x 2 (t) k m c x m 2 (t) y(t) = [ 1 0 ] [ ] x 1 (t) x 2 (t) ] + [ 0 1 m ] u(t) if u(t) 0, t 0, ODE is said to be autonomous model is time-invariant: the behavior does not change under time-shifts (we thus usually pick initial time to be equal to 0) Alessandro Abate 3
General State-Space Model for Linear ODE Linear ODE in standard state-space form: x(t) R n, state variable u(t) R m, input variable y(t) R l, output variable d dt x(t) = Ax(t) + Bu(t), x(0) = x 0 y(t) = Cx(t) + Du(t) Dimensions of x, u, y dimensions (A, B, C, D) Alessandro Abate 4
General Model for Linear ODE: comments We shall often consider SISO systems (m = l = 1) Each integrator output is state variable One initial condition needed for each state variable ss structures Control System Toolbox of MATLAB Use of Simulink to represent these models Alessandro Abate 5
Block Diagram for Single Model (linear ODE) Linear system in state-space form 8 x 0 x(t) y(t) u(t) B + + C + + A D Each integrator output is state variable One d initial condition needed for each state variable dt x(t) = Ax(t) + Bu(t), x(0) = x 0 y(t) = Cx(t) + Du(t) Alessandro Abate 6
Block-Diagrams The block-diagram is obtained by interconnecting individual blocks (by The block-diagram is obtained by interconnecting individual blocks (by equating signals). Hence such diagrams (should) always correspond in equating signals). Hence such diagrams (should) always correspond in a precise fashion to algebraic equations. a precise fashion to algebraic equations. Block Diagrams for Models Interconnection Generic examples Generic examples inseries series interconnection: Series interconnection: u 1 y ẋ 1 = f(x 1,u 1 ẋ 2 2 = f(x 2,u ) ẋ 1 = f(x y 1 = h(x 1,u 1,u 1 ) ẋ 1 y 2 = f(x 2 = h(x 2,u 2,u 2 ) 2 ) u 1 y 2 y 1 = h(x 1,u 1 ) y 2 = h(x 2,u 2 ) Parallel interconnection: inparallel parallel interconnection: u u ẋ 1 y ẋ 1 1 y 1 ẋ 2 y 2 ẋ 2 y 2 = f(x 1,u) = h(x 1,u) = f(x 1,u) = h(x 1,u) = f(x 2,u) = h(x 2,u) = f(x 2,u) = h(x 2,u) + + y y 41/44 41/44 And of course in feedback (as discussed in previous lecture) Alessandro Abate 7
From high-order ODE to system of first order ODE Leitmotif of previous examples: exploit theory of first-order ODE Consider n-th order system: d n y dt n + a d n 1 y 1 dt n 1 +... + a ny = u Introduce variables: x 1 = d n 1 y/dt n 1, x 2 = d n 2 y/dt n 2,..., x n = y x 1 a 1 x 1 a 2 x 2... a n x n u d x 2 dt. x n 1 = x 1. x n 2 + 0. 0 x n x n 1 0 n-dim system of first-order ODE non-uniqueness of construction Alessandro Abate 8
More on Linearization: From Nonlinear to Linear ODE Recall model for Inverted Pendulum (Balance System, Segway) 36 CHAPTER 2. SYSTEM MODELING m θ l F M p (b) Saturn rocket (c) Cart pendulum system tems. (a) Segway Personal Transporter, (b) Saturn rocket and (c) art. Each of these examples uses forces at the bottom of the system Alessandro Abate (a) Segway (b) Saturn rock Figure 2.5: Balance systems. (a) Segway Pers inverted pendulum on a cart. Each of these exam to keep it upright. 9 a generalization of the spring mass system we saw earlier. ics for a mechanical system in the general form M(q)q + C(q, q ) + K (q) = B(q)u, Balance systems are a generalization of
More on Linearization: From Nonlinear to Linear ODE Overall state q = (p, θ), input u = F, output y = (p, θ) Can write dynamics as: M(q) q + K(q, q) = Bu It is often of interest to work around (equilibrium) point θ 0 sin θ θ, cos θ 1, θ 2 = o( θ) (exercise session will discuss details of linearisation) Alessandro Abate 10
Solution to Autonomous ODE Let us focus on the dynamical (autonomous) part of the ODE: d dt x(t) = Ax(t), x(0) = x 0 has solution where x(t) = e At x 0, (1) e At := I + At + A 2t2 2! + A3t3 3! +... Alessandro Abate 11
Matrix exponential: Moler and Van Loan, Nineteen Dubious Ways to Compute the Exponential of a Matrix, SIAM Review 20, 1978, pp. 801-836. Use of expm function in MATLAB Proof of (1): check if putative solution satisfies ODE, and i.c.: d dt x(t) = d dt ( e At x 0 ) = A(...), x(0) = x0 Assume A R n,n is diagonal, A = λ 1 0 0 λ 2.... 0 0 λ n Alessandro Abate 12
Then i = 1,..., n, x i (t) = e λ it x 0,i x(t) = What if A is not diagonal? e λ 1t 0 0 e λ 2t.... 0 0 e λ nt x 0 State coordinate change via similarity transformation z = T x (T invertible n n) ż = T AT 1 z Ideal situation: T AT 1 is diagonal Procedure: study z-model, to derive properties for x-model Condition: A diagonalizable in MATLAB, command eig Alessandro Abate 13
Sufficient condition: A has distinct eigenvalues What if A is not diagonalizable? (e.g.: A has eigenvalues with multiplicity) For any A, existence of a Jordan form in MATLAB, command jordan Alessandro Abate 14
Transformation of state equations (state coordinate change) z = T x (T invertible n n) similarity transformation State space representation becomes ẋ = Ax + Bu, ż = T AT 1 z + T Bu, y = Cx + Du y = CT 1 z + Du (we will see shortly) two systems related by a similarity transformation have same I/O response CT 1 e T AT 1t T Bu(t) = Ce At Bu(t) Alessandro Abate 15
Eigenvalues and Dynamical Modes Importance of the eigenvalues of state matrix A: they are the solution of characteristic polynomial: det (λi A) = 0 in MATLAB poly (A) Alessandro Abate 16
Solution to ODE with Input The controlled ODE d dt x(t) = Ax(t) + Bu(t), x(0) = x 0 (assuming A is invertible) has solution x(t) = e At [x 0 + = e At x 0 + t 0 ] e Aλ Bu(λ)dλ t e A(t λ) Bu(λ)dλ } 0 {{} convolution of u(t) and e At B Alessandro Abate 17
Sum of response to initial condition and to input signal: superposition principle, which comes from model linearity Additionally, the output part: y(t) = Cx(t) + Du(t) has solution y(t) = Ce At x 0 + t 0 Ce A(t λ) Bu(λ)dλ + Du(t) Extension to non-linear, time-varying case: use of state-transition matrix Φ(t) (not in this course) Alessandro Abate 18
Impulse Response Assume for simplicity x 0 = 0. Impulse on (1-d) input u(t) = δ(t): y(t) = C t 0 e A(t λ) Bδ(λ)dλ + Dδ(t) = Ce At B + Dδ(t) 146 CHAPTER 5. LINEAR SYSTEMS Identification of system dynamics from data (recall end of Lec. 1): u 1.5 1 0.5 0 0 2 4 6 8 10 Time t (a) Pulse and impulse functions 1 y 0.5 Pulse responses Impulse response 0 0 10 20 30 40 t (b) Pulse and impulse responses Actually, LTI systems are completely characterized by impulse response Figure 5.6: Pulse response and impulse response. (a) The rectangles show pulses of width 5, 2.5 and 0.8, each with total area equal to 1. The arrow denotes an impulse δ(t) defined by equation (5.17). The corresponding pulse responses for a linear system with eigenvalues λ ={ 0.08, 0.62} are shown in (b) as dashed lines. The solid line is the true impulse response, which is well approximated by a pulse of duration 0.8. Alessandro Abate 19
Step Response - Transience and Steady State Step input (Heaviside function): u(t) = { 0, t = 0 1, t > 0 Assuming again x 0 = 0, we obtain y(t) = C t 0 e A(t λ) Bdλ + D = CA 1 e At B CA 1 B + D, t > 0 Presence of transient part, and steady-state term Alessandro Abate 20
Define controller specifications based on profile of step response Focus on dominant mode in model dynamics 5.3. INPUT/OUTPUT RESPONSE 151 2 1.5 Overshoot M p Output 1 0.5 Rise time T r Settling time T s Steady-state value y ss 0 0 5 10 15 20 25 30 Time [sec] Figure 5.9: Sample step response. The rise time, overshoot, settling time and steady-state value give the key performance properties of the signal. equilibrium point in the absence of any input), then we can rewrite the solution as Alessandro Abate 21 y(t) = CA } 1 {{ e At B} + } D CA {{ 1 B }, t > 0. (5.22) transient steady-state The first term is the transient response and decays to zero as t. The second
Features: A Note on Non-Linear ODE non-linear dynamics and observations non-autonomous time-varying d dt x(t) = f(t, x(t), u(t)), x(t 0) = x 0 y(t) = g(t, x(t), u(t)) existence of non-standard cases (non-existence or non-uniqueness of solution) will resort to local linearization Alessandro Abate 22
Integration of ODE: Discrete-Time Systems Consider a general ODE of the form ẋ(t) = f(x(t)), x(0) = x 0 Introduce integration time-step h, 0 < h < Approximate time-derivative ẋ(t) at time t 0 as ẋ(t) x(t + h) x(t) (t + h) t This yields x(t + h) x(t) + hf(x(t)) Alessandro Abate 23
The above is a forward-euler first-order integration scheme Obtain ordinary difference equation describing discrete-time system WARNING: Property disruption through sampling Can employ more complex schemes (higher-order, variable step-size) 42 CHAPTER 2. SYSTEM MODELING 2 Position q [m] 1 0 h = 1!1 h = 0.5 h = 0.1 analytical!2 0 5 10 15 20 25 30 35 40 45 50 Time t [sec] Figure 2.9: Simulation of the forced spring mass system with different simulation time constants. The dashed line represents the analytical solution. The solid lines represent the approximate solution via the method of Euler integration, using decreasing step sizes. Integration of ODE in MATLAB performed with functions ode23, ode45 h gets smaller, the computed solution converges to the exact solution. The form L.F. Shampine, of the solution Numerical is also worth noticing: Solution after anof initial Ordinary transient, the system Differential settles into a periodic motion. The portion of the response after the transient is called the Equations. steady-state Chapman response to & thehall, input. 1994 In addition to generating simulations, models can also be used to answer other types of questions. Two that are central to the methods described in this text concern Alessandro Abate the stability of an equilibrium point and the input/output frequency response. We illustrate these two computations through the examples below and return to the general computations in later chapters. Returning to the damped spring mass system, the equations of motion with no input forcing are given by 24
Transfer Functions and Frequency Domain Recall the block-diagram representation of dynamical models. Transfer Functions compactly represent the linear relationship between inputs and outputs of a system. As discussed, they can be easily constructed from measured data Start with a state-space representation ẋ = Ax + Bu, y = Cx + Du Consider inputs of the form u(t) = e st, s = σ + iω u(t) = e σt (cos ωt + i sin ωt) Solution is x(t) = e At x 0 + t 0 ea(t τ) Be sτ dτ = e At x 0 + e At t 0 e(si A)τ Bdτ If s λ(a) x(t) = e At x 0 + e At (si A) 1 ( e (si A)t I ) B Alessandro Abate 25
Thus, y(t) = Ce ( At x 0 (si A) 1 B ) + ( C(sI A) 1 B + D ) e st Consider steady-state term: let us call G yu (s) = C(sI A) 1 B + D the Transfer Function of the system: y(t) = G yu (s)u(t), u(t) = e st Notice that if s = λ i (A), G yu presents a singularity Alessandro Abate 26
Transfer Functions, example Consider canonical 2nd order system: q + 2ζω o q + ω 2 oq = kω 2 ou, y = q Can be re-written as: [ ] dx dt = 0 ω o x + ω o 2ζω o Assume ζ, ω o > 0 model is stable [ 0 kω o ] u, y = [1 0]x Steady-state response to u(t) = e st is C(sI A) 1 B: [1 0] ( si [ 0 ω o ω o 2ζω o ]) 1 [ 0 kω o ] = kω 2 o s 2 + 2ζω o s + ω 2 o Alessandro Abate 27
Transfer Functions, alternative derivation Consider integrable function f(t), f : R + R and s.t. f(t) < e s 0t Laplace transform L yields an F = Lf : C C, defined by F (s) = 0 e sτ f(τ)dτ, R(s) > s 0 Consider the system ẋ = Ax + Bu, y = Cx + Du Take Laplace transforms (with zero initial conditions): sx(s) = AX(s) + BU(s), Y (s) = CX(s) + DU(s) Substitute for X(s) to obtain: Y (s) = ( C(sI A) 1 B + D ) U(s) = G yu (s)u(s) Alessandro Abate 28