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

Online Help

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  (reference input). If Kr = 0, there are no reference inputs  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  and the state errors  (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  and the state estimates . 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  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  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  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  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,  is the state feedback controller gain, and  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 , where  is the estimated state vector, and  is the reference vector. The reference vector  contains a reference signal for each controlled output, .

• 

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,  and , 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  (when a non-zero Kr Matrix is specified)

– 

the measured_inputs 

– 

the measured_outputs  (renamed )

  

The controller-observer outputs are

– 

the controlled_inputs 

  

The controller-observer states (in state-space) are

– 

the estimated states  (renamed )

• 

The closed-loop system inputs are

– 

the reference inputs  (when a non-zero Kr Matrix is specified)

– 

the measured_inputs 

– 

the non-controlled inputs  (e.g. disturbances)

  

The closed-loop system outputs are

– 

the controlled_outputs 

– 

the non-controlled outputs

– 

the controlled_inputs  (if augment_output = true)

  

The closed-loop system states (in state-space) are

– 

the sys states  and

– 

the estimated states  (renamed )

  

Or when stateerror = true

– 

the sys states  and

– 

the state errors  (renamed ).

Examples

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([[alpha], [1]]), Matrix([[1, 0]]), Matrix(1, 1)):

PrintSystem(sys1);

(1)
• 

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

Observable(sys1, 'parameters' = {alpha = 1/2});

(2)
• 

Defining the characteristic polynomial with damping ratio  and natural frequency .

cp := s^2 + 2*Z*omega*s + omega^2;

(3)
• 

The corresponding poles are:

poles := [solve(cp, s)];

(4)
• 

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

Kc1, Kr1 := StateFeedback:-PolePlacement(sys1, [a, b], 'return_Kr'):

Kc1 := simplify(eval(Kc1, [a = poles[1], b = poles[2]]));

(5)

Kr1 := simplify(eval(Kr1, [a = poles[1], b = poles[2]]));

(6)
• 

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

L1 := StateObserver:-PolePlacement(sys1, [a, b]):

L1 := simplify(eval(L1, [a = poles[1], b = poles[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.

cosys1 := ControllerObserver(sys1, Kc1, L1, ':-Kr' = Kr1):

PrintSystem(cosys1);

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

clsys1 := ControllerObserver(sys1, Kc1, L1, ':-Kr' = Kr1, ':-closedloop' = true, ':-stateerror' = true, ':-augment_output' = true, ':-outputtype' = de):

PrintSystem(clsys1);

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

a2 := Matrix([[-R/L, -K/L, 0], [K/J, -B/J, 0], [0, 1, 0]]):

b2 := Matrix([[1/L, 0, 0],[0, -1/J , 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 , stator resistance , electromotive force (emf) constant , rotor moment of inertia , and damping ratio  are given next:

params := {J = 0.01, K = 0.01, L = 0.5, R = 1, B = 0.1}:

• 

The input variables are the source voltage , the torque load  and the rotor angular speed reference , and the output variables are the stator current , the rotor angular speed  and the integral of the rotor speed error .

sys2 := StateSpace(a2, b2, c2, d2, 'inputvariable' = [V(t), T(t), wref(t)], 'outputvariable' = [i(t), w(t), z(t)]):

PrintSystem(sys2);

(10)
• 

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, .98010], [.98010, 10.09948]]):

• 

The controlled input is the source voltage . The measured input is . The controlled output is . The measured outputs are  and .

• 

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

(11)
• 

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

(12)

Kc3, Kr3 := LQR(sys2, W:-Q, W:-R, 'parameters'=params,'return_Kr');

(13)

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.1e-2*LinearAlgebra:-IdentityMatrix(3):

Kgain := Kalman(sys2, G1, H1, Q1, R1, 'parameters'=params)[1];

(14)

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

LQG := ControllerObserver(sys2, Kc3, Kgain, 'Kr'=Kr3, 'parameters'=params):

PrintSystem(LQG);

(15)

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]

 


Download Help Document