ControllerObserver - MapleSim Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


ControlDesign

  

ControllerObserver

  

determine the equations of the subsystem comprised of a state feedback controller and an observer

 

Calling Sequence

Parameters

Options

Description

Examples

Calling Sequence

ControllerObserver(sys, Kc, L, opts)

Parameters

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

Options

• 

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=xxˆ (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).

Description

• 

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 reference inputs r=yc_ref (when a non-zero Kr Matrix is specified)

– 

the measured_inputs um

– 

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

– 

the estimated states xˆ (renamed x_est)

  

Or when stateerror = true

– 

the sys states x and

– 

the state errors xerr=xxˆ (renamed x_err).

Examples

withControlDesign:

withDynamicSystems:

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:

sys1StateSpaceMatrix0,1,0,0,Matrixα,1,Matrix1,0,Matrix1,1:

PrintSystemsys1

State Spacecontinuous1 output(s); 1 input(s); 2 state(s)inputvariable=u1toutputvariable=y1tstatevariable=x1t,x2ta=0100b=α1c=10d=0

(1)
• 

Checking whether the system is observable with alpha = 1/2.

Observablesys1,parameters=α=12

true

(2)
• 

Defining the characteristic polynomial with damping ratio Z and natural frequency ω.

cps2+2Zωs+ω2

cp2Zωs+ω2+s2

(3)
• 

The corresponding poles are:

polessolvecp,s

polesZ+Z21ω,ZZ21ω

(4)
• 

Designing the state feedback controller gains (Kc and Kr) by  pole placement:

Kc1,Kr1StateFeedback:-PolePlacementsys1,a,b,return_Kr:

Kc1simplifyevalKc1,a=poles1,b=poles2

Kc1ω2ω2α+2ωZ

(5)

Kr1simplifyevalKr1,a=poles1,b=poles2

Kr1ω2

(6)
• 

Designing the state observer with gain L by pole placement as well.

L1StateObserver:-PolePlacementsys1,a,b:

L1simplifyevalL1,a=poles1,b=poles2

L12ωZω2

(7)
• 

The controller-observer subsystem is obtained next. Note that the state, input, and output variables of the returned system object are renamed accordingly.

cosys1ControllerObserversys1,Kc1,L1,:-Kr=Kr1:

PrintSystemcosys1

State Spacecontinuous1 output(s); 2 input(s); 2 state(s)inputvariable=y1_reft,y1_meastoutputvariable=u1tstatevariable=x1_estt,x2_estta=ω2α2ωZ1αω2α+2ωZ2ω2ω2α2ωZb=ω2α2ωZω2ω2c=ω2ω2α2ωZd=ω20

(8)
• 

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).

clsys1ControllerObserversys1,Kc1,L1,:-Kr=Kr1,:-closedloop=true,:-stateerror=true,:-augment_output=true,:-outputtype=de:

PrintSystemclsys1

Diff. Equationcontinuous2 output(s); 1 input(s)inputvariable=y1_reftoutputvariable=y1t,u1tde={[ⅆⅆtx1t={ω2αx1t+1αω2α+2ωZx2t +ω2αx1_errt+αω2α+2ωZx2_errt +ω2αy1_reft, ⅆⅆtx2t={ω2x1t+ω2α2ωZx2t+ω2x1_errt ω2α+2ωZx2_errt+ω2y1_reft, ⅆⅆtx1_errt=2ωZx1_errt+x2_errt, ⅆⅆtx2_errt=ω2x1_errt, y1t=x1t, u1t={ω2x1t+ω2α2ωZx2t+ω2x1_errt ω2α+2ωZx2_errt+ω2y1_reft]

(9)

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.

a2MatrixRL,KL,0,KJ,BJ,0,0,1,0:

b2Matrix1L,0,0,0,1J,0,0,0,1:

c2Matrix1,0,0,0,1,0,0,0,1:

d2Matrix3,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:

paramsB=0.1,J=0.01,K=0.01,L=0.5,R=1:

• 

The input variables are the source voltage Vt, the torque load Tt and the rotor angular speed reference wreft, and the output variables are the stator current it, the rotor angular speed wt and the integral of the rotor speed error zt.

sys2StateSpacea2,b2,c2,d2,inputvariable=Vt,Tt,wreft,outputvariable=it,wt,zt:

PrintSystemsys2

State Spacecontinuous3 output(s); 3 input(s); 3 state(s)inputvariable=Vt,Tt,wreftoutputvariable=it,wt,ztstatevariable=x1t,x2t,x3ta=RLKL0KJBJ0010b=1L0001J000−1c=100010001d=000000000

(10)
• 

The state feedback controller and observer gains are given next:

Kc2Matrix1.89107,7.35829,70.71068:

Kr2Matrix1,1:

L2Matrix0.08028,0.00148,990.05009,0.98010,0.98010,10.09948:

• 

The controlled input is the source voltage Vt. The measured input is wreft. The controlled output is zt. The measured outputs are wt and zt.

• 

The controller-observer subsystem equations are obtained next:

cosys2ControllerObserversys2,Kc2,L2,Kr=Kr2,parameters=params,controlled_inputs=1,measured_inputs=3,controlled_outputs=3,measured_outputs=2,3:

PrintSystemcosys2

• 

It is also possible to obtain an LQG controller by computing LQR and Kalman gains. First, compute the weighting matrices:

WComputeQRsys2,0.4,parameters=params

WRecordQ=1.0.0.0.1.0.0.0.1.,R=0.321321227565641−0.332291362282656−0.00321457404413542−0.332291362282655210.0455234353071.20713539723679−0.003214574044135431.207135397236790.160000000000000

(11)

Kc3,Kr3LQRsys2,W:-Q,W:-R,parameters=params,return_Kr

Kc3,Kr31.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

(12)

Then define the noise matrices and compute the Kalman gain:

G1LinearAlgebra:-IdentityMatrix3:

H1LinearAlgebra:-ZeroMatrix3:

Q1Matrix5,0,0,0,1,0,0,0,1:

R10.001LinearAlgebra:-IdentityMatrix3:

KgainKalmansys2,G1,H1,Q1,R1,parameters=params1

Kgain68.73571982445120.6569966705915180.004052745997648820.65699667059151823.17761952135540.3576473293517190.004052745997648820.35764732935171931.6320623200853

(13)

Then compute LQG controller by combining the Kalman filter with LQR controller:

LQGControllerObserversys2,Kc3,Kgain,Kr=Kr3,parameters=params:

PrintSystemLQG

See Also

ControlDesign

ControlDesign[ComputeQR]

ControlDesign[Kalman]

ControlDesign[LQR]

ControlDesign[StateFeedback]

ControlDesign[StateFeedback][Ackermann]

ControlDesign[StateFeedback][PolePlacement]

ControlDesign[StateObserver][Ackermann]

ControlDesign[StateObserver][Observer]

ControlDesign[StateObserver][PolePlacement]