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

chore(ndt_scan_matcher): refactor NDT map update #6505

Merged
Merged
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
14 changes: 5 additions & 9 deletions localization/ndt_scan_matcher/src/map_update_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,19 +151,15 @@
return false; // No update
}

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<pcl::shared_ptr<pcl::PointCloud<PointTarget>>> points_pcl(add_size);

for (size_t i = 0; i < add_size; i++) {
points_pcl[i] = pcl::make_shared<pcl::PointCloud<PointTarget>>();
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::PointCloud<PointTarget>>();

pcl::fromROSMsg(map.pointcloud, *cloud);
ndt.addTarget(cloud, map.cell_id);

Check notice on line 162 in localization/ndt_scan_matcher/src/map_update_module.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

✅ Getting better: Complex Method

MapUpdateModule::update_ndt decreases in cyclomatic complexity from 10 to 9, threshold = 9. This function has many conditional statements (e.g. if, for, while), leading to lower code health. Avoid adding more conditionals and code to it without refactoring.
}

// Remove pcd
Expand Down
Loading