42 #include <pcl/registration/convergence_criteria.h>
43 #include <pcl/correspondence.h>
48 namespace registration {
64 template <
typename Scalar =
float>
67 using Ptr = shared_ptr<DefaultConvergenceCriteria<Scalar>>;
68 using ConstPtr = shared_ptr<const DefaultConvergenceCriteria<Scalar>>;
70 using Matrix4 = Eigen::Matrix<Scalar, 4, 4>;
265 for (
const auto& correspondence : correspondences)
266 mse += correspondence.distance;
267 mse /=
static_cast<double>(correspondences.size());
329 #include <pcl/registration/impl/default_convergence_criteria.hpp>
ConvergenceCriteria represents an abstract base class for different convergence criteria used in regi...
shared_ptr< ConvergenceCriteria > Ptr
shared_ptr< const ConvergenceCriteria > ConstPtr
DefaultConvergenceCriteria represents an instantiation of ConvergenceCriteria, and implements the fol...
ConvergenceState convergence_state_
The state of the convergence (e.g., why did the registration converge).
int iterations_similar_transforms_
Internal counter for the number of iterations that the internal rotation, translation,...
int getMaximumIterations() const
Get the maximum number of iterations the internal optimization should run for, as set by the user.
void setConvergenceState(ConvergenceState c)
Sets the convergence state externally (for example, when ICP does not find enough correspondences to ...
double correspondences_cur_mse_
The MSE for the current set of correspondences.
DefaultConvergenceCriteria(const int &iterations, const Matrix4 &transform, const pcl::Correspondences &correspondences)
Empty constructor.
const Matrix4 & transformation_
The current transformation obtained by the transformation estimation method.
void setAbsoluteMSE(const double mse_absolute)
Set the absolute MSE between two consecutive sets of correspondences.
void setMaximumIterations(const int nr_iterations)
Set the maximum number of iterations the internal optimization should run for.
const pcl::Correspondences & correspondences_
The current set of point correspondences between the source and the target.
const int & iterations_
The number of iterations done by the registration loop so far.
void setTranslationThreshold(const double threshold)
Set the translation threshold (maximum allowable difference between two consecutive transformations) ...
bool getFailureAfterMaximumIterations() const
Get whether the registration will fail or converge when the maximum number of iterations is reached.
Eigen::Matrix< Scalar, 4, 4 > Matrix4
void setRelativeMSE(const double mse_relative)
Set the relative MSE between two consecutive sets of correspondences.
int max_iterations_
The maximum nuyyGmber of iterations that the registration loop is to be executed.
void setMaximumIterationsSimilarTransforms(const int nr_iterations)
Set the maximum number of consecutive iterations that the internal rotation, translation,...
double getAbsoluteMSE() const
Get the absolute MSE between two consecutive sets of correspondences.
double translation_threshold_
The translation threshold is the relative translation between two iterations (0 if no translation).
~DefaultConvergenceCriteria() override=default
Empty destructor.
void setRotationThreshold(const double threshold)
Set the rotation threshold cosine angle (maximum allowable difference between two consecutive transfo...
double mse_threshold_absolute_
The absolute change from the previous MSE for the current set of correspondences.
double getTranslationThreshold() const
Get the rotation threshold cosine angle (maximum allowable difference between two consecutive transfo...
ConvergenceState getConvergenceState()
Return the convergence state after hasConverged ()
bool hasConverged() override
Check if convergence has been reached.
int getMaximumIterationsSimilarTransforms() const
Get the maximum number of consecutive iterations that the internal rotation, translation,...
double calculateMSE(const pcl::Correspondences &correspondences) const
Calculate the mean squared error (MSE) of the distance for a given set of correspondences.
void setFailureAfterMaximumIterations(const bool failure_after_max_iter)
Specifies if the registration fails or converges when the maximum number of iterations is reached.
double getRelativeMSE() const
Get the relative MSE between two consecutive sets of correspondences.
bool failure_after_max_iter_
Specifys if the registration fails or converges when the maximum number of iterations is reached.
double rotation_threshold_
The rotation threshold is the relative rotation between two iterations (as angle cosine).
double mse_threshold_relative_
The relative change from the previous MSE for the current set of correspondences, e....
double correspondences_prev_mse_
The MSE for the previous set of correspondences.
@ CONVERGENCE_CRITERIA_NO_CORRESPONDENCES
@ CONVERGENCE_CRITERIA_TRANSFORM
@ CONVERGENCE_CRITERIA_ITERATIONS
@ CONVERGENCE_CRITERIA_ABS_MSE
@ CONVERGENCE_CRITERIA_FAILURE_AFTER_MAX_ITERATIONS
@ CONVERGENCE_CRITERIA_REL_MSE
@ CONVERGENCE_CRITERIA_NOT_CONVERGED
int max_iterations_similar_transforms_
The maximum number of iterations that the internal rotation, translation, and MSE differences are all...
double getRotationThreshold() const
Get the rotation threshold cosine angle (maximum allowable difference between two consecutive transfo...
#define PCL_MAKE_ALIGNED_OPERATOR_NEW
Macro to signal a class requires a custom allocator.
Defines functions, macros and traits for allocating and using memory.
std::vector< pcl::Correspondence, Eigen::aligned_allocator< pcl::Correspondence > > Correspondences
Defines all the PCL and non-PCL macros used.