From 61a1e0b1a3bfd189c8c84b39259e1e6b845d868a Mon Sep 17 00:00:00 2001 From: anhnv3991 Date: Wed, 28 Feb 2024 12:57:59 +0700 Subject: [PATCH 1/2] Tested Signed-off-by: anhnv3991 --- .../src/map_update_module.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/localization/ndt_scan_matcher/src/map_update_module.cpp b/localization/ndt_scan_matcher/src/map_update_module.cpp index 950457f0d49b1..3e5b6ca3b58c6 100644 --- a/localization/ndt_scan_matcher/src/map_update_module.cpp +++ b/localization/ndt_scan_matcher/src/map_update_module.cpp @@ -152,20 +152,17 @@ bool MapUpdateModule::update_ndt(const geometry_msgs::msg::Point & position, Ndt } const auto exe_start_time = std::chrono::system_clock::now(); - const size_t add_size = maps_to_add.size(); // Perform heavy processing outside of the lock scope - std::vector>> points_pcl(add_size); - - for (size_t i = 0; i < add_size; i++) { - points_pcl[i] = pcl::make_shared>(); - pcl::fromROSMsg(maps_to_add[i].pointcloud, *points_pcl[i]); - } - + // Add pcd - for (size_t i = 0; i < add_size; i++) { - ndt.addTarget(points_pcl[i], maps_to_add[i].cell_id); + for (auto& map : maps_to_add) + { + auto cloud = pcl::make_shared>(); + + pcl::fromROSMsg(map.pointcloud, *cloud); + ndt.addTarget(cloud, map.cell_id); } - + // Remove pcd for (const std::string & map_id_to_remove : map_ids_to_remove) { ndt.removeTarget(map_id_to_remove); From 73ac31bb63e43397cc79094eefde45b632043910 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 28 Feb 2024 07:08:32 +0000 Subject: [PATCH 2/2] style(pre-commit): autofix --- localization/ndt_scan_matcher/src/map_update_module.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/localization/ndt_scan_matcher/src/map_update_module.cpp b/localization/ndt_scan_matcher/src/map_update_module.cpp index 3e5b6ca3b58c6..31d1c6588165f 100644 --- a/localization/ndt_scan_matcher/src/map_update_module.cpp +++ b/localization/ndt_scan_matcher/src/map_update_module.cpp @@ -153,16 +153,15 @@ bool MapUpdateModule::update_ndt(const geometry_msgs::msg::Point & position, Ndt const auto exe_start_time = std::chrono::system_clock::now(); // Perform heavy processing outside of the lock scope - + // Add pcd - for (auto& map : maps_to_add) - { + for (auto & map : maps_to_add) { auto cloud = pcl::make_shared>(); - + pcl::fromROSMsg(map.pointcloud, *cloud); ndt.addTarget(cloud, map.cell_id); } - + // Remove pcd for (const std::string & map_id_to_remove : map_ids_to_remove) { ndt.removeTarget(map_id_to_remove);