Skip to content

Commit c61ee0c

Browse files
anhnv3991karishma1911
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 4288b8b commit c61ee0c

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
auto input_source = ndt_ptr_->getInputSource();
7576

@@ -90,10 +91,13 @@ void MapUpdateModule::update_map(const geometry_msgs::msg::Point & position)
9091
update_ndt(position, *secondary_ndt_ptr_);
9192

9293
ndt_ptr_mutex_->lock();
94+
auto dummy_ptr = ndt_ptr_;
9395
auto input_source = ndt_ptr_->getInputSource();
9496
ndt_ptr_ = secondary_ndt_ptr_;
9597
ndt_ptr_->setInputSource(input_source);
9698
ndt_ptr_mutex_->unlock();
99+
100+
dummy_ptr.reset();
97101
}
98102

99103
secondary_ndt_ptr_.reset(new NdtType);

0 commit comments

Comments
 (0)