Skip to content

fix(demo): make radar_tracking_ukf converge and report honestly - #16

Merged
rahadbhuiya merged 1 commit into
Exploidus:mainfrom
mdabydeen:feat/fix-radar-demo-tracker-honesty
Oct 24, 2026
Merged

rahadbhuiya merged 1 commit into
Exploidus:mainfrom
mdabydeen:feat/fix-radar-demo-tracker-honesty

Conversation

@mdabydeen

Copy link
Copy Markdown
Contributor

Closes #3.

What

examples/radar_tracking_ukf.rs printed a position-error column that grew from 1.47 m to
26.84 m over 15 steps, then closed with "UKF tracked continuous curved flight without
analytical Jacobian matrices." The number and the conclusion contradicted each other.

Root cause

  • The transition closure held y constant (|state, _d| [state[0] + 8.0 * _d, state[1]])
    while the ground-truth y moved, so the model and reality did not agree.
  • A single range observation sqrt(x^2 + y^2) is barely observable in y, so the estimate
    stuck.
  • The "tracked" line was unconditional, with no check on the error.

The filter math was fine; the demo model was inconsistent.

Fix

  • Model y in the transition: the target now flies a constant-velocity straight line
    (x0 + vx*t, y0 + vy*t), which is what a linear transition can actually track.
  • Add a second, observable sensor (a lateral y reading) so the 2-D state is recoverable.
  • Report success honestly: print an error-qualified "tracked" line only when the final
    error is under a threshold, guarded by an assertion so a future regression panics the
    example instead of silently printing a false success.

Verification

  • Final error now stabilises at ~0.3 m; the demo prints an honest, error-qualified line.
  • Regression guard confirmed to fire: temporarily tightening the threshold to 0.05 m made the
    example panic (exit 134), then reverted.
  • cargo fmt -- --check clean
  • cargo clippy --all-targets --all-features -- -D warnings clean (examples included)
  • cargo run --example radar_tracking_ukf exits 0; the other three examples still run

Note: examples are not part of cargo test, so correctness is guarded by the in-main
assertion plus the before/after numbers, not a unit test.

Closes Exploidus#3: the demo's position error grew 1.47m -> 26.84m over 15 steps yet it
printed an unconditional 'UKF tracked' because:
  - the transition closure froze the y-state (|s, dt| [s0+8dt, s1]) while the
    ground-truth y drifted, so the model and reality disagreed by construction;
  - a single range observation cannot separate a 2-D state's x from y (unobservable
    in the direction orthogonal to the line of sight).

Three-part fix:
  1. Model the motion the target actually makes: capture constant velocities vx, vy
     in the transition closure so both components propagate (a linear model tracks
     linear motion; the old sin() 'curved' path was itself the first mismatch).
  2. Add a second observation (a lateral y sensor) so the 2-D state is observable.
  3. Gate the success claim on the real final error and add a regression-guard
     assert: a future divergence panics the example instead of printing a false win.

Final error now stabilises at ~0.3m and the run prints an honest, error-qualified
'tracked' line. Verified: fmt clippy (all-targets) tests all examples green;
the assert was confirmed to fire by temporarily tightening the threshold (exit 134).
@github-actions github-actions Bot added the tests Test suites, coverage, and verification benchmarks label Oct 24, 2026
@rahadbhuiya
rahadbhuiya self-requested a review October 24, 2026 18:56
@rahadbhuiya
rahadbhuiya merged commit 7aba00c into Exploidus:main Oct 24, 2026
1 check passed
mdabydeen added a commit to mdabydeen/aegis-filter that referenced this pull request Oct 25, 2026
N-D Joseph-stabilized measurement update for LinearKalmanFilter (Exploidus#15) and the
honest radar-tracking demo fix (Exploidus#16); closes Exploidus#2 and Exploidus#3.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tests Test suites, coverage, and verification benchmarks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

demo: radar_tracking_ukf diverges but reports successful tracking

2 participants