Fix IMU covariance residual coordinates - #2719
Conversation
|
@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. |
|
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. |
NEES validation resultsI 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.
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. |
Summary
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
Fixes #1803.
This PR supersedes #2384.