CogniPilot

MODELICA LIBRARY · ENGINEERING REFERENCE

package

Estimation.StrapdownINS.ESKF

15-state aided strapdown inertial-navigation error-state Kalman filter

Use Estimator for sampled sensor fusion, or the prediction and correction functions for an explicit replay. The optional stationary-IMU mode requires a trustworthy vehicleAtRest signal; it does not detect rest. Optional square-root covariance changes numerical representation and has additional runtime and storage costs. Validate each mode for the intended vehicle.

The sampled step boundary delegates initialization and state advancement to bounded functions. Keep those boundaries intact: expanding prediction, recovery and all aiding branches into one dispatcher can exceed a native compiler's function-size limit and silently select a much slower interpreter. Re-seeding remains opt-in and retains the same state, covariance and recovery-reporting contract.

The nominal extended pose is propagated by LieGroups.SE23.Quat.exp_mixed. Covariance lives in a body-local right-perturbation error ordered as position, velocity, attitude, gyroscope bias, and accelerometer bias.

Over one IMU interval the corrected IMU input is held constant. The locally linearized error transition is discretized with a third-order matrix exponential polynomial; the process-noise integral is evaluated by Simpson quadrature. Both operations retain full cross-axis covariance and use matrix expressions rather than three scalar filters.

This is an aided strapdown INS ESKF, not a strict invariant Kalman filter. The additive bias states are not part of a group-affine, exactly log-linear augmented system. The local pose error and manifold retraction are geometric implementation choices inside an otherwise ordinary error-state EKF.

The convention and inertial error dynamics follow T. D. Barfoot, State Estimation for Robotics, 2nd-edition draft, Section 9.4: the nominal state is right-perturbed, so the local error is T_hat^-1 T. In the tangent ordering used here, Barfoot's position, velocity, attitude, gyro-bias, and accelerometer-bias blocks map directly to continuousTransition and noiseInputMatrix. Prediction implements P+ = Phi P Phi' + integral(Phi G Q G' Phi'). Correction uses an arbitrary-gain Joseph update followed by the right-Jacobian reset that transports covariance to the newly injected nominal-state tangent.

Public declarations

Explicit source declarations; dimensions, modifications and defaults are shown as written, without evaluation.

RoleNameTypeDimensions / attributes / defaultDescription
constantTangentLengthInteger= 15
constantProcessNoiseLengthInteger= 12
constantRecoveryEnvelope_mReal= 100.0
constantFiniteMagnitudeLimitReal= 1.0e30
constantMinimumSeedQuaternionNormReal= 1.0e-3
constantMaxAttitudeCorrection_radReal= 0.15

Members

NameKindDescription
TangentVectortype
Covariancetype
NominalStaterecordNominal navigation state
StaterecordNominal state and full local-error tangent covariance
VarianceLimitsrecordMission-envelope upper bounds on the tangent variances
TuningrecordFixed filter tuning held constant across every estimator tick
initializefunctionInitialize the geometric error-state filter
conditionAlignmentfunctionCondition the initial tangent covariance on the gravity vector used for alignment
seedPositionVariancesfunctionBound an aiding position seed's uncertainty in the local tangent frame
continuousTransitionfunctionContinuous local right-perturbation error dynamics for held IMU input
noiseInputMatrixfunctionMap continuous IMU and bias noise into the tangent
processNoiseMatrixfunctionAssemble the full continuous process covariance
discreteTransitionfunctionThird-order discretization of a held continuous tangent transition
heldInputJacobianfunctionTransport one held gyroscope/accelerometer sample into the local error
discreteProcessCovariancefunctionSimpson approximation of the exact held-input covariance integral
predictNominalfunctionPropagate the nominal state with the existing mixed SE_2(3) exponential
predictPreintegratedfunctionApply one closed-form IMU preintegral and its exact local transition
predictStationaryfunctionPropagate a declared stationary vehicle with random-walk biases
retrodictfunctionRetrodict the nominal state with one held IMU sample
predictfunctionMixed SE_2(3) nominal and local error covariance prediction
limitCovariancefunctionBound diagonal covariance growth to mission-envelope variance limits
inflateCovariancefunctionRamp position and velocity covariance toward the mission envelope
holdCovariancefunctionGrow covariance by one interval of process noise with the state held
injectfunctionRight-inject a local tangent correction
SemiDirectBiaspackageExperimental 15-state semi-direct bias correction geometry
VisualpackageVisual aiding in the navigation error coordinates
reseedfunctionRe-seed position and velocity from a fresh anchor sample after a sustained rejection, restoring their covariance blocks to the initial variances
conjugateResetfunctionConjugate a covariance by the block-diagonal reset Jacobian diag(J, I)
considerGainProjectorfunctionConsider-projector for the rotation rows of a Kalman gain
constrainGainfunctionProject considered states and limit the finite attitude correction
correctLinearfunctionVectorized Joseph-form correction in the local right-error tangent space
correctMocapfunctionCorrect position and attitude from motion capture
correctGpsfunctionJointly correct GPS position and velocity
correctGpsPositionfunctionCorrect world position from GPS
correctGpsVelocityfunctionCorrect world velocity from GPS Doppler velocity
correctMagnetometerfunctionCorrect heading or a calibrated magnetic vector in the local tangent
correctPseudoPositionfunctionFuse a synthetic measurement that the vehicle is still at its held position
correctZeroVelocityfunctionFuse a synthetic measurement that the vehicle is not moving
correctStationaryImufunctionObserve gyro bias and coupled gravity/accelerometer bias during declared rest
correctBarometerfunctionCorrect vertical position from pressure altitude after bias compensation
opticalFlowRangeJacobianfunctionNadir ray-to-plane range and Jacobian in the ESKF right-error tangent
correctOpticalFlowfunctionFuse image angular rates with co-timed range uncertainty
navigationEstimatefunctionPublish a canonical estimate with consistent attitude representations
nominalStateFinitefunctionTrue when every published nominal state component is finite
initializeTickfunctionInitialize and condition a navigation state without expanding the step dispatcher
predictTickfunctionPredict or hold one IMU interval and bound its covariance
correctAbsoluteAidingTickfunctionSelect and fuse one absolute aiding sample without expanding the dispatcher
TickUpdatespackageBounded gated state updates for the sampled dispatcher
advanceStateTickfunctionAdvance the state through prediction, recovery and aiding as one bounded stage
stepfunctionPredict, select absolute aiding, and fuse independent flow, height and heading
EstimatorblockSampled aided strapdown inertial-navigation ESKF
withCovarianceRootfunctionSet the authoritative root and its dense diagnostic
predictCovariancefunctionPropagate covariance in its selected representation
limitStateCovariancefunctionBound covariance without changing its representation
inflateStateCovariancefunctionInflate covariance in its selected representation
copyStatefunctionCopy a filter state and its covariance representation
withDenseCovariancefunctionReplace a dense covariance and preserve the state

Modelica declarations and implementation

Show parameters, interfaces and source

Parameters, inputs, outputs, defaults and equations from the source file.

package ESKF
  "15-state aided strapdown inertial-navigation error-state Kalman filter"
  constant Integer TangentLength = 15;
  constant Integer ProcessNoiseLength = 12;

  constant Real RecoveryEnvelope_m = 100.0;

  // Magnitude above which a Real is treated as not finite. Exactly
  // representable in binary32 (max ~3.4e38) and binary64, so the same
  // source means the same thing in simulation and in generated flight
  // code, and 1e30 is ~20 orders of magnitude beyond any residual,
  // position, or velocity this filter can legitimately see. The test
  // `abs(x) < FiniteMagnitudeLimit` is false for NaN and for +/-Inf
  // alike, so one comparison per element covers both.
  constant Real FiniteMagnitudeLimit = 1.0e30;

  constant Real MinimumSeedQuaternionNorm = 1.0e-3;

  constant Real MaxAttitudeCorrection_rad = 0.15;

  type TangentVector = Real[15]
    "{position,velocity,attitude,gyro bias,accelerometer bias} error";
  type Covariance = Real[15, 15];
  annotation(Documentation(info = "<html>
    <p>Use <a href=\"modelica://Estimation.StrapdownINS.ESKF.Estimator\">Estimator</a>
    for sampled sensor fusion, or the prediction and correction functions for
    an explicit replay. The optional stationary-IMU mode requires a trustworthy
    <code>vehicleAtRest</code> signal; it does not detect rest. Optional
    square-root covariance changes numerical representation and has additional
    runtime and storage costs. Validate each mode for the intended vehicle.</p>
    <p>The sampled <code>step</code> boundary delegates initialization and
    state advancement to bounded functions. Keep those boundaries intact:
    expanding prediction, recovery and all aiding branches into one dispatcher
    can exceed a native compiler's function-size limit and silently select a
    much slower interpreter. Re-seeding remains opt-in and retains the same
    state, covariance and recovery-reporting contract.</p>
    <p>The nominal extended pose is propagated by
    <code>LieGroups.SE23.Quat.exp_mixed</code>. Covariance lives in a
    body-local right-perturbation error ordered as position, velocity,
    attitude, gyroscope bias, and accelerometer bias.</p>
    <p>Over one IMU interval the corrected IMU input is held constant. The
    locally linearized error transition is discretized with a third-order matrix
    exponential polynomial; the process-noise integral is evaluated by
    Simpson quadrature. Both operations retain full cross-axis covariance and
    use matrix expressions rather than three scalar filters.</p>
    <p>This is an aided strapdown INS ESKF, not a strict invariant Kalman
    filter. The additive bias states are not part of a group-affine, exactly
    log-linear augmented system. The local pose error and manifold retraction
    are geometric implementation choices inside an otherwise ordinary
    error-state EKF.</p>
    <p>The convention and inertial error dynamics follow T. D. Barfoot,
    <a href=\"https://asrl.utias.utoronto.ca/~tdb/bib/barfoot_ser24.pdf\">
    <i>State Estimation for Robotics</i>, 2nd-edition draft</a>, Section 9.4:
    the nominal state is right-perturbed, so the local error is
    <code>T_hat^-1 T</code>. In the tangent ordering used here, Barfoot's
    position, velocity, attitude, gyro-bias, and accelerometer-bias blocks map
    directly to <code>continuousTransition</code> and
    <code>noiseInputMatrix</code>. Prediction implements
    <code>P+ = Phi P Phi' + integral(Phi G Q G' Phi')</code>. Correction uses
    an arbitrary-gain Joseph update followed by the right-Jacobian reset that
    transports covariance to the newly injected nominal-state tangent.</p>
  </html>"));
end ESKF;