Skip to content

feat: improved ray tracing to preserve floors#2275

Merged
leshy merged 5 commits into
mainfrom
andrew/feat/improved-floor-ray-tracing
May 29, 2026
Merged

feat: improved ray tracing to preserve floors#2275
leshy merged 5 commits into
mainfrom
andrew/feat/improved-floor-ray-tracing

Conversation

@aclauer
Copy link
Copy Markdown
Collaborator

@aclauer aclauer commented May 28, 2026

Problem

Floors and other horizontal surfaces lose points due to ray clipping when more than ~1 meter from sensor.

Closes DIM-XXX

Solution

Ignore points on the same xy plane as the lidar hit from clipping. This preserves floors much better than without.

With fix:
with_planar_grace

Before fix:
before_fix

How to Test

cargo test added test to ensure same plane points aren't removed

Contributor License Agreement

  • I have read and approved the CLA.

@aclauer aclauer changed the title feat: improved floors with ray tracing feat: improved ray tracing on floors May 28, 2026
@aclauer aclauer changed the title feat: improved ray tracing on floors feat: improved ray tracing to preserve floors May 28, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@leshy
Copy link
Copy Markdown
Member

leshy commented May 28, 2026

r u ready 2 suffer #2283

@aclauer aclauer marked this pull request as ready for review May 28, 2026 15:12
@aclauer
Copy link
Copy Markdown
Collaborator Author

aclauer commented May 28, 2026

r u ready 2 suffer #2283

🥲😅

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 28, 2026

Greptile Summary

This PR fixes floor-point erasure in the ray-tracing voxel mapper by adding a z-slab protection rule: when a ray crosses z-levels, any voxel that shares the endpoint's Z index is skipped (not marked as a miss), preserving horizontal surfaces like floors.

  • A new t_max early-exit is introduced so the DDA traversal loop always terminates even when z-slab voxels are continuously skipped before the shadow-distance check can fire.
  • The past_endpoint flag is now also set from the parametric t_enter >= 1.0 check (in addition to the coordinate match), which correctly handles cases where the endpoint voxel is itself in the protected z-slab.
  • An existing unit test is updated to match the new skipping behavior, and a new ground_clipping_single_ray test with an assert!(total_clipped == 0, …) guard is added.

Confidence Score: 5/5

The change is safe to merge; the z-slab skip and t_max early exit are internally consistent and the new regression test with an assertion guards against future breakage.

The core logic is sound: the DDA loop terminates through the t_max exit when z-slab voxels are continuously skipped before the shadow-distance check can fire, parametric t_enter correctly identifies shadow territory, and the endpoint voxel is always visited before the z-slab filter applies. No defects in the changed paths were found.

No files require special attention.

Important Files Changed

Filename Overview
dimos/mapping/ray_tracing/rust/src/main.rs Adds z-slab floor protection and t_max early exit to find_misses_along_ray; updates existing DDA test and adds new ground-clipping regression test with assertion.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Loop start] --> B["t_enter = min(tx, ty, tz)"]
    B --> C{t_enter > t_max?}
    C -- Yes --> D[return — shadow zone exceeded]
    C -- No --> E{t_enter >= 1.0?}
    E -- Yes --> F[past_endpoint = true]
    E -- No --> G[Step DDA to next voxel]
    F --> G
    G --> H{x,y,z == endpoint?}
    H -- Yes --> I[past_endpoint = true; continue]
    H -- No --> J{"origin_voxel.z ≠ endpoint.z AND z == endpoint.z?"}
    J -- Yes --> K[skip — z-slab floor protection]
    J -- No --> L{past_endpoint?}
    L -- Yes --> M{dist_sq > shadow_sq?}
    M -- Yes --> D
    M -- No --> N[mark as miss if in map]
    L -- No --> O{dist_sq < grace_sq?}
    O -- Yes --> K
    O -- No --> N
    N --> A
    K --> A
    I --> A
Loading

Reviews (2): Last reviewed commit: "Enforce planar condition in test" | Re-trigger Greptile

Comment thread dimos/mapping/ray_tracing/rust/src/main.rs Outdated
Comment thread dimos/mapping/ray_tracing/rust/src/main.rs
@aclauer aclauer requested a review from a team May 28, 2026 16:38
@aclauer
Copy link
Copy Markdown
Collaborator Author

aclauer commented May 29, 2026

r u ready 2 suffer #2283

#2304

I think this might be a solution to stairs and a more general fix for floors. Would be a total experiment though.

@leshy leshy merged commit e9f8161 into main May 29, 2026
21 checks passed
@leshy leshy deleted the andrew/feat/improved-floor-ray-tracing branch May 29, 2026 03:00
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.

2 participants