Add TSDF / ESDF / Occupancy / Decay APIs and a fast marching-cubes variant#656
Draft
fwilliams wants to merge 1 commit into
Draft
Add TSDF / ESDF / Occupancy / Decay APIs and a fast marching-cubes variant#656fwilliams wants to merge 1 commit into
fwilliams wants to merge 1 commit into
Conversation
3 tasks
14613ce to
4ec7afe
Compare
859f849 to
959d383
Compare
4ec7afe to
bedf87e
Compare
31dde5d to
a0bd959
Compare
010424d to
c700a40
Compare
a0bd959 to
63b12a2
Compare
Add native CUDA kernels and Python wrappers for TSDF and ESDF
reconstruction, occupancy mapping, dynamic-scene decay, and a fast
sparse-compact marching-cubes variant. These features sit on top of
the nanoVDB allocator-overrides change (parent PR) and share a
common `PersistentTSDFState` + `BuildPointTruncationShell` substrate.
Topology + state primitives
src/fvdb/detail/ops/BuildPointTruncationShell.{cu,h}
Shared primitive that turns `(points, base_grid, truncation_margin)`
into the set of voxels within the truncation shell. Used by both
depth and LiDAR TSDF integrators.
src/fvdb/detail/ops/PersistentTSDFState.{cu,h}
Grow-on-touch state holder for incremental integration: wraps a
monotonically-growing live grid with fixed-shape tsdf / weights /
optional feature sidecars and exposes a `grow` method that
expands the grid + sidecars atomically while preserving values
at already-live voxels.
src/python/PersistentTSDFStateBinding.cpp
Pybind11 binding for the above.
Integrators
src/fvdb/detail/ops/IntegrateTSDF.{cu,h} (modified)
Depth TSDF integrator now uses `BuildPointTruncationShell` and
`PersistentTSDFState`, and exposes a new N-frame batched entry
point `integrateTSDFBatch` that grows the union grid one frame
at a time and copy-forwards sidecars through the
persistent-state object. Bit-identical to the per-frame loop
(pinned by `test_integrate_tsdf_frames_matches_sequential`).
src/fvdb/detail/ops/IntegrateTSDFFromPoints.{cu,h}
Native LiDAR / range-sensor TSDF integrator: per-point thread
HDDA-walks the union grid and `atomicAdd`s a running-sum into
(sum_w_sdf, sum_w, sum_w_feat) accumulators within the
truncation (and optionally free-space) band. Single-frame,
with-features, and N-frames-batched variants.
src/fvdb/detail/ops/IntegrateOccupancyFromPoints.{cu,h}
LiDAR occupancy mapping with free-space carving and log-odds
updates. Single-frame and N-frames-batched variants. Same
ray-walk structure as the LiDAR TSDF integrator.
ESDF
src/fvdb/detail/ops/ComputeESDF.{cu,h}
Euclidean Signed Distance Field from an integrated narrow-band
TSDF. Composition pattern is
`dilateGrid -> esdfSeed -> N sweeps of 26-N min-propagation`,
reusing the topology-op primitives.
src/fvdb/detail/ops/DirtyMaskFromSidecars.{cu,h}
Per-voxel dirty-mask primitive that lets the incremental ESDF
variant scope work to just the voxels whose sidecars changed.
Marching cubes
src/fvdb/detail/ops/MarchingCubesFast.{cu,h}
Sparse-compact, packed-key marching cubes for fp32 / fp16 CUDA.
`marchingCubes` now dispatches to this for eligible inputs and
to `marchingCubesLegacy` (the previous default, kept verbatim)
otherwise.
src/fvdb/detail/ops/MarchingCubes.{cu,h} (modified)
Routes through to the new fast path.
Python surface
fvdb/functional/_meshing.py
Wrappers for the new N-frame + with-features + LiDAR variants
of TSDF integration, occupancy mapping (single + frames), and
ESDF (single + incremental).
fvdb/functional/_topology.py
Wrapper for `dirty_mask_from_sidecars_single`.
fvdb/grid.py
New methods on `Grid`: `decay_and_prune`,
`integrate_tsdf_frames`, `integrate_tsdf_with_features`,
`integrate_tsdf_from_points` (+ frames + with-features
variants), `integrate_occupancy_from_points` (+ frames),
`compute_esdf`, `compute_esdf_incremental`. `decay_and_prune`
is implemented entirely in Python on top of existing fvdb
sidecar + topology primitives.
fvdb/functional/__init__.py
Export the new functional names.
src/python/Bindings.cpp, src/python/GridBatchOps.cpp
Register the new C++ bindings.
Tests
tests/unit/test_persistent_tsdf_state.py
tests/unit/test_compute_esdf.py
tests/unit/test_dirty_mask.py
tests/unit/test_integrate_occupancy.py
tests/unit/test_decay_and_prune.py
tests/unit/test_basic_ops.py (extended)
Cover the new primitives, the persistent-state invariants
(`grow` semantics, sidecar carry-forward), bit-identity of the
batched-vs-sequential TSDF paths, atomic-noise tolerance for
the LiDAR/occupancy variants, and fp16-vs-fp32 numerical
agreement for the new marching-cubes fast path.
Signed-off-by: Francis Williams <francis@fwilliams.info>
63b12a2 to
cd63cb3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Native CUDA kernels and Python wrappers for TSDF and ESDF reconstruction, occupancy mapping, dynamic-scene decay, and a fast sparse-compact marching-cubes variant. These features share a common
PersistentTSDFState+BuildPointTruncationShellsubstrate.Stacked on top of #655 (nanoVDB allocator overrides). That PR should land first; the multi-frame integrator paths here depend on the allocator routing it sets up.
Topology and state primitives
BuildPointTruncationShell.{cu,h}— shared primitive that turns(points, base_grid, truncation_margin)into the set of voxels within the truncation shell. Used by both the depth and LiDAR TSDF integrators.PersistentTSDFState.{cu,h}— grow-on-touch state holder for incremental integration. Wraps a monotonically-growing live grid with fixed-shapetsdf/weights/ optionalfeaturessidecar tensors and exposes agrowmethod that expands the grid + sidecars atomically while preserving values at already-live voxels.PersistentTSDFStateBinding.cpp— pybind11 binding for the above.Integrators
IntegrateTSDF.{cu,h}(modified) — depth TSDF integrator now usesBuildPointTruncationShellandPersistentTSDFState, and exposes a new N-frame batched entry pointintegrateTSDFBatchthat grows the union grid one frame at a time and copy-forwards sidecars through the persistent-state object. Bit-identical to the per-frame loop (pinned bytest_integrate_tsdf_frames_matches_sequential).IntegrateTSDFFromPoints.{cu,h}— native LiDAR / range-sensor TSDF integrator. Per-point thread HDDA-walks the union grid andatomicAdds a running-sum into(sum_w_sdf, sum_w, sum_w_feat)accumulators within the truncation (and optionally free-space) band. Single-frame, with-features, and N-frames-batched variants.IntegrateOccupancyFromPoints.{cu,h}— LiDAR occupancy mapping with free-space carving and log-odds updates. Single-frame and N-frames-batched variants. Same ray-walk structure as the LiDAR TSDF integrator.ESDF
ComputeESDF.{cu,h}— Euclidean Signed Distance Field from an integrated narrow-band TSDF. Composition pattern isdilateGrid -> esdfSeed -> N sweeps of 26-neighbour min-propagation, reusing the existing topology-op primitives.DirtyMaskFromSidecars.{cu,h}— per-voxel dirty-mask primitive that lets the incremental ESDF variant scope work to just the voxels whose sidecars changed.Marching cubes
MarchingCubesFast.{cu,h}— sparse-compact, packed-key marching cubes for fp32 / fp16 CUDA. Surface-voxel compaction + 1-D packed-key dedup + an in-register fp16-to-fp32 cast on load. Bit-identical to the legacy at fp32 and numerically-identical at fp16 (kernels are templated on the input scalar type so there's no transient fp32 buffer).MarchingCubes.{cu,h}(modified) — the publicmarchingCubesdispatcher routes toMarchingCubesFastfor fp32 / fp16 CUDA inputs and to the previous implementation (now namedmarchingCubesLegacy, kept verbatim) for other dtype / device combinations.Python surface
Gridinfvdb/grid.py:decay_and_prune,integrate_tsdf_frames,integrate_tsdf_with_features,integrate_tsdf_from_points(+ frames + with-features variants),integrate_occupancy_from_points(+ frames),compute_esdf,compute_esdf_incremental.decay_and_pruneis implemented entirely in Python on top of existing fvdb sidecar + topology primitives.fvdb/functional/_meshing.pyandfvdb/functional/_topology.py.src/python/Bindings.cppandsrc/python/GridBatchOps.cpp.Test plan
New unit tests cover the persistent-state invariants, bit-identity of the batched-vs-sequential TSDF paths, atomic-noise tolerance for the LiDAR / occupancy variants, and fp16-vs-fp32 numerical agreement for the new marching-cubes fast path:
tests/unit/test_persistent_tsdf_state.py— 7 teststests/unit/test_compute_esdf.py— 17 teststests/unit/test_dirty_mask.py— 9 teststests/unit/test_integrate_occupancy.py— 7 teststests/unit/test_decay_and_prune.py— 9 teststests/unit/test_basic_ops.py— 16 new TSDF / MC fp16 / occupancy testsAll pass locally on the freshly-built install. Full
pytest unit/suite is green.Followups
Cross-library benchmark drivers (Replica, KITTI, Mai City, 7-Scenes, fvdb vs nvblox / VDBFusion / Open3D) for these new APIs live in a companion PR against openvdb/fvdb-reality-capture.