Main Content

residual

Residual and residual covariance from state measurement for insEKF

Description

example

[residual,residualCovariance] = residual(filter,sensor,measurement,measurementNoise) computes the residual and the residual covariance based on the measurement from the sensor and the measurement covariance.

Examples

collapse all

Create an insAccelerometer sensor object and insGyroscope sensor object.

acc = insAccelerometer;
gyro = insGyroscope;

Construct an insEKF object using the two sensor objects. Specify the angular velocity as [0.1 0.1 0.1] rad/s.

filter = insEKF(acc,gyro);
stateparts(filter,"AngularVelocity",[0.1 0.1 0.1]);

Obtain the residuals for a gyroscope measurement of [0.1 0.2 -0.04] rad/s with a measurement noise covariance of diag([0.2 0.2 0.2]) (deg/s)2.

[residual,residualCov] = residual(filter,gyro,[0.1 0.2 -0.04],diag([0.2 0.2 0.2]))
residual = 3×1

         0
    0.1000
   -0.1400

residualCov = 3×3

    2.2000         0         0
         0    2.2000         0
         0         0    2.2000

Input Arguments

collapse all

INS filter, specified as an insEKF object.

Inertial sensor, specified as one of these objects used to construct the insEKF filter object:

Measurement from the sensor, specified as an M-element real-valued vector, where M is the dimension of the measurement from the sensor object.

Data Types: single | double

Measurement noise, specified as an M-by-M real-valued positive-definite matrix, an M-element vector of positive values, or a positive scalar. M is the dimension of the measurement from the sensor object. When specified as a vector, the vector expands to the diagonal of an M-by-M diagonal matrix. When specified as a scalar, the value of the property is the product of the scalar and an M-by-M identity matrix.

Data Types: single | double

Output Arguments

collapse all

Measurement residual, returned as an M-element real-valued vector, where M is the dimension of the measurement.

Data Types: single | double

Residual covariance, returned as an M-by-M real-valued positive definite matrix, where M is the dimension of the measurement.

Data Types: single | double

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Version History

Introduced in R2022a