Skip to content

test(mobile): tests for vehicle models, sensor, landmark map, EKF and particle filter - #747

Merged
petercorke merged 2 commits into
mainfrom
test/mobile-estimator-regressions
Oct 13, 2026
Merged

petercorke merged 2 commits into
mainfrom
test/mobile-estimator-regressions

Conversation

@petercorke

Copy link
Copy Markdown
Owner

Summary

EKF (14% covered), ParticleFilter (21%) and Vehicle (35%) were among the least tested code in the toolbox, and several recent third-party bug reports (#719, #720, #721, #735) are in exactly these files. This adds tests/test_vehicle_estimators.py.

  • Vehicle kinematics against closed-form results; state transition f and its Jacobians Fx, Fv against finite differences
  • Range-bearing sensor against the geometry, range limits; seeded landmark maps
  • EKF: dead reckoning (uncertainty grows, covariance symmetric positive definite), map-based localization (beats dead reckoning), map creation and SLAM (landmark and vehicle error against ground truth), landmark bookkeeping, Joseph and standard forms agree
  • Particle filter converges to the truth, uncertainty shrinks, seeded and reproducible

Bounds are loose multiples of the errors measured at the time of writing, so they catch a broken estimator without being brittle. The whole file runs in under half a second (the particle filter test patches plt.pause, see below).

Coverage: EKF 14% → 70%, ParticleFilter 21% → 62%, sensors 79%, landmark map 64%.

Defects found

  • EKF.plot_error() raises in SLAM (recorded as an expectedFailure), and has further problems: the line is plotted against sample index while the axes are in time, bgcolor is ignored, and the bounds use df=2 for a scalar error
  • ParticleFilter.run() calls plt.pause(0.2) on every step even when animate=False, so run(T=10) takes 24 s of wall time

Fixes follow as separate PRs. Several docstring examples are also wrong (LandmarkMap(nlandmarks=...), RandomPath(20, 2), RangeBearingSensor(robot, map, W)); that is a separate docs PR.

This does not touch the code changed by #719, #720, #721 and #735, and the tests do not depend on those bugs.

Test plan

  • pytest tests/test_vehicle_estimators.py on pgraph 0.6.5 and 1.0.0 (39 passed, 1 xfailed)
  • No Python 3.12-only syntax

🤖 Generated with Claude Code

… particle filter

EKF (14%), ParticleFilter (21%) and Vehicle (35%) were the least tested
estimators in the toolbox.  This adds tests/test_vehicle_estimators.py.

- vehicle kinematics against closed form results, state transition and its
  Jacobians Fx and Fv against finite differences
- range-bearing sensor against the geometry, range limits, seeded landmark maps
- EKF: dead reckoning (uncertainty grows, covariance stays symmetric positive
  definite), map-based localization (beats dead reckoning), map creation and
  SLAM (landmark and vehicle error against ground truth), landmark bookkeeping
- particle filter converges to the truth, uncertainty shrinks, seeded

Bounds are loose multiples of the errors measured at the time of writing.
EKF 14% -> 70%, ParticleFilter 21% -> 62%, sensors 79%.  Passes on pgraph
0.6.5 and 1.0.0.

One defect is recorded as an expectedFailure: EKF.plot_error() raises in SLAM
because it subtracts the whole state vector from the 3-element truth.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@codacy-production

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 7 high

Alerts:
⚠ 7 issues (≤ 0 issues of at least minor severity)

Results:
7 new issues

Category Results
ErrorProne 7 high

View in Codacy

🟢 Metrics 62 complexity · 9 duplication

Metric Results
Complexity 62
Duplication 9

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@codecov

codecov Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (e094f89) to head (cf4e1d0).

Additional details and impacted files
@@          Coverage Diff          @@
##            main    #747   +/-   ##
=====================================
  Coverage   0.00%   0.00%           
=====================================
  Files        143     143           
  Lines      14271   14271           
=====================================
  Misses     14271   14271           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@petercorke
petercorke merged commit b2093fc into main Oct 13, 2026
24 of 25 checks passed
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.

1 participant