Skip to content

[filters] Reject out-of-grid centroid coordinates - #6465

Draft
fallenmi wants to merge 1 commit into
PointCloudLibrary:masterfrom
fallenmi:agent/fix-voxel-grid-index-bounds
Draft

[filters] Reject out-of-grid centroid coordinates#6465
fallenmi wants to merge 1 commit into
PointCloudLibrary:masterfrom
fallenmi:agent/fix-voxel-grid-index-bounds

Conversation

@fallenmi

Copy link
Copy Markdown

Summary

  • reject component coordinates outside the voxel grid before flattening them
  • apply the same bounds contract to the typed and PCLPointCloud2 overloads
  • add a deterministic 2x2x2 regression for positive, negative, and mixed-axis aliases

Root cause

getCentroidIndexAt() flattened (i, j, k) into a scalar index and only checked that scalar against leaf_layout_. Different coordinate triples can produce the same flattened index, so an out-of-grid coordinate could return an unrelated occupied voxel instead of -1.

For example, in a fully occupied 2x2x2 grid, (2, 0, 0) is outside the grid but currently aliases the valid scalar index for (0, 1, 0). The new component-wise guard rejects the coordinate before subtraction and flattening.

Validation

  • reproduced the bug on current master in both overloads with six out-of-grid aliases
  • built test_filters successfully
  • focused regression: 100 consecutive passes
  • full test_filters binary: 22/22 tests passed
  • canonical CTest target filters_filters: 1/1 passed
  • clang-format 14 changed-lines check and git diff --check passed

AI assistance disclosure: OpenAI Codex helped investigate and draft this change; I reproduced the bug, reviewed every changed line, and ran the tests listed above.

Fixes #3529.

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.

getCentroidIndexAt in voxel_grid.h deliver wrong leaf_layout_[idx]

1 participant