control.create_estimator_iosystem

control.create_estimator_iosystem(sys, QN, RN, P0=None, G=None, C=None, control_indices=None, disturbance_indices=None, estimate_labels='xhat[{i}]', covariance_labels='P[{i},{j}]', measurement_labels=None, control_labels=None, inputs=None, outputs=None, states=None, **kwargs)[source]

Create an I/O system implementing a linear quadratic estimator.

This function creates an input/output system that implements a continuous-time state estimator of the form

d \hat{x}/dt &= A \hat{x} + B u - L (C \hat{x} - y) \\
   dP/dt &= A P + P A^T + G Q_N G^T - P C^T R_N^{-1} C P \\
       L &= P C^T R_N^{-1}

or a discrete-time state estimator of the form

\hat{x}[k+1] &= A \hat{x}[k] + B u[k] - L (C \hat{x}[k] - y[k]) \\
       P[k+1] &= A P A^T + G Q_N G^T - A P C^T R_e^{-1} C P A \\
            L &= A P C^T R_e^{-1}

where R_e = R_N + C P C^T. It can be called in the form:

estim = ct.create_estimator_iosystem(sys, QN, RN)

where sys is the process dynamics and QN and RN are the covariance of the disturbance noise and measurement noise. The function returns the estimator estim as I/O system with a parameter correct that can be used to turn off the correction term in the estimation (for forward predictions).

Parameters
sysStateSpace

The linear I/O system that represents the process dynamics.

QN, RNndarray

Disturbance and measurement noise covariance matrices.

P0ndarray, optional

Initial covariance matrix. If not specified, defaults to the steady state covariance.

Gndarray, optional

Disturbance matrix describing how the disturbances enters the dynamics. Defaults to sys.B.

Cndarray, optional

If the system has full state output, define the measured values to be used by the estimator. Otherwise, use the system output as the measured values.

Returns
estimInputOutputSystem

Input/output system representing the estimator. This system takes the system output y and input u and generates the estimated state xhat.

Other Parameters
control_indicesint, slice, or list of int or string, optional

Specify the indices in the system input vector that correspond to the control inputs. These inputs will be used as known control inputs for the estimator. If value is an integer m, the first m system inputs are used. Otherwise, the value should be a slice or a list of indices. The list of indices can be specified as either integer offsets or as system input signal names. If not specified, defaults to the system inputs.

disturbance_indicesint, list of int, or slice, optional

Specify the indices in the system input vector that correspond to the unknown disturbances. These inputs are assumed to be white noise with noise intensity QN. If value is an integer m, the last m system inputs are used. Otherwise, the value should be a slice or a list of indices. The list of indices can be specified as either integer offsets or as system input signal names. If not specified, the disturbances are assumed to be added to the system inputs.

estimate_labelsstr or list of str, optional

Set the names of the state estimate variables (estimator outputs). If a single string is specified, it should be a format string using the variable i as an index. Otherwise, a list of strings matching the number of system states should be used. Default is “xhat[{i}]”.

covariance_labelsstr or list of str, optional

Set the name of the the covariance state variables. If a single string is specified, it should be a format string using the variables i and j as indices. Otherwise, a list of strings matching the size of the covariance matrix should be used. Default is “P[{i},{j}]”.

measurement_labels, control_labelsstr or list of str, optional

Set the name of the measurement and control signal names (estimator inputs). If a single string is specified, it should be a format string using the variable i as an index. Otherwise, a list of strings matching the size of the system inputs and outputs should be used. Default is the signal names for the system measurements and known control inputs. These settings can also be overridden using the inputs keyword.

inputs, outputs, statesint or list of str, optional

Set the names of the inputs, outputs, and states, as described in InputOutputSystem. Overrides signal labels.

namestring, optional

System name (used for specifying signals). If unspecified, a generic name ‘sys[id]’ is generated with a unique integer id.

Notes

This function can be used with the create_statefbk_iosystem function to create a closed loop, output-feedback, state space controller:

K, _, _ = ct.lqr(sys, Q, R)
est = ct.create_estimator_iosystem(sys, QN, RN, P0)
ctrl, clsys = ct.create_statefbk_iosystem(sys, K, estimator=est)

The estimator can also be run on its own to process a noisy signal:

resp = ct.input_output_response(est, T, [Y, U], [X0, P0])

If desired, the correct parameter can be set to False to allow prediction with no additional measurement information:

resp = ct.input_output_response(
   est, T, 0, [X0, P0], params={'correct': False)

References

1

R. M. Murray, Optimization-Based Control, 2023.