-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[AMCL] 9x initialisation (and reset) speed increase #4941
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Guillaume Doisy <[email protected]>
Signed-off-by: Guillaume Doisy <[email protected]>
Codecov ReportAll modified and coverable lines are covered by tests ✅
|
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 agree. I’m also not entirely clear on reading this how the priority queue ever worked considering no comparator for the class/struct was provided. I don’t see any reason except maybe someone thinking it would improve caching efficiency to do patches near each other consecutively.
I assume the queue change is what resulted in the major runtime benefits, but can you confirm that?
@mikeferguson do you see any reason to not merge this?
@@ -130,18 +129,14 @@ void enqueue( | |||
return; | |||
} | |||
|
|||
map->cells[MAP_INDEX(map, i, j)].occ_dist = distance * map->scale; | |||
const int map_index = MAP_INDEX(map, i, j); |
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.
This could be done before L120 to remove another MAPINDEX look up on L120.
This code was added 15 years ago - by Gerkey (who generally knows what he is doing) On line 82-87, there is a less-than comparator defined for CellData - it compares the occ_dist of each of the cells. The order in which cells are expanded is important - since we're basically doing wavefront expansion from occupied cells and on L120 we only ever set the occ_dist once. In theory, you will get nearly the same map - but possibly not identically the same map if you don't enforce expanding the closest cells first. I see at least three possible options here:
|
Ah, I didn't see the comparator in the priority queue constructor nor after the class so I missed it. These are good points, thanks Fergs! I think (3) is the most sensible since it is both the least impactful and easiest to validate. Though 2 should be similarly simple to test. @doisyg what do you think? |
Basic Info
Description of contribution in a few bullet points
On VERY big maps, the method
map_update_cspace
of AMCL takes ages. Which makes AMCL long to start, or reset (when for instance changing a dynamic parameter needingreinit_laser = true
)3 tricks by order of impact:
std::queue
instead ofstd::priority_queue
. But this is why this is a draft, I cannot understand whystd::priority_queue
was needed in the first place (and which criteria it used for ordering), so I am not sure.CellData
copy withemplace
instead of push.On a big map, AMCL activation times drops from 22s to 2.4s on my machine.
Description of documentation updates required from your changes
Description of how this change was tested
Future work that may be required in bullet points
For Maintainers: