Skip to content
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

fix(ndt_scan_matcher): add a bool return indicating whether ndt has been updated in update_ndt #6502

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class MapUpdateModule
friend class NDTScanMatcher;

// Update the specified NDT
void update_ndt(const geometry_msgs::msg::Point & position, NdtType & ndt);
bool update_ndt(const geometry_msgs::msg::Point & position, NdtType & ndt);
void update_map(const geometry_msgs::msg::Point & position);
[[nodiscard]] bool should_update_map(const geometry_msgs::msg::Point & position);
void publish_partial_pcd_map();
Expand Down
13 changes: 9 additions & 4 deletions localization/ndt_scan_matcher/src/map_update_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@
// the main ndt_ptr_) overlap, the latency of updating/alignment reduces partly.
// If the updating is done the main ndt_ptr_, either the update or the NDT
// align will be blocked by the other.
update_ndt(position, *secondary_ndt_ptr_);
const bool updated = update_ndt(position, *secondary_ndt_ptr_);

Check warning on line 90 in localization/ndt_scan_matcher/src/map_update_module.cpp

View check run for this annotation

Codecov / codecov/patch

localization/ndt_scan_matcher/src/map_update_module.cpp#L90

Added line #L90 was not covered by tests
if (!updated) {
last_update_position_ = position;
return;

Check warning on line 93 in localization/ndt_scan_matcher/src/map_update_module.cpp

View check run for this annotation

Codecov / codecov/patch

localization/ndt_scan_matcher/src/map_update_module.cpp#L93

Added line #L93 was not covered by tests
}

ndt_ptr_mutex_->lock();
auto input_source = ndt_ptr_->getInputSource();
Expand All @@ -106,7 +110,7 @@
publish_partial_pcd_map();
}

void MapUpdateModule::update_ndt(const geometry_msgs::msg::Point & position, NdtType & ndt)
bool MapUpdateModule::update_ndt(const geometry_msgs::msg::Point & position, NdtType & ndt)

Check warning on line 113 in localization/ndt_scan_matcher/src/map_update_module.cpp

View check run for this annotation

Codecov / codecov/patch

localization/ndt_scan_matcher/src/map_update_module.cpp#L113

Added line #L113 was not covered by tests
{
auto request = std::make_shared<autoware_map_msgs::srv::GetDifferentialPointCloudMap::Request>();

Expand All @@ -128,7 +132,7 @@
while (status != std::future_status::ready) {
RCLCPP_INFO(logger_, "waiting response");
if (!rclcpp::ok()) {
return;
return false; // No update
}
status = result.wait_for(std::chrono::seconds(1));
}
Expand All @@ -140,7 +144,7 @@
logger_, "Update map (Add: %lu, Remove: %lu)", maps_to_add.size(), map_ids_to_remove.size());
if (maps_to_add.empty() && map_ids_to_remove.empty()) {
RCLCPP_INFO(logger_, "Skip map update");
return;
return false; // No update

Check warning on line 147 in localization/ndt_scan_matcher/src/map_update_module.cpp

View check run for this annotation

Codecov / codecov/patch

localization/ndt_scan_matcher/src/map_update_module.cpp#L147

Added line #L147 was not covered by tests
}

const auto exe_start_time = std::chrono::system_clock::now();
Expand Down Expand Up @@ -170,6 +174,7 @@
std::chrono::duration_cast<std::chrono::microseconds>(exe_end_time - exe_start_time).count();
const auto exe_time = static_cast<double>(duration_micro_sec) / 1000.0;
RCLCPP_INFO(logger_, "Time duration for creating new ndt_ptr: %lf [ms]", exe_time);
return true; // Updated
}

void MapUpdateModule::publish_partial_pcd_map()
Expand Down
Loading