ethz-asl / wavemap

Fast, efficient and accurate multi-resolution, multi-sensor 3D occupancy mapping
https://ethz-asl.github.io/wavemap/
BSD 3-Clause "New" or "Revised" License
434 stars 38 forks source link

Address failing DCHECKs for Morton encoding #35

Closed victorreijgwart closed 1 year ago

victorreijgwart commented 1 year ago

Description

This PR addresses issue #32 regarding failing DCHECKs in the Morton encoder.

Type of change

Detailed summary

Wavemap's implementation of Morton encoding does not support negative indices. Specifically, the conversion (Index -> Morton -> Index) is reversible for positive coefficients, but for negative coefficients, their truncated two's complement is returned instead.

The DCHECK that failed was there to alert users when a negative index is Morton encoded since I originally thought this non-reversible conversion would only be requested by accident. However, most of wavemap's code only performs one-way conversions (Index -> Morton) and uses the Morton numbers to compute relative offsets. These are valid regardless of the sign and not problematic. It would be possible to update wavemap's code to only Morton encode positive indices, but this would often require back-and-forth conversions that make the code harder to read and slightly less efficient.

The changes in this PR:

Fixes #32

Testing

The changes were tested through the regular unit tests and by manually running the new code on the demo datasets.

Checklist:

victorreijgwart commented 1 year ago

/prepare-release patch

victorreijgwart commented 1 year ago

Thanks for reviewing @LionelOtt!