Skip to content
Closed
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
4 changes: 2 additions & 2 deletions cpp/kiss_icp/core/Registration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ LinearSystem BuildLinearSystem(const Correspondences &correspondences, const dou
};

using correspondence_iterator = Correspondences::const_iterator;
const auto &[JTJ, JTr] = tbb::parallel_reduce(
const auto linear_system = tbb::parallel_reduce(
// Range
tbb::blocked_range<correspondence_iterator>{correspondences.cbegin(),
correspondences.cend()},
Expand All @@ -117,7 +117,7 @@ LinearSystem BuildLinearSystem(const Correspondences &correspondences, const dou
// 2nd Lambda: Parallel reduction of the private Jacboians
sum_linear_systems);

return {JTJ, JTr};
return linear_system;
Comment on lines 101 to +120
}
} // namespace

Expand Down
32 changes: 25 additions & 7 deletions cpp/kiss_icp/core/VoxelHashMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ std::tuple<Eigen::Vector3d, double> VoxelHashMap::GetClosestNeighbor(
}
}
});
return std::make_tuple(closest_neighbor, closest_distance);
return {closest_neighbor, closest_distance};
}

std::vector<Eigen::Vector3d> VoxelHashMap::Pointcloud() const {
Expand All @@ -87,11 +87,29 @@ void VoxelHashMap::Update(const std::vector<Eigen::Vector3d> &points,
}

void VoxelHashMap::Update(const std::vector<Eigen::Vector3d> &points, const Sophus::SE3d &pose) {
std::vector<Eigen::Vector3d> points_transformed(points.size());
std::transform(points.cbegin(), points.cend(), points_transformed.begin(),
[&](const auto &point) { return pose * point; });
const Eigen::Vector3d &origin = pose.translation();
Update(points_transformed, origin);
const double map_resolution = std::sqrt(voxel_size_ * voxel_size_ / max_points_per_voxel_);
std::for_each(points.cbegin(), points.cend(), [&](const auto &point) {
const Eigen::Vector3d transformed_point = pose * point;
const auto voxel = PointToVoxel(transformed_point, voxel_size_);
auto search = map_.find(voxel);
if (search != map_.end()) {
auto &voxel_points = search.value();
if (voxel_points.size() == max_points_per_voxel_ ||
std::any_of(voxel_points.cbegin(), voxel_points.cend(),
[&](const auto &voxel_point) {
return (voxel_point - transformed_point).norm() < map_resolution;
})) {
return;
}
voxel_points.emplace_back(transformed_point);
} else {
std::vector<Eigen::Vector3d> voxel_points;
voxel_points.reserve(max_points_per_voxel_);
voxel_points.emplace_back(transformed_point);
map_.emplace(voxel, std::move(voxel_points));
}
});
Comment thread
saurabh1002 marked this conversation as resolved.
Comment on lines +90 to +111
RemovePointsFarFromLocation(pose.translation());
}

void VoxelHashMap::AddPoints(const std::vector<Eigen::Vector3d> &points) {
Expand All @@ -113,7 +131,7 @@ void VoxelHashMap::AddPoints(const std::vector<Eigen::Vector3d> &points) {
std::vector<Eigen::Vector3d> voxel_points;
voxel_points.reserve(max_points_per_voxel_);
voxel_points.emplace_back(point);
map_.insert({voxel, std::move(voxel_points)});
map_.emplace(voxel, std::move(voxel_points));
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion cpp/kiss_icp/core/VoxelUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ std::vector<Eigen::Vector3d> VoxelDownsample(const std::vector<Eigen::Vector3d>
grid.reserve(frame.size());
std::for_each(frame.cbegin(), frame.cend(), [&](const auto &point) {
const auto voxel = PointToVoxel(point, voxel_size);
if (!grid.contains(voxel)) grid.insert({voxel, point});
if (!grid.contains(voxel)) grid.emplace(voxel, point);
});
std::vector<Eigen::Vector3d> frame_dowsampled;
frame_dowsampled.reserve(grid.size());
Expand Down
Loading