44 #include <pcl/registration/correspondence_estimation.h>
45 #include <pcl/registration/default_convergence_criteria.h>
46 #include <pcl/registration/registration.h>
47 #include <pcl/registration/transformation_estimation_point_to_plane_lls.h>
48 #include <pcl/registration/transformation_estimation_svd.h>
49 #include <pcl/registration/transformation_estimation_symmetric_point_to_plane_lls.h>
51 #include <pcl/pcl_config.h>
97 template <
typename Po
intSource,
typename Po
intTarget,
typename Scalar =
float>
113 using Ptr = shared_ptr<IterativeClosestPoint<PointSource, PointTarget, Scalar>>;
115 shared_ptr<const IterativeClosestPoint<PointSource, PointTarget, Scalar>>;
151 TransformationEstimationSVD<PointSource, PointTarget, Scalar>());
202 const auto fields = pcl::getFields<PointSource>();
204 for (
const auto& field : fields) {
205 if (field.name ==
"x")
207 else if (field.name ==
"y")
209 else if (field.name ==
"z")
211 else if (field.name ==
"normal_x") {
215 else if (field.name ==
"normal_y") {
219 else if (field.name ==
"normal_z") {
235 const auto fields = pcl::getFields<PointSource>();
237 for (
const auto& field : fields) {
238 if (field.name ==
"normal_x" || field.name ==
"normal_y" ||
239 field.name ==
"normal_z") {
339 template <
typename Po
intSource,
typename Po
intTarget,
typename Scalar =
float>
359 shared_ptr<IterativeClosestPointWithNormals<PointSource, PointTarget, Scalar>>;
366 reg_name_ =
"IterativeClosestPointWithNormals";
390 symmetric_transformation_estimation->setEnforceSameDirectionNormals(
420 auto symmetric_transformation_estimation = dynamic_pointer_cast<
425 if (symmetric_transformation_estimation)
426 symmetric_transformation_estimation->setEnforceSameDirectionNormals(
448 const Matrix4& transform)
override;
460 #include <pcl/registration/impl/icp.hpp>
462 #if !defined(PCL_NO_PRECOMPILE) && !defined(PCL_REGISTRATION_ICP_CPP_)
IterativeClosestPoint provides a base implementation of the Iterative Closest Point algorithm.
typename PointCloudSource::ConstPtr PointCloudSourceConstPtr
typename Registration< PointSource, PointTarget, Scalar >::Matrix4 Matrix4
std::size_t y_idx_offset_
std::size_t nz_idx_offset_
bool use_reciprocal_correspondence_
The correspondence type used for correspondence estimation.
void setUseReciprocalCorrespondences(bool use_reciprocal_correspondence)
Set whether to use reciprocal correspondence or not.
IterativeClosestPoint & operator=(const IterativeClosestPoint &)=delete
typename PointCloudTarget::ConstPtr PointCloudTargetConstPtr
typename Registration< PointSource, PointTarget, Scalar >::PointCloudTarget PointCloudTarget
std::size_t ny_idx_offset_
shared_ptr< IterativeClosestPoint< PointSource, PointTarget, Scalar > > Ptr
bool need_source_blob_
Checks for whether estimators and rejectors need various data.
typename PointCloudTarget::Ptr PointCloudTargetPtr
typename Registration< PointSource, PointTarget, Scalar >::PointCloudSource PointCloudSource
pcl::registration::DefaultConvergenceCriteria< Scalar >::Ptr convergence_criteria_
IterativeClosestPoint & operator=(IterativeClosestPoint &&)=delete
bool getUseReciprocalCorrespondences() const
Obtain whether reciprocal correspondence are used or not.
IterativeClosestPoint()
Empty constructor.
void setInputTarget(const PointCloudTargetConstPtr &cloud) override
Provide a pointer to the input target (e.g., the point cloud that we want to align the input source t...
PointIndices::ConstPtr PointIndicesConstPtr
bool source_has_normals_
Internal check whether source dataset has normals or not.
virtual void transformCloud(const PointCloudSource &input, PointCloudSource &output, const Matrix4 &transform)
Apply a rigid transform to a given dataset.
virtual void determineRequiredBlobData()
Looks at the Estimators and Rejectors and determines whether their blob-setter methods need to be cal...
std::size_t nx_idx_offset_
Normal fields offset.
IterativeClosestPoint(IterativeClosestPoint &&)=delete
void computeTransformation(PointCloudSource &output, const Matrix4 &guess) override
Rigid transformation computation method with initial guess.
PointIndices::Ptr PointIndicesPtr
void setNumberOfThreads(unsigned int nr_threads)
Set the number of threads to use.
pcl::registration::DefaultConvergenceCriteria< Scalar >::Ptr getConvergeCriteria()
Returns a pointer to the DefaultConvergenceCriteria used by the IterativeClosestPoint class.
IterativeClosestPoint(const IterativeClosestPoint &)=delete
Due to convergence_criteria_ holding references to the class members, it is tricky to correctly imple...
void setInputSource(const PointCloudSourceConstPtr &cloud) override
Provide a pointer to the input source (e.g., the point cloud that we want to align to the target)
~IterativeClosestPoint() override=default
Empty destructor.
bool target_has_normals_
Internal check whether target dataset has normals or not.
typename PointCloudSource::Ptr PointCloudSourcePtr
shared_ptr< const IterativeClosestPoint< PointSource, PointTarget, Scalar > > ConstPtr
std::size_t z_idx_offset_
std::size_t x_idx_offset_
XYZ fields offset.
IterativeClosestPointWithNormals is a special case of IterativeClosestPoint, that uses a transformati...
IterativeClosestPointWithNormals()
Empty constructor.
void setUseSymmetricObjective(bool use_symmetric_objective)
Set whether to use a symmetric objective function or not.
shared_ptr< IterativeClosestPointWithNormals< PointSource, PointTarget, Scalar > > Ptr
typename IterativeClosestPoint< PointSource, PointTarget, Scalar >::PointCloudSource PointCloudSource
bool getUseSymmetricObjective() const
Obtain whether a symmetric objective is used or not.
bool use_symmetric_objective_
Type of objective function (asymmetric vs.
~IterativeClosestPointWithNormals() override=default
Empty destructor.
void setEnforceSameDirectionNormals(bool enforce_same_direction_normals)
Set whether or not to negate source or target normals on a per-point basis such that they point in th...
void transformCloud(const PointCloudSource &input, PointCloudSource &output, const Matrix4 &transform) override
Apply a rigid transform to a given dataset.
bool getEnforceSameDirectionNormals() const
Obtain whether source or target normals are negated on a per-point basis such that they point in the ...
typename IterativeClosestPoint< PointSource, PointTarget, Scalar >::Matrix4 Matrix4
bool enforce_same_direction_normals_
Whether or not to negate source and/or target normals such that they point in the same direction in t...
shared_ptr< const IterativeClosestPointWithNormals< PointSource, PointTarget, Scalar > > ConstPtr
typename IterativeClosestPoint< PointSource, PointTarget, Scalar >::PointCloudTarget PointCloudTarget
Registration represents the base registration class for general purpose, ICP-like methods.
virtual void setInputSource(const PointCloudSourceConstPtr &cloud)
Provide a pointer to the input source (e.g., the point cloud that we want to align to the target)
std::string reg_name_
The registration method name.
Matrix4 transformation_
The transformation matrix estimated by the registration method.
virtual void setInputTarget(const PointCloudTargetConstPtr &cloud)
Provide a pointer to the input target (e.g., the point cloud that we want to align the input source t...
CorrespondenceEstimationPtr correspondence_estimation_
A CorrespondenceEstimation object, used to estimate correspondences between the source and the target...
int nr_iterations_
The number of iterations the internal optimization ran for (used internally).
Eigen::Matrix< Scalar, 4, 4 > Matrix4
CorrespondencesPtr correspondences_
The set of correspondences determined at this ICP step.
TransformationEstimationPtr transformation_estimation_
A TransformationEstimation object, used to calculate the 4x4 rigid transformation.
double transformation_rotation_epsilon_
The maximum rotation difference between two consecutive transformations in order to consider converge...
std::vector< CorrespondenceRejectorPtr > correspondence_rejectors_
The list of correspondence rejectors to use.
DefaultConvergenceCriteria represents an instantiation of ConvergenceCriteria, and implements the fol...
shared_ptr< DefaultConvergenceCriteria< Scalar > > Ptr
Defines functions, macros and traits for allocating and using memory.
shared_ptr< T > make_shared(Args &&... args)
Returns a pcl::shared_ptr compliant with type T's allocation policy.
shared_ptr< ::pcl::PointIndices > Ptr
shared_ptr< const ::pcl::PointIndices > ConstPtr