Skip to content

Commit 145734c

Browse files
anhnv3991SakodaShintaro
authored andcommitted
feat(ndt_scan_matcher): zero mutex blocking for ndt map update (autowarefoundation#6480)
Added a dummy pointer to delay the destructor of NDT when switching ndt ptr Signed-off-by: anhnv3991 <anh.nguyen.2@tier4.jp>
1 parent 94e5f48 commit 145734c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

localization/ndt_scan_matcher/src/map_update_module.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ void MapUpdateModule::update_map(const geometry_msgs::msg::Point & position)
7070
// lock and rebuild ndt_ptr_
7171
if (need_rebuild_) {
7272
ndt_ptr_mutex_->lock();
73+
7374
auto param = ndt_ptr_->getParams();
7475

7576
ndt_ptr_.reset(new NdtType);
@@ -88,10 +89,13 @@ void MapUpdateModule::update_map(const geometry_msgs::msg::Point & position)
8889
update_ndt(position, *secondary_ndt_ptr_);
8990

9091
ndt_ptr_mutex_->lock();
92+
auto dummy_ptr = ndt_ptr_;
9193
auto input_source = ndt_ptr_->getInputSource();
9294
ndt_ptr_ = secondary_ndt_ptr_;
9395
ndt_ptr_->setInputSource(input_source);
9496
ndt_ptr_mutex_->unlock();
97+
98+
dummy_ptr.reset();
9599
}
96100

97101
secondary_ndt_ptr_.reset(new NdtType);

0 commit comments

Comments
 (0)