Skip to content

Commit

Permalink
feat(ndt_scan_matcher): zero mutex blocking for ndt map update (#6480)
Browse files Browse the repository at this point in the history
Added a dummy pointer to delay the destructor of NDT when switching ndt ptr

Signed-off-by: anhnv3991 <anh.nguyen.2@tier4.jp>
Signed-off-by: Kotaro Yoshimoto <pythagora.yoshimoto@gmail.com>
  • Loading branch information
anhnv3991 authored and HansRobo committed Mar 12, 2024
1 parent 87198ed commit 833a099
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions localization/ndt_scan_matcher/src/map_update_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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);
Expand Down

0 comments on commit 833a099

Please sign in to comment.