From e64415bd26f9a7c9a7a4cc1ec6e7c6cd578e7d9a Mon Sep 17 00:00:00 2001 From: Anh Nguyen Date: Wed, 28 Feb 2024 05:21:28 +0700 Subject: [PATCH] feat(ndt_scan_matcher): zero mutex blocking for ndt map update (#6480) Added a dummy pointer to delay the destructor of NDT when switching ndt ptr Signed-off-by: anhnv3991 --- localization/ndt_scan_matcher/src/map_update_module.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/localization/ndt_scan_matcher/src/map_update_module.cpp b/localization/ndt_scan_matcher/src/map_update_module.cpp index d00f40b0b382c..5661ba5aa7a6a 100644 --- a/localization/ndt_scan_matcher/src/map_update_module.cpp +++ b/localization/ndt_scan_matcher/src/map_update_module.cpp @@ -70,6 +70,7 @@ void MapUpdateModule::update_map(const geometry_msgs::msg::Point & position) // lock and rebuild ndt_ptr_ if (need_rebuild_) { ndt_ptr_mutex_->lock(); + auto param = ndt_ptr_->getParams(); auto input_source = ndt_ptr_->getInputSource(); @@ -90,10 +91,13 @@ void MapUpdateModule::update_map(const geometry_msgs::msg::Point & position) update_ndt(position, *secondary_ndt_ptr_); ndt_ptr_mutex_->lock(); + auto dummy_ptr = ndt_ptr_; auto input_source = ndt_ptr_->getInputSource(); ndt_ptr_ = secondary_ndt_ptr_; ndt_ptr_->setInputSource(input_source); ndt_ptr_mutex_->unlock(); + + dummy_ptr.reset(); } secondary_ndt_ptr_.reset(new NdtType);