getEstimator

Obtain Kalman gains and model for estimator design

Description

example

[L,M] = getEstimator(MPCobj) extracts the Kalman gains used by the state estimator in a model predictive controller. The estimator updates the states of internal plant, disturbance, and noise models at the beginning of each controller interval.

example

[L,M,A,Cm,Bu,Bv,Dvm] = getEstimator(MPCobj) also returns the system matrices used to calculate the estimator gains.

[L,M,model,index] = getEstimator(MPCobj,'sys') returns an LTI state-space representation of the system used for state-estimator design and a structure summarizing the I/O signal types of the system.

Examples

collapse all

The plant is a stable, discrete LTI state-space model with four states, three inputs, and three outputs. The manipulated variables are inputs 1 and 2. Input 3 is an unmeasured disturbance. Outputs 1 and 3 are measured. Output 2 is unmeasured.

Create a model of the plant and specify the signals for MPC.

rng(1253)              % For repeatable results
Plant = drss(4,3,3);    
Plant.Ts = 0.25;
Plant = setmpcsignals(Plant,'MV',[1,2],'UD',3,'MO',[1 3],'UO', 2);
Plant.d(:,[1,2]) = 0;

The last command forces the plant to satisfy the assumption of no direct feedthrough.

Calculate the default model predictive controller for this plant.

MPCobj = mpc(Plant);
-->The "PredictionHorizon" property of "mpc" object is empty. Trying PredictionHorizon = 10.
-->The "ControlHorizon" property of the "mpc" object is empty. Assuming 2.
-->The "Weights.ManipulatedVariables" property of "mpc" object is empty. Assuming default 0.00000.
-->The "Weights.ManipulatedVariablesRate" property of "mpc" object is empty. Assuming default 0.10000.
-->The "Weights.OutputVariables" property of "mpc" object is empty. Assuming default 1.00000.
   for output(s) y1 y3 and zero weight for output(s) y2 

Obtain the parameters to be used in state estimation.

[L,M,A,Cm,Bu,Bv,Dvm] = getEstimator(MPCobj);
-->The "Model.Disturbance" property of "mpc" object is empty:
   Assuming unmeasured input disturbance #3 is integrated white noise.
-->Assuming output disturbance added to measured output channel #1 is integrated white noise.
   Assuming no disturbance added to measured output channel #3.
-->The "Model.Noise" property of the "mpc" object is empty. Assuming white noise on each measured output channel.

Based on the estimator state equation, the estimator poles are given by the eigenvalues of A - L*Cm. Calculate and display the poles.

Poles = eig(A - L*Cm)
Poles = 6×1

   -0.7467
   -0.5019
    0.0769
    0.4850
    0.8825
    0.8291

Confirm that the default estimator is asymptotically stable.

max(abs(Poles))
ans = 0.8825

This value is less than 1, so the estimator is asymptotically stable.

Verify that in this case, L = A*M.

L - A*M
ans = 6×2
10-15 ×

    0.1665   -0.0139
    0.0694   -0.0278
   -0.0416    0.0833
   -0.0555   -0.0416
   -0.0208    0.0555
   -0.0971   -0.0833

Input Arguments

collapse all

MPC controller, specified as an MPC controller object. Use the mpc command to create the MPC controller.

Output Arguments

collapse all

Kalman gain matrix for the time update, returned as a matrix. The dimensions of L are nx-by-nym, where nx is the total number of controller states, and nym is the number of measured outputs.

Kalman gain matrix for the measurement update, returned as a matrix. The dimensions of L are nx-by-nym, where nx is the total number of controller states, and nym is the number of measured outputs.

System matrices used to calculate the estimator gains, returned as matrices of various dimensions. For definitions of these system matrices, see State Estimator Equations.

System used for state-estimator design, returned as a state-space (ss) model. The input to model is a vector signal comprising the following components, concatenated in the following order:

  • Manipulated variables

  • Measured disturbance variables

  • 1

  • Noise inputs to disturbance models

  • Noise inputs to measurement noise model

The number of noise inputs depends on the disturbance and measurement noise models within MPCobj. For the category noise inputs to disturbance models, inputs to the input disturbance model (if any) precede those entering the output disturbance model (if any). The constant input, 1, accounts for nonequilibrium nominal values (see MPC Modeling).

To make the calculation of gains L and M more robust, additive white noise inputs are assumed to affect the manipulated variables and measured disturbances (see Controller State Estimation). These white noise inputs are not included in model.

Locations of variables within the inputs and outputs of model. The structure summarizes these locations with the following fields and values.

Field NameValue
ManipulatedVariablesIndices of manipulated variables within the input vector of model.
MeasuredDisturbancesIndices of measured input disturbances within the input vector of model.
OffsetIndex of the constant input 1 within the input vector of model.
WhiteNoiseIndices of unmeasured disturbance inputs within the input vector of model.
MeasuredOutputsIndices of measured outputs within the output vector of model.
UmeasuredOutputsIndices of unmeasured outputs within the output vector of model.

Algorithms

collapse all

State Estimator Equations

In general, the controller states are unmeasured and must be estimated. By default, the controller uses a steady-state Kalman filter that derives from the state observer. For more information, see Controller State Estimation.

At the beginning of the kth control interval, the controller state is estimated with the following steps:

  1. Obtain the following data:

    • xc(k|k–1) — Controller state estimate from previous control interval, k–1

    • uact(k–1) — Manipulated variable (MV) actually used in the plant from k–1 to k (assumed constant)

    • uopt(k–1) — Optimal MV recommended by MPC and assumed to be used in the plant from k–1 to k

    • v(k) — Current measured disturbances

    • ym(k) — Current measured plant outputs

    • Bu, Bv — Columns of observer parameter B corresponding to u(k) and v(k) inputs

    • Cm — Rows of observer parameter C corresponding to measured plant outputs

    • Dmv — Rows and columns of observer parameter D corresponding to measured plant outputs and measured disturbance inputs

    • L, M — Constant Kalman gain matrices

    Plant input and output signals are scaled to be dimensionless prior to use in calculations.

  2. Revise xc(k|k–1) when uact(k–1) and uopt(k–1) are different.

    xcrev(k|k1)=xc(k|k1)+Bu[uact(k1)uopt(k1)]

  3. Compute the innovation.

    e(k)=ym(k)[Cmxcrev(k|k1)+Dmvv(k)]

  4. Update the controller state estimate to account for the latest measurements.

    xc(k|k)=xcrev(k|k1)+Me(k)

    Then, the software uses the current state estimate xc(k|k) to solve the quadratic program at interval k. The solution is uopt(k), the MPC-recommended manipulated-variable value to be used between control intervals k and k+1.

    Finally, the software prepares for the next control interval assuming that the unknown inputs, wid(k), wod(k), and wn(k) assume their mean value (zero) between times k and k+1. The software predicts the impact of the known inputs and the innovation as follows:

    xc(k+1|k)=Axcrev(k|k1)+Buuopt(k)+Bvv(k)+Le(k)

Introduced in R2014b