ControlDesign
ControllerObserver
determine the equations of the subsystem comprised of a state feedback controller and an observer
Calling Sequence
Parameters
Options
Description
Examples
ControllerObserver(sys, Kc, L, opts)
sys
-
System; system object
Kc
Matrix; state feedback gain
L
Matrix; observer gain
opts
(optional) equation(s) of the form option = value; specify options for the ControllerObserver command
Kr = Matrix or 0
Specify a feedforward gain Kr (reference input). If Kr = 0, there are no reference inputs r and the returned closed-loop system is autonomous if there are no measured_inputs or non-controlled inputs specified by the user. The default value is 0.
closedloop = true or false
True means calculate the closed-loop equations of the state feedback controller, observer, and plant. False means calculate the equations of the state-feedback controller and observer subsystem. The default is false.
stateerror = true or false
True means return a state vector with the original states x and the state errors xerr=x−xˆ (difference between each state and its estimate) in the closedloop case with outputtype = ss. False means express the closed-loop state-space equations in terms of the original states x and the state estimates xˆ. The default is false.
controlled_inputs = all or set(posint)
Specifies a subset of sys input indices that are controller outputs. The default is all. A controlled input uc cannot be specified as a measured input.
measured_inputs = none, all or set(posint)
Specifies a subset of sys input indices that are not controller outputs and are measured to be input to the observer. The default is none. A measured input um cannot be specified as a controlled input.
controlled_outputs = all or set(posint)
Specifies a subset of sys output indices that are regulated by the controller. The default is all. A controlled output yc may be specified as a measured output.
measured_outputs = all or set(posint)
Specifies a subset of sys output indices that are measured to be input to the observer. The default is all. A measured output ym may be specified as a controlled output.
augment_output = true or false
True means append the controlled_inputs to the output vector in the closedloop case. The default is false.
outputtype = tf, coeff, zpk, ss, or de
Determines the subtype of the returned system object. The default return type is based on the type of the system object specified in the sys parameter.
parameters = {list, set}(name = complexcons)
Specifies numeric values for the parameters of sys. These values override any parameters previously specified for sys. The numeric value on the right-hand side of each equation is substituted for the name on the left-hand side in the sys equations. The default is the value of sys given by DynamicSystems:-SystemOptions(parameters).
The ControllerObserver command calculates the equations of the subsystem comprised of a state feedback controller and an observer, where sys is the plant, Kc is the state feedback controller gain, and L is the observer gain. In the diagram below, this subsystem corresponds to the blocks enclosed in the solid-line box.
The closed-loop system equations of the state feedback controller, observer and plant can be obtained using the closedloop option. In the diagram below, the closed-loop system corresponds to the blocks enclosed in the dashed-line box.
When the option Kr is specified, the state feedback controller is governed by the control law uc=−Kc.xˆ+Kr.r, where xˆ is the estimated state vector, and r is the reference vector. The reference vector r contains a reference signal for each controlled output, yc_ref.
The system sys is a SISO (single input, single output) or MIMO (multiple input, multiple output) linear system object created using the DynamicSystems package. The system object can be of types: transfer function (TF), zero-pole-gain (ZPK), coefficients (Coeff), state-space (SS), and diff-equation (DE). It is assumed that the state feedback controller gains, Kc and Kr, are obtained using the sys representation obtained by DynamicSystems[StateSpace].
The ControllerObserver command returns a system object whose type is the same as the type of sys, unless the option outputtype is specified.
The controller-observer subsystem inputs are
the reference inputs r=yc_ref (when a non-zero Kr Matrix is specified)
the measured_inputs um
the measured_outputs ym (renamed y_meas)
The controller-observer outputs are
the controlled_inputs uc
The controller-observer states (in state-space) are
the estimated states xˆ (renamed x_est)
The closed-loop system inputs are
the non-controlled inputs unc (e.g. disturbances)
The closed-loop system outputs are
the controlled_outputs yc
the non-controlled outputs ync
the controlled_inputs uc (if augment_output = true)
The closed-loop system states (in state-space) are
the sys states x and
Or when stateerror = true
the state errors xerr=x−xˆ (renamed x_err).
with⁡ControlDesign:
with⁡DynamicSystems:
Example: State feedback control with observer of linear model for the steering of a vehicle with nonslipping wheels
The following second order system represents a linear model for the steering of a vehicle with nonslipping wheels:
sys1≔StateSpace⁡Matrix⁡0,1,0,0,Matrix⁡α,1,Matrix⁡1,0,Matrix⁡1,1:
PrintSystem⁡sys1
State Spacecontinuous1 output(s); 1 input(s); 2 state(s)inputvariable=u1⁡toutputvariable=y1⁡tstatevariable=x1⁡t,x2⁡ta=0100b=α1c=10d=0
Checking whether the system is observable with alpha = 1/2.
Observable⁡sys1,parameters=α=12
true
Defining the characteristic polynomial with damping ratio Z and natural frequency ω.
cp≔s2+2⁢Z⁢ω⁢s+ω2
cp≔2⁢Z⁢ω⁢s+ω2+s2
The corresponding poles are:
poles≔solve⁡cp,s
poles≔−Z+Z2−1⁢ω,−Z−Z2−1⁢ω
Designing the state feedback controller gains (Kc and Kr) by pole placement:
Kc1,Kr1≔StateFeedback:-PolePlacement⁡sys1,a,b,return_Kr:
Kc1≔simplify⁡eval⁡Kc1,a=poles1,b=poles2
Kc1≔ω2−ω2⁢α+2⁢ω⁢Z
Kr1≔simplify⁡eval⁡Kr1,a=poles1,b=poles2
Kr1≔ω2
Designing the state observer with gain L by pole placement as well.
L1≔StateObserver:-PolePlacement⁡sys1,a,b:
L1≔simplify⁡eval⁡L1,a=poles1,b=poles2
L1≔2⁢ω⁢Zω2
The controller-observer subsystem is obtained next. Note that the state, input, and output variables of the returned system object are renamed accordingly.
cosys1≔ControllerObserver⁡sys1,Kc1,L1,:-Kr=Kr1:
PrintSystem⁡cosys1
State Spacecontinuous1 output(s); 2 input(s); 2 state(s)inputvariable=y1_ref⁡t,y1_meas⁡toutputvariable=u1⁡tstatevariable=x1_est⁡t,x2_est⁡ta=−ω2⁢α−2⁢ω⁢Z1−α⁢−ω2⁢α+2⁢ω⁢Z−2⁢ω2ω2⁢α−2⁢ω⁢Zb=ω2⁢α2⁢ω⁢Zω2ω2c=−ω2ω2⁢α−2⁢ω⁢Zd=ω20
The closed-loop equations of the state feedback control system with observer are obtained using the closedloop = true option. Using stateerror = true, augment_output = true, and outputtype = de, we obtain the closed-loop equations of sys1 with state feedback controller with Kc and Kr gains and observer with gain L. The returned system object is a set of differential equations, where the differential variables are x1, x2, x1_err and x2_err, and the outputs are y1 and u1 (controller output).
clsys1≔ControllerObserver⁡sys1,Kc1,L1,:-Kr=Kr1,:-closedloop=true,:-stateerror=true,:-augment_output=true,:-outputtype=de:
PrintSystem⁡clsys1
Diff. Equationcontinuous2 output(s); 1 input(s)inputvariable=y1_ref⁡toutputvariable=y1⁡t,u1⁡tde={[ⅆⅆtx1⁡t={−ω2⁢α⁢x1⁡t+1−α⁢−ω2⁢α+2⁢ω⁢Z⁢x2⁡t +ω2⁢α⁢x1_err⁡t+α⁢−ω2⁢α+2⁢ω⁢Z⁢x2_err⁡t +ω2⁢α⁢y1_ref⁡t, ⅆⅆtx2⁡t={−ω2⁢x1⁡t+ω2⁢α−2⁢ω⁢Z⁢x2⁡t+ω2⁢x1_err⁡t −ω2⁢α+2⁢ω⁢Z⁢x2_err⁡t+ω2⁢y1_ref⁡t, ⅆⅆtx1_err⁡t=−2⁢ω⁢Z⁢x1_err⁡t+x2_err⁡t, ⅆⅆtx2_err⁡t=−ω2⁢x1_err⁡t, y1⁡t=x1⁡t, u1⁡t={−ω2⁢x1⁡t+ω2⁢α−2⁢ω⁢Z⁢x2⁡t+ω2⁢x1_err⁡t −ω2⁢α+2⁢ω⁢Z⁢x2_err⁡t+ω2⁢y1_ref⁡t]
Example: DC motor model state feedback control with observer
The following DC motor example demonstrates the use of the parameters, controlled_inputs, measured_inputs, controlled_outputs and measured_outputs options.
a2≔Matrix⁡−RL,−KL,0,KJ,−BJ,0,0,1,0:
b2≔Matrix⁡1L,0,0,0,−1J,0,0,0,−1:
c2≔Matrix⁡1,0,0,0,1,0,0,0,1:
d2≔Matrix⁡3,3:
The numeric values for the DC motor stator inductance L, stator resistance R, electromotive force (emf) constant K, rotor moment of inertia J, and damping ratio B are given next:
params≔B=0.1,J=0.01,K=0.01,L=0.5,R=1:
The input variables are the source voltage V⁡t, the torque load T⁡t and the rotor angular speed reference wref⁡t, and the output variables are the stator current i⁡t, the rotor angular speed w⁡t and the integral of the rotor speed error z⁡t.
sys2≔StateSpace⁡a2,b2,c2,d2,inputvariable=V⁡t,T⁡t,wref⁡t,outputvariable=i⁡t,w⁡t,z⁡t:
PrintSystem⁡sys2
State Spacecontinuous3 output(s); 3 input(s); 3 state(s)inputvariable=V⁡t,T⁡t,wref⁡toutputvariable=i⁡t,w⁡t,z⁡tstatevariable=x1⁡t,x2⁡t,x3⁡ta=−RL−KL0KJ−BJ0010b=1L000−1J000−1c=100010001d=000000000
The state feedback controller and observer gains are given next:
Kc2≔Matrix⁡1.89107,7.35829,70.71068:
Kr2≔Matrix⁡1,1:
L2≔Matrix⁡0.08028,−0.00148,990.05009,0.98010,0.98010,10.09948:
The controlled input is the source voltage V⁡t. The measured input is wref⁡t. The controlled output is z⁡t. The measured outputs are w⁡t and z⁡t.
The controller-observer subsystem equations are obtained next:
cosys2≔ControllerObserver⁡sys2,Kc2,L2,Kr=Kr2,parameters=params,controlled_inputs=1,measured_inputs=3,controlled_outputs=3,measured_outputs=2,3:
PrintSystem⁡cosys2
It is also possible to obtain an LQG controller by computing LQR and Kalman gains. First, compute the weighting matrices:
W≔ComputeQR⁡sys2,0.4,parameters=params
W≔Record⁡Q=1.0.0.0.1.0.0.0.1.,R=0.321321227565641−0.332291362282656−0.00321457404413542−0.332291362282655210.0455234353071.20713539723679−0.003214574044135431.207135397236790.160000000000000
Kc3,Kr3≔LQR⁡sys2,W:-Q,W:-R,parameters=params,return_Kr
Kc3,Kr3≔1.03313325178664−0.001432595818157930.01221569878646450.0000388509514481089−0.0225671357809562−0.000745437890855909−0.0176293731317396−0.0279650446417151−2.49392402957048,2.033133251786640.008567404181842070.01221569878646450.0100388509514481−0.122567135780956−0.000745437890855909−0.01762937313173960.972034955358285−2.49392402957049
Then define the noise matrices and compute the Kalman gain:
G1≔LinearAlgebra:-IdentityMatrix⁡3:
H1≔LinearAlgebra:-ZeroMatrix⁡3:
Q1≔Matrix⁡5,0,0,0,1,0,0,0,1:
R1≔0.001⁢LinearAlgebra:-IdentityMatrix⁡3:
Kgain≔Kalman⁡sys2,G1,H1,Q1,R1,parameters=params1
Kgain≔68.73571982445120.6569966705915180.004052745997648820.65699667059151823.17761952135540.3576473293517190.004052745997648820.35764732935171931.6320623200853
Then compute LQG controller by combining the Kalman filter with LQR controller:
LQG≔ControllerObserver⁡sys2,Kc3,Kgain,Kr=Kr3,parameters=params:
PrintSystem⁡LQG
See Also
ControlDesign[ComputeQR]
ControlDesign[Kalman]
ControlDesign[LQR]
ControlDesign[StateFeedback]
ControlDesign[StateFeedback][Ackermann]
ControlDesign[StateFeedback][PolePlacement]
ControlDesign[StateObserver][Ackermann]
ControlDesign[StateObserver][Observer]
ControlDesign[StateObserver][PolePlacement]
Download Help Document