Skip to content
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

Add nD-NDT maps to Beluga #309

Closed
hidmic opened this issue Feb 9, 2024 · 7 comments
Closed

Add nD-NDT maps to Beluga #309

hidmic opened this issue Feb 9, 2024 · 7 comments
Assignees
Labels
cpp Related to C++ code enhancement New feature or request

Comments

@hidmic
Copy link
Collaborator

hidmic commented Feb 9, 2024

Feature description

Connected to #93. Before we can implement NDT based sensor models in Beluga, we need an efficient data structure for NDT maps of arbitrary dimension.

Implementation considerations

https://github.com/cogsys-tuebingen/cslibs_ndt may be of interest.

@hidmic hidmic added enhancement New feature or request cpp Related to C++ code labels Feb 9, 2024
@serraramiro1
Copy link
Contributor

What about https://github.com/Tessil/robin-map ? This is the library Kiss-ICP uses and I had very good results with.
It contains std::unordered_map drop-in replacements depending on your needs.

Here're some benchmarks:
https://tessil.github.io/2016/08/29/benchmark-hopscotch-map.html

@hidmic
Copy link
Collaborator Author

hidmic commented Mar 6, 2024

@serraramiro1 how would you lay out NDT maps using those data structures? I imagine we will need some form of spatial indexing for speed when we get to #311.

@serraramiro1
Copy link
Contributor

@hidmic
I'm not completely sure if we need spatial indexing here.

Spatial indexing is usually good for complex queries, like intersections between complex shapes.

In this case we can leverage the map being discretized.
I'm thinking of:

NDT map represented as Discretized cell -> Normal Distribution hash map.

Then for getting likelihood for a point {x, y} is as easy as

discretized_cell = {floor(x / resolution), floor(y / resolution)};
if discretized_cell not in map:
      return MINIMUM_LIKELIHOOD
return map[discretized_cell].likelihood(x,y)

Hashing integers is almost free and I don't think doing spatial indexing will outperform this.

I might be overlooking something tho.

Thoughts?

@hidmic
Copy link
Collaborator Author

hidmic commented Mar 6, 2024

IIRC NDT maps also use some shifted copies to deal with boundary effects, but yeah, that can be sorted out with cell hashes. Eventually we may want to be smart about how we run over the pointcloud to maximize cache efficiency (hash maps are O(1) but memory I/O is not). I'll try and take a look at at robin_map to see what it can offer in that sense. For now, the approach makes sense to me if @nahueespinosa is OK with the extra dependency (has is it been released anywhere already?).

@nahueespinosa
Copy link
Member

If the idea is to use the drop-in replacements for std::unordered_map, then I would support implementing a class with the necessary accessor methods where the underlying map type is a template parameter. This way we don't have to add the extra dependency to beluga core, and instead defer that to the concrete implementation packages.

nahueespinosa pushed a commit that referenced this issue Mar 12, 2024
### Proposed changes

Needed to work in #309 as our NDT generated maps are in HDF5 format. 

#### Type of change

- [ ] 🐛 Bugfix (change which fixes an issue)
- [x] 🚀 Feature (change which adds functionality)
- [ ] 📚 Documentation (change which fixes or extends documentation)

### Checklist

_Put an `x` in the boxes that apply. This is simply a reminder of what
we will require before merging your code._

- [x] Lint and unit tests (if any) pass locally with my changes
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] I have added necessary documentation (if appropriate)
- [x] All commits have been signed for
[DCO](https://developercertificate.org/)

---------

Signed-off-by: Ramiro Serra <[email protected]>
@hidmic
Copy link
Collaborator Author

hidmic commented Apr 11, 2024

As of #336 and #338, we kinda have a first 2D variant. I'll keep this one open until we land a 3D variant.

@serraramiro1
Copy link
Contributor

The 3D variant was introduced with #422

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cpp Related to C++ code enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants