koide3 / small_gicp

Efficient and parallel algorithms for point cloud registration [C++, Python]
MIT License
393 stars 51 forks source link

The converged flag in RegistrationResult is wrongly labelled to false #75

Closed deliangye closed 3 months ago

deliangye commented 3 months ago

Describe the bug The converged flag in RegistrationResult is wrongly labelled to false, i.e. 0, even the registration transformation is correct.

To Reproduce Steps to reproduce the behavior: Create a simulated point cloud by sampling 4 edges of a rectangle, and register it to itself with GICP, the converged flag is zero, but the transformation is correct, an identity matrix.

Environment (please complete the following information):

koide3 commented 3 months ago

It may wrongly identify the convergence when the optimization starts from a perfect position. Could you share a snippet to reproduce the issue?

deliangye commented 3 months ago

Here is the script to reproduce the issue: replace main function in 01_basic_registration.cpp with :

int main(int argc, char** argv) {

std::vector rect_cloud; constexpr float step = 0.005; size_t num_points_in_width = floor(10 / step); for (auto c = 0u; c < num_points_in_width; ++c) { const auto x = c * step; rect_cloud.emplace_back(Eigen::Vector4f{x, 0, 0, 0}); rect_cloud.emplace_back(Eigen::Vector4f{x, 5, 0, 0}); }

size_t num_points_in_height = floor(5 / step); for (auto r = 0u; r < num_points_in_height; ++r) { const auto y = r * step; rect_cloud.emplace_back(Eigen::Vector4f{0, y, 0, 0}); rect_cloud.emplace_back(Eigen::Vector4f{10, y, 0, 0}); }

example1(rect_cloud, rect_cloud); // example2(target_points, source_points);

return 0; }

you will see the convergence flag is 0 :)

koide3 commented 3 months ago

Thanks, I could reproduce the issue. It should be fixed by https://github.com/koide3/small_gicp/pull/77 that was just merged into the main branch.