Topic #7 16.31 Feedback Control State-Space Systems What are state-space models? Why should we use them? How are they related to the transfer functions used in classical control design and how do we develop a state-space model? What are the basic properties of a state-space model, and how do we analyze these? Copyright 2001 by Jonathan How. 1 Fall 2001 16.31 7—1 Introduction State space model: a representation of the dynamics of an N th order system as a first order di?erential equation in an N-vector, which is called the state. — Convert the N th order di?erential equation that governs the dy- namics into N first-order di?erential equations Classic example: second order mass-spring system m¨p+c ˙p+kp = F — Let x 1 = p,thenx 2 = ˙p = ˙x 1 ,and ¨x 2 =¨p =(F ?c˙p?kp)/m =(F ?cx 2 ?kx 1 )/m ? ? ? ? ˙p ¨p ? ? ? = ? ? ? 0 1 ?k/m ?c/m ? ? ? ? ? ? p ˙p ? ? ? + ? ? ? 0 1/m ? ? ? u — Let u = F and introduce the state x = ? ? ? x 1 x 2 ? ? ? = ? ? ? p ˙p ? ? ? ? ˙x = Ax+Bu — If the measured output of the system is the position, then we have that y = p = ? 1 0 ? ? ? ? p ˙p ? ? ? = ? 1 0 ? ? ? ? x 1 x 2 ? ? ? = cx Fall 2001 16.31 7—2 The most general continuous-time linear dynamical system has form ˙x(t)=A(t)x(t)+B(t)u(t) y(t)=C(t)x(t)+D(t)u(t) where: — t ∈ R denotes time — x(t) ∈ R n is the state (vector) — u(t) ∈ R m is the input or control — y(t) ∈ R p is the output — A(t) ∈ R n×n is the dynamics matrix — B(t) ∈ R n×m is the input matrix — C(t) ∈ R p×n is the output or sensor matrix — D(t) ∈ R p×m is the feedthrough matrix Note that the plant dynamics can be time-varying. Also note that this is a MIMO system. We will typically deal with the time-invariant case ? Linear Time-Invariant (LTI) state dynamics ˙x(t)=Ax(t)+Bu(t) y(t)=Cx(t)+Du(t) so that now A,B,C,D are constant and do not depend on t. Fall 2001 16.31 7—3 Basic Definitions Linearity — What is a linear dynamical system? A system G is linear with respect to its inputs and output u(t) → G(s) → y(t) if superposition?holds: G(α 1 u 1 + α 2 u 2 )=α 1 Gu 1 + α 2 Gu 2 So if y 1 is the response of G to u 1 (y 1 = Gu 1 ), and y 2 is the response of G to u 2 (y 2 = Gu 2 ), then the response to α 1 u 1 + α 2 u 2 is α 1 y 1 + α 2 y 2 Asystemissaidtobetime-invariant if the relationship between the input and output is independent of time. So if the response to u(t)isy(t), then the response to u(t?t 0 )isy(t?t 0 ) x(t)iscalledthestate of the system at t because: — Future output depends only on current state and future input — Future output depends on past input only through current state — State summarizes e?ect of past inputs on future output — like the memory of the system Example: Rechargeable flashlight — the state is the current state of charge of the battery. If you know that state, then you do not need to know how that level of charge was achieved (assuming a perfect battery) to predict the future performance of the flashlight. Fall 2001 16.31 7—4 Creating Linear State-Space Models Most easily created from N th order di?erential equations that de- scribe the dynamics — This was the case done before. — Only issue is which set of states to use — there are many choices. Can be developed from transfer function model as well. — Much more on this later Problem is that we have restricted ourselves here to linear state space models, and almost all systems are nonlinear in real-life. — Can develop linear models from nonlinear system dynamics Fall 2001 16.31 7—5 Linearization Often have a nonlinear set of dynamics given by ˙x = f(x,u) where x is once gain the state vector, u is the vector of inputs, and f(·,·) is a nonlinear vector function that describes the dynamics Example: simple spring. With a mass at the end of a linear spring (rate k)wehavethedynamics m¨x = kx but with a “leaf spring” as is used on car suspensions, we have a nonlinear spring — the more it deflects, the sti?er it gets. Good model now is m¨x =(k 1 x +k 2 x 3 ) which is a “cubic spring”. — Restoring force depends on the deflection x in a nonlinear way. 0 2 4 6 8 10 12 ?2 ?1 0 1 2 X Time Nonlinear Linear 0 2 4 6 8 10 12 ?3 ?2 ?1 0 1 2 3 V Time Nonlinear Linear Figure 1: Response to linear k and nonlinear (k 1 =0,k 2 = k) springs (code at the end) Fall 2001 16.31 7—6 Typically assume that the system is operating about some nominal state solution x 0 (t) (possibly requires a nominal input u 0 (t)) — Then write the actual state as x(t)=x 0 (t)+δx(t) and the actual inputs as u(t)=u 0 (t)+δu(t) — The “δ” is included to denote the fact that we expect the varia- tions about the nominal to be “small” Can then develop the linearized equations by using the Taylor series expansion of f(·,·)aboutx 0 (t)andu 0 (t). Recall the vector equation ˙x = f(x,u), each equation of which ˙x i = f i (x,u) canbeexpandedas d dt (x 0 i + δx i )=f i (x 0 + δx,u 0 + δu) ≈ f i (x 0 ,u 0 )+ ?f i ?x ˉ ˉ ˉ ˉ ˉ ˉ 0 δx + ?f i ?u ˉ ˉ ˉ ˉ ˉ ˉ 0 δu where ?f i ?x = ? ? ?f i ?x 1 ··· ?f i ?x n ? ? and ·| 0 means that we should evaluate the function at the nominal values of x 0 and u 0 . The meaning of “small” deviations now clear — the variations in δx and δu must be small enough that we can ignore the higher order terms in the Taylor expansion of f(x,u). Fall 2001 16.31 7—7 Since d dt x 0 i = f i (x 0 ,u 0 ), we thus have that d dt (δx i ) ≈ ?f i ?x ˉ ˉ ˉ ˉ ˉ ˉ 0 δx + ?f i ?u ˉ ˉ ˉ ˉ ˉ ˉ 0 δu Combining for all n state equations, gives (note that we also set “≈” → “=”) that d dt δx = ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?f 1 ?x ˉ ˉ ˉ ˉ ˉ ˉ 0 ?f 2 ?x ˉ ˉ ˉ ˉ ˉ ˉ 0 . . . ?f n ?x ˉ ˉ ˉ ˉ ˉ ˉ 0 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? δx+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?f 1 ?u ˉ ˉ ˉ ˉ ˉ ˉ 0 ?f 2 ?u ˉ ˉ ˉ ˉ ˉ ˉ 0 . . . ?f n ?u ˉ ˉ ˉ ˉ ˉ ˉ 0 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? δu = A(t)δx+B(t)δu where A(t) ≡ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?f 1 ?x 1 ?f 1 ?x 2 ··· ?f 1 ?x n ?f 2 ?x 1 ?f 2 ?x 2 ··· ?f 2 ?x n . . . ?f n ?x 1 ?f n ?x 2 ··· ?f n ?x n ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0 and B(t) ≡ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?f 1 ?u 1 ?f 1 ?u 2 ··· ?f 1 ?u m ?f 2 ?u 1 ?f 2 ?u 2 ··· ?f 2 ?u m . . . ?f n ?u 1 ?f n ?u 2 ··· ?f n ?u m ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0 Fall 2001 16.31 7—8 Similarly, if the nonlinear measurement equation is y = g(x,u), can show that, if y(t)=y 0 + δy,then δy = ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?g 1 ?x ˉ ˉ ˉ ˉ ˉ ˉ 0 ?g 2 ?x ˉ ˉ ˉ ˉ ˉ ˉ 0 . . . ?g p ?x ˉ ˉ ˉ ˉ ˉ ˉ 0 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? δx+ ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?g 1 ?u ˉ ˉ ˉ ˉ ˉ ˉ 0 ?g 2 ?u ˉ ˉ ˉ ˉ ˉ ˉ 0 . . . ?g p ?u ˉ ˉ ˉ ˉ ˉ ˉ 0 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? δu = C(t)δx +D(t)δu Typically think of these nominal conditions x 0 , u 0 as “set points” or “operating points” for the nonlinear system. The equations d dt δx = A(t)δx +B(t)δu δy = C(t)δx+ D(t)δu then give us a linearized model of the system dynamic behavior about these operating/set points. Note that if x 0 , u 0 are constants, then the partial fractions in the expressions for A—D are all constant → LTI linearized model. One particularly important set of operating points are the equilib- rium points of the system. Defined as the states & control input combinations for which ˙x = f(x 0 ,u 0 ) ≡ 0 provides n algebraic equations to find the equilibrium points. Fall 2001 16.31 7—9 Example Consider the nonlinear spring with (set m = 1) ¨y = k 1 y +k 2 y 3 gives us the nonlinear model (x 1 = y and x 2 = ˙y) d dt ? ? ? y ˙y ? ? ? = ? ? ? ˙y k 1 y +k 2 y 3 ? ? ? ? ˙x = f(x) Find the equilibrium points and then make a state space model For the equilibrium points, we must solve f(x)= ? ? ? ˙y k 1 y +k 2 y 3 ? ? ? =0 which gives ˙y 0 =0 and k 1 y 0 +k 2 (y 0 ) 3 =0 — Second condition corresponds to y 0 =0ory 0 = ± r ?k 1 /k 2 , whichisonlyrealifk 1 and k 2 areoppositesigns. For the state space model, A = ? ? ? ? ? ? ? ? ? ? ?f 1 ?x 1 ?f 1 ?x 2 ?f 2 ?x 1 ?f 2 ?x 2 ? ? ? ? ? ? ? ? ? ? 0 = ? ? ? ? ? ? 0 1 k 1 +3k 2 (y) 2 0 ? ? ? ? ? ? 0 = ? ? ? ? ? ? 0 1 k 1 +3k 2 (y 0 ) 2 0 ? ? ? ? ? ? and the linearized model is ˙ δx = Aδx Fall 2001 16.31 7—10 For the equilibrium point y =0, ˙y =0 A 0 = ? ? ? ? ? ? 0 1 k 1 0 ? ? ? ? ? ? which are the standard dynamics of a system with just a linear spring of sti?ness k 1 — Stable motion about y =0ifk 1 < 0 Assume that k 1 = 1, k 2 = ?1/2, then we should get an equilibrium point at ˙y =0,y = ± √ 2, and since k 1 +k 2 (y 0 ) 2 =0 A 1 = ? ? ? ? ? ? 0 1 ?2k 1 0 ? ? ? ? ? ? = ? ? ? ? ? ? 0 1 ?20 ? ? ? ? ? ? are the dynamics of a stable oscillator about the equilibrium point — Will explore this in detail later 0 5 10 15 20 25 30 35 1.3 1.35 1.4 1.45 1.5 y Time 0 5 10 15 20 25 30 35 ?0.1 ?0.05 0 0.05 0.1 dy/dt Time 1.34 1.36 1.38 1.4 1.42 1.44 1.46 1.48 1.5 ?0.1 ?0.08 ?0.06 ?0.04 ?0.02 0 0.02 0.04 0.06 0.08 0.1 y dy/dt Figure 2: Nonlinear response (k 1 =1,k 2 = ?.5). The figure on the right shows the oscillation about the equilibrium point. Fall 2001 16.31 7—11 Linearized Nonlinear Dynamics Usuallyinpracticewedropthe“δ”astheyarerathercumbersome, and (abusing notation) we write the state equations as: ˙x(t)=A(t)x(t)+B(t)u(t) y(t)=C(t)x(t)+D(t)u(t) which is of the same form as the previous linear models Fall 2001 16.31 7—12 Example: Aircraft Dynamics Assumptions: 1. Earth is an inertial reference frame 2. A/C is a rigid body 3. Body frame B fixed to the aircraft ( ~ i, ~ j, ~ k) The basic dynamics are: ~ F = m ˙ ~v c I and ~ T = ˙ ~ H I ? 1 m ~ F = ˙ ~v c B + BI ~ω ×~v c Transport Thm. ? ~ T = ˙ ~ H B + BI ~ω × ~ H Instantaneous mapping of ~v c and BI ~ω into the body frame is given by BI ~ω = P ~ i +Q ~ j + R ~ k~v c = U ~ i +V ~ j + W ~ k ? BI ω B = ? ? ? ? ? ? ? P Q R ? ? ? ? ? ? ? ? (v c ) B = ? ? ? ? ? ? ? U V W ? ? ? ? ? ? ? Fall 2001 16.31 7—13 The overall equations of motion are then: 1 m ~ F = ˙ ~v c B + BI ~ω ×~v c ? 1 m ? ? ? ? ? ? ? F x F y F z ? ? ? ? ? ? ? = ? ? ? ? ? ? ? ˙ U ˙ V ˙ W ? ? ? ? ? ? ? + ? ? ? ? ? ? ? 0 ?RQ R 0 ?P ?QP 0 ? ? ? ? ? ? ? ? ? ? ? ? ? ? U V W ? ? ? ? ? ? ? = ? ? ? ? ? ? ? ˙ U + QW ?RV ˙ V +RU ?PW ˙ W +PV ?QU ? ? ? ? ? ? ? These are clearly nonlinear — need to linearize about the equilibrium states. To find suitable equilibrium conditions, must solve 1 m ? ? ? ? ? ? ? F x F y F z ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? +QW ?RV +RU ?PW +PV ?QU ? ? ? ? ? ? ? =0 Assume steady state flight conditions with ˙ P = ˙ Q = ˙ R =0 Fall 2001 16.31 7—14 Define the trim angular rates, velocities, and Forces BI ω o B = ? ? ? ? ? ? ? P Q R ? ? ? ? ? ? ? (v c ) o B = ? ? ? ? ? ? ? U o 0 0 ? ? ? ? ? ? ? F o B = ? ? ? ? ? ? ? F o x F o y F o z ? ? ? ? ? ? ? that are associated with the flight condition (they define the type of equilibrium motion that we analyze about). Note: — W 0 = 0 since we are using the stability axes, and — V 0 = 0 because we are assuming symmetric flight Can now linearize the equations about this flight mode. To proceed, define Velocities U 0 ,U= U 0 +u ? ˙ U = ˙u W 0 =0,W= w ? ˙ W = ˙w V 0 =0,V= v ? ˙ V = ˙v Angular Rates P 0 =0,P= p ? ˙ P = ˙p Q 0 =0,Q= q ? ˙ Q = ˙q R 0 =0,R= r ? ˙ R = ˙r Angles Θ 0 , Θ = Θ 0 + θ ? ˙ Θ = ˙ θ Φ 0 =0, Φ = φ ? ˙ Φ = ˙ φ Ψ 0 =0, Ψ = ψ ? ˙ Ψ = ˙ ψ Fall 2001 16.31 7—15 Linearization for symmetric flight U = U 0 +u, V 0 = W 0 =0,P 0 = Q 0 = R 0 =0. Note that the forces and moments are also perturbed. 1 m ? F 0 x +?F x ? = ˙ U +QW ?RV ≈ ˙u +qw?rv ≈ ˙u 1 m ? F 0 y +?F y ? = ˙ V +RU ?PW ≈ ˙v +r(U 0 +u)?pw ≈ ˙v +rU 0 1 m ? F 0 z +?F z ? = ˙ W +PV ?QU ≈ ˙w +pv?q(U 0 +u) ≈ ˙w?qU 0 ? 1 m ? ? ? ? ? ? ? ?F x ?F y ?F z ? ? ? ? ? ? ? = ? ? ? ? ? ? ? ˙u ˙v + rU 0 ˙w?qU 0 ? ? ? ? ? ? ? Which gives the linearized dynamics for the aircraft motion about the steady-state flight condition. — Need to analyze the perturbations to the forces and moments to fully understand the linearized dynamics — take 16.61 — Can do same thing for the rotational dynamics. Fall 2001 16.31 7—16 % save this entire code as plant.m % function [xdot] = plant(t,x) global n xdot(1) = x(2); xdot(2) = -3*(x(1))^n; xdot = xdot’; return % the use this part of the code in Matlab % to call_plant.m global n n=3; %nonlinear x0 = [-1 2]; % initial condition [T,x]=ode23(’plant’, [0 12], x0); %simulate NL equations for 12 sec n=1; % linear [T1,x1]=ode23(’plant’, [0 12], x0); subplot(211) plot(T,x(:,1),T1,x1(:,1),’--’); legend(’Nonlinear’,’Linear’) ylabel(’X’) xlabel(’Time’) subplot(212) plot(T,x(:,2),T1,x1(:,2),’--’); legend(’Nonlinear’,’Linear’) ylabel(’V’) xlabel(’Time’)