Skip to content

Fix IMU covariance residual coordinates - #2719

Draft
dellaert wants to merge 8 commits into
developfrom
fix/imu_covariance
Draft

Fix IMU covariance residual coordinates#2719
dellaert wants to merge 8 commits into
developfrom
fix/imu_covariance

Conversation

@dellaert

Copy link
Copy Markdown
Member

Summary

  • Convert standard 9D preintegrated IMU covariance from each backend native propagation coordinates into the existing factor-residual chart before constructing Gaussian noise models.
  • Apply the corresponding conversion to the full 15D combined covariance, including the bias sign and state-bias cross-covariances.
  • Replace the loose covariance regression behind issue Unit Test IMUFactor: Inconsistent covariance matrices #1803 with deterministic theoretical and Monte Carlo checks of actual factor residuals.

Details

The nonlinear residuals and raw preintMeasCov() accessors remain unchanged. New residualCovariance() accessors provide the covariance expressed in the chart used by each factor.

For tangent preintegration, the 9D conversion uses the exact NavState::retract Jacobian, whose blocks are the right Jacobian for rotation and the transpose of the preintegrated rotation for position and velocity. Manifold and Lie-group preintegration retain the identity conversion.

For combined preintegration, the conversion is extended with a negative identity on the six bias dimensions because covariance propagation tracks the accumulated bias change while the factor residual uses b_i - b_j. This leaves the bias marginal covariance unchanged but correctly transforms the state-bias cross-covariances.

The converted covariance is now installed by ImuFactorT, ImuFactor2T, ImuFactorWithGravityT, CombinedImuFactorT, and CombinedImuFactorWithGravityT. The wrapper interface exposes both raw and residual-chart covariance accessors.

The regression coverage runs identical theoretical and Monte Carlo experiments for manifold, tangent, and Lie-group preintegration. It checks the 9D and 15D covariances, including the combined state-bias cross block. The ScenarioRunner regression now disables integration noise that the runner does not sample, uses 5,000 deterministic samples, and compares covariance with a scale-aware relative Frobenius error.

Testing

  • make -j6 testImuFactorCovariance.run
  • make -j6 testImuFactor.run
  • make -j6 testImuFactorWithGravity.run
  • make -j6 testCombinedImuFactor.run
  • make -j6 testCombinedImuFactorWithGravity.run

Fixes #1803.

This PR supersedes #2384.

@dellaert dellaert mentioned this pull request Aug 21, 2026
@dellaert

Copy link
Copy Markdown
Member Author

@JzHuai0108 Take a look at this PR and let me know if you see any issues. I know it's a different approach than the one you suggested in #2384 - but if we can help it (and it seems we can) I'd strongly prefer not to change the definition of the residual.

@JzHuai0108

JzHuai0108 commented Aug 21, 2026

Copy link
Copy Markdown

I briefly reviewed the changes. Indeed keeping the original residual definitions is better for downstream users. The changes look good/consistent to me, but I did not build and run it.
Edit: A somewhat inelegant part of this PR is the PIM knows the IMU factor's residual definition. However, this PR allows that a developer writes a customized IMU factor and its residual cov using the PIM's preintMeasCov. So I am OK with this PR.

@dellaert

Copy link
Copy Markdown
Member Author

NEES validation results

I ran the notebook added in commit f64e137 with 5,000 deterministic Monte Carlo trials. Each trial integrates 60 measurements at 0.02 s with anisotropic accelerometer and gyroscope noise, constructs the real ImuFactor2, and evaluates its nonlinear residual at the ideal states.

The old comparison uses the raw preintMeasCov() as the factor covariance. The fixed comparison uses residualCovariance(), which is also the covariance now installed by the factor.

Metric Old raw covariance Fixed residual covariance
Mean NEES 23.674986 9.101219
Relative covariance error vs empirical residuals 97.4929% 2.7499%

For this 9D residual, expected mean NEES is 9; the approximate 95% interval for 5,000 trials is [8.8824, 9.1176]. The old result is far outside that interval, while the fixed result lies inside it.

The factor-installed covariance agrees with residualCovariance() to numerical precision. Relative to the old behavior, the fix reduces NEES deviation by 99.31% and empirical covariance error by 97.18%.

The experiment validates statistical consistency of the factor noise model; it does not claim a runtime improvement and does not redefine the nonlinear residual.

Open the validation notebook.

@dellaert dellaert mentioned this pull request Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unit Test IMUFactor: Inconsistent covariance matrices

2 participants