Skip to content

Feature/use kd tree for landmark map search - #579

Open
PaulVerhoeckx wants to merge 7 commits into
Ekumen-OS:mainfrom
nobleo:feature/use-kd-tree-for-landmark-map-search
Open

Feature/use kd tree for landmark map search#579
PaulVerhoeckx wants to merge 7 commits into
Ekumen-OS:mainfrom
nobleo:feature/use-kd-tree-for-landmark-map-search

Conversation

@PaulVerhoeckx

Copy link
Copy Markdown
Contributor

Proposed changes

Implement efficient nearest-neighbor landmark search using per-category KD-trees with nanoflann. Provides O(log n) spatial queries instead of O(n) linear search for position-based landmark matching.

Tested for a particle filter with:

  • 1000 particles
  • 3 landmark detections
  • landmark map containing 50.000 landmarks

This reduced the filter update time from 1.4 seconds to 0.005 seconds. (12th Gen Intel® Core™ i7-1255U × 12)

Changes

  • Added category-based KD-tree indices for fast spatial nearest-neighbor search
  • Implemented find_nearest_landmark() using KD-tree queries for efficient position-based matching
  • Cached per-category indices with lazy construction during map initialization
  • Added PositionCloud adapter and CategoryIndex structure for nanoflann integration
  • Deprecated copy operations to prevent expensive kd-tree reconstruction

Type of change

  • 🐛 Bugfix (change which fixes an issue)
  • 🚀 Feature (change which adds functionality)
  • 📚 Documentation (change which fixes or extends documentation)

Checklist

Put an x in the boxes that apply. This is simply a reminder of what we will require before merging your code.

  • Lint and unit tests (if any) pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • All commits have been signed for DCO

Additional comments

Note on find_closest_bearing_landmark() implementation:
This method currently uses O(n) linear search instead of the KD-tree indices because bearing-based matching requires angular distance metrics, which are fundamentally incompatible with the Euclidean L2 distance metric used by the position-based KD-trees.

Signed-off-by: Paul Verhoeckx <paul.verhoeckx@nobleo.nl>
Signed-off-by: Paul Verhoeckx <paul.verhoeckx@nobleo.nl>
Signed-off-by: Paul Verhoeckx <paul.verhoeckx@nobleo.nl>
Signed-off-by: Paul Verhoeckx <paul.verhoeckx@nobleo.nl>
@PaulVerhoeckx
PaulVerhoeckx force-pushed the feature/use-kd-tree-for-landmark-map-search branch from 4ce4fb8 to 2c0a8aa Compare August 19, 2026 09:51
Signed-off-by: Paul Verhoeckx <paul.verhoeckx@nobleo.nl>
Signed-off-by: Paul Verhoeckx <paul.verhoeckx@nobleo.nl>
Signed-off-by: Paul Verhoeckx <paul.verhoeckx@nobleo.nl>
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