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

[feat] gicp: add convergence criteria and correspondence estimation #5287

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
48 changes: 48 additions & 0 deletions registration/include/pcl/registration/gicp.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#pragma once

#include <pcl/registration/bfgs.h>
#include <pcl/registration/gicp_convergence_criteria.h>
#include <pcl/registration/icp.h>

namespace pcl {
Expand Down Expand Up @@ -76,6 +77,19 @@ class GeneralizedIterativeClosestPoint
using IterativeClosestPoint<PointSource, PointTarget>::inlier_threshold_;
using IterativeClosestPoint<PointSource, PointTarget>::min_number_correspondences_;
using IterativeClosestPoint<PointSource, PointTarget>::update_visualizer_;
using IterativeClosestPoint<PointSource, PointTarget>::correspondences_;
using IterativeClosestPoint<PointSource, PointTarget>::correspondence_estimation_;
using IterativeClosestPoint<PointSource, PointTarget>::correspondence_rejectors_;
using IterativeClosestPoint<PointSource,
PointTarget>::setUseReciprocalCorrespondences;
using IterativeClosestPoint<PointSource,
PointTarget>::getUseReciprocalCorrespondences;
using IterativeClosestPoint<PointSource, PointTarget>::determineRequiredBlobData;
using IterativeClosestPoint<PointSource, PointTarget>::use_reciprocal_correspondence_;
using IterativeClosestPoint<PointSource, PointTarget>::source_has_normals_;
using IterativeClosestPoint<PointSource, PointTarget>::target_has_normals_;
using IterativeClosestPoint<PointSource, PointTarget>::need_source_blob_;
using IterativeClosestPoint<PointSource, PointTarget>::need_target_blob_;

using PointCloudSource = pcl::PointCloud<PointSource>;
using PointCloudSourcePtr = typename PointCloudSource::Ptr;
Expand All @@ -102,6 +116,8 @@ class GeneralizedIterativeClosestPoint

using Vector6d = Eigen::Matrix<double, 6, 1>;

typename pcl::registration::GICPConvergenceCriteria<float>::Ptr convergence_criteria_;

/** \brief Empty constructor. */
GeneralizedIterativeClosestPoint()
: k_correspondences_(20)
Expand All @@ -125,6 +141,38 @@ class GeneralizedIterativeClosestPoint
estimateRigidTransformationBFGS(
cloud_src, indices_src, cloud_tgt, indices_tgt, transformation_matrix);
};
convergence_criteria_.reset(new pcl::registration::GICPConvergenceCriteria<float>(
nr_iterations_, transformation_, previous_transformation_, *correspondences_));
}

/**
* \brief Due to `convergence_criteria_` holding references to the class members,
* it is tricky to correctly implement its copy and move operations correctly. This
* can result in subtle bugs and to prevent them, these operations for GICP have
* been disabled.
*
* \todo: remove deleted ctors and assignments operations after resolving the issue
*/
GeneralizedIterativeClosestPoint(const GeneralizedIterativeClosestPoint&) = delete;
GeneralizedIterativeClosestPoint(GeneralizedIterativeClosestPoint&&) = delete;
GeneralizedIterativeClosestPoint&
operator=(const GeneralizedIterativeClosestPoint&) = delete;
GeneralizedIterativeClosestPoint&
operator=(GeneralizedIterativeClosestPoint&&) = delete;

/** \brief Returns a pointer to the GICPConvergenceCriteria used by the
* GeneralizedIterativeClosestPoint class. This allows to check the convergence state
* after the align() method as well as to configure GICPConvergenceCriteria's
* parameters not available through the GICP API before the align() method is called.
* Please note that the align method sets max_iterations_, transformation_epsilon_ and
* rotation_epsilon_ and therefore overrides the default / set values of the
* GICPConvergenceCriteria instance. \return Pointer to the
* GeneralizedIterativeClosestPoint's GICPConvergenceCriteria.
*/
inline typename pcl::registration::GICPConvergenceCriteria<float>::Ptr
getConvergeCriteria()
{
return convergence_criteria_;
}

/** \brief Provide a pointer to the input dataset
Expand Down
Loading