Fix enforceConsistency_ in BatchFixedLagSmoother#2456
Conversation
The linearValues_ member was never populated, making the enforceConsistency_ guard condition always false. After marginalization, the new LinearContainerFactors are only valid at the linearization point where they were computed. When enforceConsistency_ is enabled, we now record those variables and their linearization points in linearValues_ so that the existing logic in optimize() can restore them after each LM iteration. Fixes borglab#948
|
Ha ! That's a bug, thanks ! |
Adds a test that creates two smoothers (enforceConsistency on/off), runs them through a chain of between-factors with poor initial estimates, and verifies both produce valid results after marginalization has occurred.
|
Thanks! Added a test in the latest push that exercises
The test builds and passes with Before the fix, |
|
That's great ! Any NEES comparison? This flag was supposed to be implement FEJ which should make for better NEES values. |
Pose2 trajectory with 100 trials, 30 steps, lag=3, significant rotation per step. Shows enforceConsistency now has observable effect on NEES after the linearValues_ fix.
|
Added a Monte Carlo NEES test using Pose2 (100 trials, 30 steps, lag=3, significant rotation per step). Results: The key takeaway: with the fix, |
dellaert
left a comment
There was a problem hiding this comment.
Thanks, that's fast !!! Will run CI and merge when passes!
What this does
Fixes the
enforceConsistency_feature inBatchFixedLagSmoother, which has been non-functional sincelinearValues_was never populated.The bug
linearValues_(declared inBatchFixedLagSmoother.h:149) is read inoptimize()(line 268) to decide whether to restore linearization points:But
linearValues_is never written to anywhere in the codebase. It is always empty, so the guard is alwaysfalseand the consistency enforcement is dead code.The fix
After
marginalize()inserts newLinearContainerFactors (which store the linearization point at marginalization time), we now record the remaining variables and their linearization points inlinearValues_. This allows the existing logic inoptimize()to restore those linearization points after each LM iteration, keeping the marginal factors consistent.The existing cleanup in
eraseKeys()already handles removing entries fromlinearValues_when those variables are themselves eventually marginalized out.Fixes #948
cc @dellaert