control.create_estimator_iosystem¶
- control.create_estimator_iosystem(sys, QN, RN, P0=None, G=None, C=None, state_labels='xhat[{i}]', output_labels='xhat[{i}]', covariance_labels='P[{i},{j}]', sensor_labels=None)¶
Create an I/O system implementing a linqear quadratic estimator
This function creates an input/output system that implements a state estimator of the form
xhat[k + 1] = A x[k] + B u[k] - L (C xhat[k] - y[k]) P[k + 1] = A P A^T + F QN F^T - A P C^T Reps^{-1} C P A L = A P C^T Reps^{-1}
where Reps = RN + 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 sensor noise. The function returns the estimatorestim
as I/O system with a parametercorrect
that can be used to turn off the correction term in the estimation (for forward predictions).- Parameters
sys (InputOutputSystem) – The I/O system that represents the process dynamics. If no estimator is given, the output of this system should represent the full state.
QN (ndarray) – Process and sensor noise covariance matrices.
RN (ndarray) – Process and sensor noise covariance matrices.
P0 (ndarray, optional) – Initial covariance matrix. If not specified, defaults to the steady state covariance.
G (ndarray, optional) – Disturbance matrix describing how the disturbances enters the dynamics. Defaults to sys.B.
C (ndarray, optional) – If the system has all full states output, define the measured values to be used by the estimator. Otherwise, use the system output as the measured values.
{state (str or list of str, optional) – Set the name of the signals to use for the internal state, covariance, sensors, and outputs (state estimate). If a single string is specified, it should be a format string using the variable
i
as an index (ori
andj
for covariance). Otherwise, a list of strings matching the size of the respective signal should be used. Default is'xhat[{i}]'
for state and output labels,'y[{i}]'
for output labels and'P[{i},{j}]'
for covariance labels.covariance (str or list of str, optional) – Set the name of the signals to use for the internal state, covariance, sensors, and outputs (state estimate). If a single string is specified, it should be a format string using the variable
i
as an index (ori
andj
for covariance). Otherwise, a list of strings matching the size of the respective signal should be used. Default is'xhat[{i}]'
for state and output labels,'y[{i}]'
for output labels and'P[{i},{j}]'
for covariance labels.sensor (str or list of str, optional) – Set the name of the signals to use for the internal state, covariance, sensors, and outputs (state estimate). If a single string is specified, it should be a format string using the variable
i
as an index (ori
andj
for covariance). Otherwise, a list of strings matching the size of the respective signal should be used. Default is'xhat[{i}]'
for state and output labels,'y[{i}]'
for output labels and'P[{i},{j}]'
for covariance labels.output}_labels (str or list of str, optional) – Set the name of the signals to use for the internal state, covariance, sensors, and outputs (state estimate). If a single string is specified, it should be a format string using the variable
i
as an index (ori
andj
for covariance). Otherwise, a list of strings matching the size of the respective signal should be used. Default is'xhat[{i}]'
for state and output labels,'y[{i}]'
for output labels and'P[{i},{j}]'
for covariance labels.
- Returns
estim – Input/output system representing the estimator. This system takes the system input and output and generates the estimated state.
- Return type
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 toFalse
to allow prediction with no additional sensor information:- resp = ct.input_output_response(
est, T, 0, [X0, P0], param={‘correct’: False)