catec / amcl3d

Adaptive Monte Carlo Localization (AMCL) in 3D.
Apache License 2.0
195 stars 51 forks source link

Trouble generating occupancy grid #2

Closed arjvn closed 3 years ago

arjvn commented 3 years ago

Hi! I'm having some trouble generating my occupancy grid. The program gets stuck on the "Computing 3D occupancy grid. This will take some time..." info prompt for about an hour. After which it tells me that the that the process has died. I generate the map.ot with the help of octomap_server and LeGO-LOAM. Does anyone have any advice on what I could do?

msalvago commented 3 years ago

Hi @arjvn. Could you provide us the *.ot file that you're using to generate the occupancy grid?

arjvn commented 3 years ago

Hi, thanks for responding. I've tried these two .ot files here is a link: https://drive.google.com/file/d/1FhtKBZ3N0eaPpuvn0h4UYyQajrZNefXl/view?usp=sharing

msalvago commented 3 years ago

Hi @arjvn, we've been checking the problem with your .ot files.

The problem is due to the size of your octomap. When the occupancy grid is generated, it creates a Grid3dCell vector called "grid" where the size of each element is 8 bytes. This vector's size depends on the map's size and the octomap's resolution (ComputeGrid method in PointCloudTools.cpp). If the map is too large, the size of the grid also becomes too large, causing the program to crash.

The memory needed to create the grid is calculated by:

mem = (map_size_z / octomap_resolution) (map_size_y / octomap_resolution) (map_size_z / octomap_resolution ) * 8 bytes

In one of your octomaps, this value is approximately 60GB. To workaround the issue you could reduce the size of your .ot files or change the octomap resolution to reduce the size of the grid.

arjvn commented 3 years ago

Alright thanks, I will try this out. Would you know/ have a recommendation of how big of a map I can generate without the program crashing?

msalvago commented 3 years ago

Hi @arjvn,

It depends on the computational capacity of your computer, you can use the previous formula as a guideline to check whether the map's size is valid or not.