-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplify chunked octree traversals #84
Simplify chunked octree traversals #84
Conversation
The initial implementation did not properly distinguish pointers-to-const (i.e. `const T*`) from const pointers (i.e. `T* const`), resulting in complicated code and incorrect handling of some edge cases. The new version's code is cleaner and shorter, and more closely aligns with standard C++ syntax: * pointer-to-const: `ChunkedNdtreeNodePtr<const YourChunkType>` * const pointer: `const ChunkedNdtreeNodePtr<YourChunkType>` * const pointer-to-const: `const ChunkedNdtreeNodePtr<const YourChunkType>`
Instead of first calling hasChild and then retrieving a reference with *getChild, this change directly uses the pointer returned by getChild, avoiding a double lookup and improving efficiency. With C++17's if condition init-statements, the code remains clean and easy to read.
7c9a2fc
to
3de0323
Compare
const auto num_queries = index_view.shape(0); | ||
// Create the raw results array and wrap it in a Python capsule that | ||
// deallocates it when all references to it expire | ||
auto* results = new float[num_queries]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume that's nanobind that wants to have raw memory fun rather than raii things?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I was also a bit surprised. Their docs seem to suggest this approach, and I couldn't find an RAII-based alternative.
I read through it, seems like a lot of clean-up and unification and typing changes but overall it's not too complicated to follow in my view. |
5be9501
to
75f4edf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good.
This reverts commit 75f4edf, as we believe its changes are not yet ready for release. Tracy is configured through CMake options, part of which are converted to C++ compile definitions. Since they affect both Tracy's binary and headers, the same options/definitions must be set when compiling Tracy's system library, wavemap C++ library (CMake), and its ROS1 interface (catkin). A complicating factor is that catkin ignores standard CMake features like inheriting a linked library's PUBLIC definitions. We will reintroduce Tracy-support once we find a cleaner, less error-prone way to integrate it into the project.
Thanks @LionelOtt. I'll update the Changelogs and document the API changes, and then we can merge it. |
Description
Release 2.0.0 introduced experimental
NodePtr
andNodeRef
classes, enabling traversal of chunked octrees as if they were regular octrees. This PR finalizes their implementation, uses them to simplify map operations and measurement integrators, and extends theQueryAccelerator
to support chunked octrees. Benchmarks confirm these changes improve code clarity while slightly enhancing performance.Type of change
Detailed Summary
Prior to this PR, handling chunked octrees involved explicit reasoning about chunks, relative node positions, and parent-child chunk boundaries. This approach made the code harder to read, maintain, and debug.
Release 2.0.0 introduced
NodePtr
andNodeRef
, inspired by STL’sstd::vector<bool>::bitref
, to emulate the semantics of standard octree nodes for chunked octrees. However, their implementation was experimental, and the performance impact compared to directly interacting with chunks was uncertain.This PR:
NodePtr
andNodeRef
.QueryAccelerator
to supportHashedChunkedWaveletOctrees
.Extensive benchmarks show that these changes not only simplify the codebase but also slightly improve performance.
In addition, several older code sections were cleaned up. While most changes are internal, notable updates affecting users are documented below.
API Changes
List any changes to wavemap's APIs to help users update their code. Write "None" if there are no changes.
C++ API:
Additions
QueryAccelerator
now also supportsHashedChunkedWaveletOctrees
ChunkedNdtree::NodeRef
Refactoring
using ... = ...
) nested in the Map classes have been moved or renamedPython API:
Additions
ROS1 Interface:
Refactoring
TfTransformer
now returns the transform by value, and indicates lookup failures by returning std::nulloptReview Notes
@LionelOtt A general review would be great. Let me know if some parts of the code are difficult to follow or if the purpose of certain methods or classes is unclear. Then I'll add more comments and docstrings.
Testing
Automated Tests
The
NodePtr
andNodeRef
classes are thoroughly tested via thendtree
data structure, map, and measurement integrator test suites. Additionally, theQueryAccelerator
test suite has been extended to coverQueryAccelerator<HashedChunkedWaveletOctree>
.Manual Tests
The changes were manually tested by rerunning the Demos on an AMD laptop and an Intel desktop.
Benchmarks (To be completed by maintainers)
Newer College 20cm
Newer College 5cm
Pantopic Flat 5cm
Pantopic Flat 2cm
Note that we leave out the plots comparing the accuracy-over-distance of
proposed
andv2.1.2
, as they fully overlap. The plots forv2.1.2
can be seen in PR #83.Checklist
General
Documentation (where applicable)