Point Cloud Library (PCL)  1.10.1-dev
registration.h
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Point Cloud Library (PCL) - www.pointclouds.org
5  * Copyright (c) 2010-2011, Willow Garage, Inc.
6  * Copyright (c) 2012-, Open Perception, Inc.
7  *
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  *
14  * * Redistributions of source code must retain the above copyright
15  * notice, this list of conditions and the following disclaimer.
16  * * Redistributions in binary form must reproduce the above
17  * copyright notice, this list of conditions and the following
18  * disclaimer in the documentation and/or other materials provided
19  * with the distribution.
20  * * Neither the name of the copyright holder(s) nor the names of its
21  * contributors may be used to endorse or promote products derived
22  * from this software without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
29  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
34  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35  * POSSIBILITY OF SUCH DAMAGE.
36  *
37  * $Id$
38  *
39  */
40 
41 #pragma once
42 
43 // PCL includes
44 #include <pcl/pcl_base.h>
45 #include <pcl/common/transforms.h>
46 #include <pcl/memory.h>
47 #include <pcl/pcl_macros.h>
48 #include <pcl/search/kdtree.h>
49 #include <pcl/registration/boost.h>
50 #include <pcl/registration/transformation_estimation.h>
51 #include <pcl/registration/correspondence_estimation.h>
52 #include <pcl/registration/correspondence_rejection.h>
53 
54 namespace pcl
55 {
56  /** \brief @b Registration represents the base registration class for general purpose, ICP-like methods.
57  * \author Radu B. Rusu, Michael Dixon
58  * \ingroup registration
59  */
60  template <typename PointSource, typename PointTarget, typename Scalar = float>
61  class Registration : public PCLBase<PointSource>
62  {
63  public:
64  using Matrix4 = Eigen::Matrix<Scalar, 4, 4>;
65 
66  // using PCLBase<PointSource>::initCompute;
70 
73 
76  using KdTreePtr = typename KdTree::Ptr;
77 
80 
84 
88 
90 
92  using TransformationEstimationPtr = typename TransformationEstimation::Ptr;
93  using TransformationEstimationConstPtr = typename TransformationEstimation::ConstPtr;
94 
98 
99  /** \brief The callback signature to the function updating intermediate source point cloud position
100  * during it's registration to the target point cloud.
101  * \param[in] cloud_src - the point cloud which will be updated to match target
102  * \param[in] indices_src - a selector of points in cloud_src
103  * \param[in] cloud_tgt - the point cloud we want to register against
104  * \param[in] indices_tgt - a selector of points in cloud_tgt
105  */
107  const std::vector<int>&,
109  const std::vector<int>&);
110 
111  /** \brief Empty constructor. */
113  : tree_ (new KdTree)
115  , nr_iterations_ (0)
116  , max_iterations_ (10)
117  , ransac_iterations_ (0)
118  , target_ ()
119  , final_transformation_ (Matrix4::Identity ())
120  , transformation_ (Matrix4::Identity ())
121  , previous_transformation_ (Matrix4::Identity ())
124  , euclidean_fitness_epsilon_ (-std::numeric_limits<double>::max ())
125  , corr_dist_threshold_ (std::sqrt (std::numeric_limits<double>::max ()))
126  , inlier_threshold_ (0.05)
127  , converged_ (false)
132  , target_cloud_updated_ (true)
133  , source_cloud_updated_ (true)
134  , force_no_recompute_ (false)
136  , point_representation_ ()
137  {
138  }
139 
140  /** \brief destructor. */
142 
143  /** \brief Provide a pointer to the transformation estimation object.
144  * (e.g., SVD, point to plane etc.)
145  *
146  * \param[in] te is the pointer to the corresponding transformation estimation object
147  *
148  * Code example:
149  *
150  * \code
151  * TransformationEstimationPointToPlaneLLS<PointXYZ, PointXYZ>::Ptr trans_lls (new TransformationEstimationPointToPlaneLLS<PointXYZ, PointXYZ>);
152  * icp.setTransformationEstimation (trans_lls);
153  * // or...
154  * TransformationEstimationSVD<PointXYZ, PointXYZ>::Ptr trans_svd (new TransformationEstimationSVD<PointXYZ, PointXYZ>);
155  * icp.setTransformationEstimation (trans_svd);
156  * \endcode
157  */
158  void
160 
161  /** \brief Provide a pointer to the correspondence estimation object.
162  * (e.g., regular, reciprocal, normal shooting etc.)
163  *
164  * \param[in] ce is the pointer to the corresponding correspondence estimation object
165  *
166  * Code example:
167  *
168  * \code
169  * CorrespondenceEstimation<PointXYZ, PointXYZ>::Ptr ce (new CorrespondenceEstimation<PointXYZ, PointXYZ>);
170  * ce->setInputSource (source);
171  * ce->setInputTarget (target);
172  * icp.setCorrespondenceEstimation (ce);
173  * // or...
174  * CorrespondenceEstimationNormalShooting<PointNormal, PointNormal, PointNormal>::Ptr cens (new CorrespondenceEstimationNormalShooting<PointNormal, PointNormal>);
175  * ce->setInputSource (source);
176  * ce->setInputTarget (target);
177  * ce->setSourceNormals (source);
178  * ce->setTargetNormals (target);
179  * icp.setCorrespondenceEstimation (cens);
180  * \endcode
181  */
182  void
184 
185  /** \brief Provide a pointer to the input source
186  * (e.g., the point cloud that we want to align to the target)
187  *
188  * \param[in] cloud the input point cloud source
189  */
190  virtual void
192  {
193  source_cloud_updated_ = true;
195  }
196 
197  /** \brief Get a pointer to the input point cloud dataset target. */
198  inline PointCloudSourceConstPtr const
199  getInputSource () { return (input_ ); }
200 
201  /** \brief Provide a pointer to the input target (e.g., the point cloud that we want to align the input source to)
202  * \param[in] cloud the input point cloud target
203  */
204  virtual inline void
206 
207  /** \brief Get a pointer to the input point cloud dataset target. */
208  inline PointCloudTargetConstPtr const
209  getInputTarget () { return (target_ ); }
210 
211 
212  /** \brief Provide a pointer to the search object used to find correspondences in
213  * the target cloud.
214  * \param[in] tree a pointer to the spatial search object.
215  * \param[in] force_no_recompute If set to true, this tree will NEVER be
216  * recomputed, regardless of calls to setInputTarget. Only use if you are
217  * confident that the tree will be set correctly.
218  */
219  inline void
221  bool force_no_recompute = false)
222  {
223  tree_ = tree;
224  if (force_no_recompute)
225  {
226  force_no_recompute_ = true;
227  }
228  // Since we just set a new tree, we need to check for updates
229  target_cloud_updated_ = true;
230  }
231 
232  /** \brief Get a pointer to the search method used to find correspondences in the
233  * target cloud. */
234  inline KdTreePtr
236  {
237  return (tree_);
238  }
239 
240  /** \brief Provide a pointer to the search object used to find correspondences in
241  * the source cloud (usually used by reciprocal correspondence finding).
242  * \param[in] tree a pointer to the spatial search object.
243  * \param[in] force_no_recompute If set to true, this tree will NEVER be
244  * recomputed, regardless of calls to setInputSource. Only use if you are
245  * extremely confident that the tree will be set correctly.
246  */
247  inline void
249  bool force_no_recompute = false)
250  {
251  tree_reciprocal_ = tree;
252  if ( force_no_recompute )
253  {
255  }
256  // Since we just set a new tree, we need to check for updates
257  source_cloud_updated_ = true;
258  }
259 
260  /** \brief Get a pointer to the search method used to find correspondences in the
261  * source cloud. */
262  inline KdTreeReciprocalPtr
264  {
265  return (tree_reciprocal_);
266  }
267 
268  /** \brief Get the final transformation matrix estimated by the registration method. */
269  inline Matrix4
271 
272  /** \brief Get the last incremental transformation matrix estimated by the registration method. */
273  inline Matrix4
275 
276  /** \brief Set the maximum number of iterations the internal optimization should run for.
277  * \param[in] nr_iterations the maximum number of iterations the internal optimization should run for
278  */
279  inline void
280  setMaximumIterations (int nr_iterations) { max_iterations_ = nr_iterations; }
281 
282  /** \brief Get the maximum number of iterations the internal optimization should run for, as set by the user. */
283  inline int
285 
286  /** \brief Set the number of iterations RANSAC should run for.
287  * \param[in] ransac_iterations is the number of iterations RANSAC should run for
288  */
289  inline void
290  setRANSACIterations (int ransac_iterations) { ransac_iterations_ = ransac_iterations; }
291 
292  /** \brief Get the number of iterations RANSAC should run for, as set by the user. */
293  inline double
295 
296  /** \brief Set the inlier distance threshold for the internal RANSAC outlier rejection loop.
297  *
298  * The method considers a point to be an inlier, if the distance between the target data index and the transformed
299  * source index is smaller than the given inlier distance threshold.
300  * The value is set by default to 0.05m.
301  * \param[in] inlier_threshold the inlier distance threshold for the internal RANSAC outlier rejection loop
302  */
303  inline void
304  setRANSACOutlierRejectionThreshold (double inlier_threshold) { inlier_threshold_ = inlier_threshold; }
305 
306  /** \brief Get the inlier distance threshold for the internal outlier rejection loop as set by the user. */
307  inline double
309 
310  /** \brief Set the maximum distance threshold between two correspondent points in source <-> target. If the
311  * distance is larger than this threshold, the points will be ignored in the alignment process.
312  * \param[in] distance_threshold the maximum distance threshold between a point and its nearest neighbor
313  * correspondent in order to be considered in the alignment process
314  */
315  inline void
316  setMaxCorrespondenceDistance (double distance_threshold) { corr_dist_threshold_ = distance_threshold; }
317 
318  /** \brief Get the maximum distance threshold between two correspondent points in source <-> target. If the
319  * distance is larger than this threshold, the points will be ignored in the alignment process.
320  */
321  inline double
323 
324  /** \brief Set the transformation epsilon (maximum allowable translation squared difference between two consecutive
325  * transformations) in order for an optimization to be considered as having converged to the final
326  * solution.
327  * \param[in] epsilon the transformation epsilon in order for an optimization to be considered as having
328  * converged to the final solution.
329  */
330  inline void
331  setTransformationEpsilon (double epsilon) { transformation_epsilon_ = epsilon; }
332 
333  /** \brief Get the transformation epsilon (maximum allowable translation squared difference between two consecutive
334  * transformations) as set by the user.
335  */
336  inline double
338 
339  /** \brief Set the transformation rotation epsilon (maximum allowable rotation difference between two consecutive
340  * transformations) in order for an optimization to be considered as having converged to the final
341  * solution.
342  * \param[in] epsilon the transformation rotation epsilon in order for an optimization to be considered as having
343  * converged to the final solution (epsilon is the cos(angle) in a axis-angle representation).
344  */
345  inline void
347 
348  /** \brief Get the transformation rotation epsilon (maximum allowable difference between two consecutive
349  * transformations) as set by the user (epsilon is the cos(angle) in a axis-angle representation).
350  */
351  inline double
353 
354  /** \brief Set the maximum allowed Euclidean error between two consecutive steps in the ICP loop, before
355  * the algorithm is considered to have converged.
356  * The error is estimated as the sum of the differences between correspondences in an Euclidean sense,
357  * divided by the number of correspondences.
358  * \param[in] epsilon the maximum allowed distance error before the algorithm will be considered to have
359  * converged
360  */
361  inline void
363 
364  /** \brief Get the maximum allowed distance error before the algorithm will be considered to have converged,
365  * as set by the user. See \ref setEuclideanFitnessEpsilon
366  */
367  inline double
369 
370  /** \brief Provide a boost shared pointer to the PointRepresentation to be used when comparing points
371  * \param[in] point_representation the PointRepresentation to be used by the k-D tree
372  */
373  inline void
375  {
376  point_representation_ = point_representation;
377  }
378 
379  /** \brief Register the user callback function which will be called from registration thread
380  * in order to update point cloud obtained after each iteration
381  * \param[in] visualizerCallback reference of the user callback function
382  */
383  inline bool
384  registerVisualizationCallback (std::function<UpdateVisualizerCallbackSignature> &visualizerCallback)
385  {
386  if (visualizerCallback)
387  {
388  update_visualizer_ = visualizerCallback;
389  return (true);
390  }
391  return (false);
392  }
393 
394  /** \brief Obtain the Euclidean fitness score (e.g., mean of squared distances from the source to the target)
395  * \param[in] max_range maximum allowable distance between a point and its correspondence in the target
396  * (default: double::max)
397  */
398  inline double
399  getFitnessScore (double max_range = std::numeric_limits<double>::max ());
400 
401  /** \brief Obtain the Euclidean fitness score (e.g., mean of squared distances from the source to the target)
402  * from two sets of correspondence distances (distances between source and target points)
403  * \param[in] distances_a the first set of distances between correspondences
404  * \param[in] distances_b the second set of distances between correspondences
405  */
406  inline double
407  getFitnessScore (const std::vector<float> &distances_a, const std::vector<float> &distances_b);
408 
409  /** \brief Return the state of convergence after the last align run */
410  inline bool
411  hasConverged () const { return (converged_); }
412 
413  /** \brief Call the registration algorithm which estimates the transformation and returns the transformed source
414  * (input) as \a output.
415  * \param[out] output the resultant input transformed point cloud dataset
416  */
417  inline void
418  align (PointCloudSource &output);
419 
420  /** \brief Call the registration algorithm which estimates the transformation and returns the transformed source
421  * (input) as \a output.
422  * \param[out] output the resultant input transformed point cloud dataset
423  * \param[in] guess the initial gross estimation of the transformation
424  */
425  inline void
426  align (PointCloudSource &output, const Matrix4& guess);
427 
428  /** \brief Abstract class get name method. */
429  inline const std::string&
430  getClassName () const { return (reg_name_); }
431 
432  /** \brief Internal computation initialization. */
433  bool
434  initCompute ();
435 
436  /** \brief Internal computation when reciprocal lookup is needed */
437  bool
439 
440  /** \brief Add a new correspondence rejector to the list
441  * \param[in] rejector the new correspondence rejector to concatenate
442  *
443  * Code example:
444  *
445  * \code
446  * CorrespondenceRejectorDistance rej;
447  * rej.setInputCloud<PointXYZ> (keypoints_src);
448  * rej.setInputTarget<PointXYZ> (keypoints_tgt);
449  * rej.setMaximumDistance (1);
450  * rej.setInputCorrespondences (all_correspondences);
451  *
452  * // or...
453  *
454  * \endcode
455  */
456  inline void
458  {
459  correspondence_rejectors_.push_back (rejector);
460  }
461 
462  /** \brief Get the list of correspondence rejectors. */
463  inline std::vector<CorrespondenceRejectorPtr>
465  {
466  return (correspondence_rejectors_);
467  }
468 
469  /** \brief Remove the i-th correspondence rejector in the list
470  * \param[in] i the position of the correspondence rejector in the list to remove
471  */
472  inline bool
474  {
475  if (i >= correspondence_rejectors_.size ())
476  return (false);
478  return (true);
479  }
480 
481  /** \brief Clear the list of correspondence rejectors. */
482  inline void
484  {
485  correspondence_rejectors_.clear ();
486  }
487 
488  protected:
489  /** \brief The registration method name. */
490  std::string reg_name_;
491 
492  /** \brief A pointer to the spatial search object. */
494 
495  /** \brief A pointer to the spatial search object of the source. */
497 
498  /** \brief The number of iterations the internal optimization ran for (used internally). */
500 
501  /** \brief The maximum number of iterations the internal optimization should run for.
502  * The default value is 10.
503  */
505 
506  /** \brief The number of iterations RANSAC should run for. */
508 
509  /** \brief The input point cloud dataset target. */
511 
512  /** \brief The final transformation matrix estimated by the registration method after N iterations. */
514 
515  /** \brief The transformation matrix estimated by the registration method. */
517 
518  /** \brief The previous transformation matrix estimated by the registration method (used internally). */
520 
521  /** \brief The maximum difference between two consecutive transformations in order to consider convergence
522  * (user defined).
523  */
525 
526  /** \brief The maximum rotation difference between two consecutive transformations in order to consider convergence
527  * (user defined).
528  */
530 
531  /** \brief The maximum allowed Euclidean error between two consecutive steps in the ICP loop, before the
532  * algorithm is considered to have converged. The error is estimated as the sum of the differences between
533  * correspondences in an Euclidean sense, divided by the number of correspondences.
534  */
536 
537  /** \brief The maximum distance threshold between two correspondent points in source <-> target. If the
538  * distance is larger than this threshold, the points will be ignored in the alignment process.
539  */
541 
542  /** \brief The inlier distance threshold for the internal RANSAC outlier rejection loop.
543  * The method considers a point to be an inlier, if the distance between the target data index and the transformed
544  * source index is smaller than the given inlier distance threshold. The default value is 0.05.
545  */
547 
548  /** \brief Holds internal convergence state, given user parameters. */
550 
551  /** \brief The minimum number of correspondences that the algorithm needs before attempting to estimate the
552  * transformation. The default value is 3.
553  */
555 
556  /** \brief The set of correspondences determined at this ICP step. */
558 
559  /** \brief A TransformationEstimation object, used to calculate the 4x4 rigid transformation. */
561 
562  /** \brief A CorrespondenceEstimation object, used to estimate correspondences between the source and the target cloud. */
564 
565  /** \brief The list of correspondence rejectors to use. */
566  std::vector<CorrespondenceRejectorPtr> correspondence_rejectors_;
567 
568  /** \brief Variable that stores whether we have a new target cloud, meaning we need to pre-process it again.
569  * This way, we avoid rebuilding the kd-tree for the target cloud every time the determineCorrespondences () method
570  * is called. */
572  /** \brief Variable that stores whether we have a new source cloud, meaning we need to pre-process it again.
573  * This way, we avoid rebuilding the reciprocal kd-tree for the source cloud every time the determineCorrespondences () method
574  * is called. */
576  /** \brief A flag which, if set, means the tree operating on the target cloud
577  * will never be recomputed*/
579 
580  /** \brief A flag which, if set, means the tree operating on the source cloud
581  * will never be recomputed*/
583 
584  /** \brief Callback function to update intermediate source point cloud position during it's registration
585  * to the target point cloud.
586  */
587  std::function<UpdateVisualizerCallbackSignature> update_visualizer_;
588 
589  /** \brief Search for the closest nearest neighbor of a given point.
590  * \param cloud the point cloud dataset to use for nearest neighbor search
591  * \param index the index of the query point
592  * \param indices the resultant vector of indices representing the k-nearest neighbors
593  * \param distances the resultant distances from the query point to the k-nearest neighbors
594  */
595  inline bool
596  searchForNeighbors (const PointCloudSource &cloud, int index,
597  std::vector<int> &indices, std::vector<float> &distances)
598  {
599  int k = tree_->nearestKSearch (cloud, index, 1, indices, distances);
600  if (k == 0)
601  return (false);
602  return (true);
603  }
604 
605  /** \brief Abstract transformation computation method with initial guess */
606  virtual void
607  computeTransformation (PointCloudSource &output, const Matrix4& guess) = 0;
608 
609  private:
610  /** \brief The point representation used (internal). */
611  PointRepresentationConstPtr point_representation_;
612  public:
614  };
615 }
616 
617 #include <pcl/registration/impl/registration.hpp>
KdTreeReciprocalPtr tree_reciprocal_
A pointer to the spatial search object of the source.
Definition: registration.h:496
shared_ptr< KdTree< PointT, Tree > > Ptr
Definition: kdtree.h:78
bool initComputeReciprocal()
Internal computation when reciprocal lookup is needed.
bool source_cloud_updated_
Variable that stores whether we have a new source cloud, meaning we need to pre-process it again...
Definition: registration.h:575
const std::string & getClassName() const
Abstract class get name method.
Definition: registration.h:430
Matrix4 getLastIncrementalTransformation()
Get the last incremental transformation matrix estimated by the registration method.
Definition: registration.h:274
search::KdTree is a wrapper class which inherits the pcl::KdTree class for performing search function...
Definition: kdtree.h:61
void align(PointCloudSource &output)
Call the registration algorithm which estimates the transformation and returns the transformed source...
shared_ptr< PointCloud< PointSource > > Ptr
Definition: point_cloud.h:414
Defines functions, macros and traits for allocating and using memory.
void addCorrespondenceRejector(const CorrespondenceRejectorPtr &rejector)
Add a new correspondence rejector to the list.
Definition: registration.h:457
shared_ptr< CorrespondenceRejector > Ptr
TransformationEstimationPtr transformation_estimation_
A TransformationEstimation object, used to calculate the 4x4 rigid transformation.
Definition: registration.h:560
void setRANSACOutlierRejectionThreshold(double inlier_threshold)
Set the inlier distance threshold for the internal RANSAC outlier rejection loop. ...
Definition: registration.h:304
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) ...
Definition: registration.h:191
CorrespondenceEstimationPtr correspondence_estimation_
A CorrespondenceEstimation object, used to estimate correspondences between the source and the target...
Definition: registration.h:563
int nr_iterations_
The number of iterations the internal optimization ran for (used internally).
Definition: registration.h:499
typename PointRepresentation< PointT >::ConstPtr PointRepresentationConstPtr
Definition: kdtree.h:83
typename CorrespondenceEstimation::ConstPtr CorrespondenceEstimationConstPtr
Definition: registration.h:97
CorrespondencesPtr correspondences_
The set of correspondences determined at this ICP step.
Definition: registration.h:557
shared_ptr< CorrespondenceEstimationBase< PointSource, PointTarget, Scalar > > Ptr
PointCloudTargetConstPtr const getInputTarget()
Get a pointer to the input point cloud dataset target.
Definition: registration.h:209
bool target_cloud_updated_
Variable that stores whether we have a new target cloud, meaning we need to pre-process it again...
Definition: registration.h:571
void setTransformationEstimation(const TransformationEstimationPtr &te)
Provide a pointer to the transformation estimation object.
Definition: registration.h:159
bool removeCorrespondenceRejector(unsigned int i)
Remove the i-th correspondence rejector in the list.
Definition: registration.h:473
virtual void computeTransformation(PointCloudSource &output, const Matrix4 &guess)=0
Abstract transformation computation method with initial guess.
Matrix4 getFinalTransformation()
Get the final transformation matrix estimated by the registration method.
Definition: registration.h:270
std::function< UpdateVisualizerCallbackSignature > update_visualizer_
Callback function to update intermediate source point cloud position during it&#39;s registration to the ...
Definition: registration.h:587
shared_ptr< const CorrespondenceEstimationBase< PointSource, PointTarget, Scalar > > ConstPtr
void setSearchMethodTarget(const KdTreePtr &tree, bool force_no_recompute=false)
Provide a pointer to the search object used to find correspondences in the target cloud...
Definition: registration.h:220
#define PCL_MAKE_ALIGNED_OPERATOR_NEW
Macro to signal a class requires a custom allocator.
Definition: memory.h:65
double getFitnessScore(double max_range=std::numeric_limits< double >::max())
Obtain the Euclidean fitness score (e.g., mean of squared distances from the source to the target) ...
Eigen::Matrix< float, 4, 4 > Matrix4
Definition: registration.h:64
typename CorrespondenceEstimation::Ptr CorrespondenceEstimationPtr
Definition: registration.h:96
int ransac_iterations_
The number of iterations RANSAC should run for.
Definition: registration.h:507
int getMaximumIterations()
Get the maximum number of iterations the internal optimization should run for, as set by the user...
Definition: registration.h:284
bool force_no_recompute_reciprocal_
A flag which, if set, means the tree operating on the source cloud will never be recomputed.
Definition: registration.h:582
double getRANSACIterations()
Get the number of iterations RANSAC should run for, as set by the user.
Definition: registration.h:294
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...
void clearCorrespondenceRejectors()
Clear the list of correspondence rejectors.
Definition: registration.h:483
double getEuclideanFitnessEpsilon()
Get the maximum allowed distance error before the algorithm will be considered to have converged...
Definition: registration.h:368
pcl::registration::CorrespondenceRejector::Ptr CorrespondenceRejectorPtr
Definition: registration.h:74
KdTreePtr tree_
A pointer to the spatial search object.
Definition: registration.h:493
void setCorrespondenceEstimation(const CorrespondenceEstimationPtr &ce)
Provide a pointer to the correspondence estimation object.
Definition: registration.h:183
PointCloudSourceConstPtr const getInputSource()
Get a pointer to the input point cloud dataset target.
Definition: registration.h:199
void setEuclideanFitnessEpsilon(double epsilon)
Set the maximum allowed Euclidean error between two consecutive steps in the ICP loop, before the algorithm is considered to have converged.
Definition: registration.h:362
Matrix4 previous_transformation_
The previous transformation matrix estimated by the registration method (used internally).
Definition: registration.h:519
Matrix4 transformation_
The transformation matrix estimated by the registration method.
Definition: registration.h:516
double getMaxCorrespondenceDistance()
Get the maximum distance threshold between two correspondent points in source <-> target...
Definition: registration.h:322
void setMaximumIterations(int nr_iterations)
Set the maximum number of iterations the internal optimization should run for.
Definition: registration.h:280
int max_iterations_
The maximum number of iterations the internal optimization should run for.
Definition: registration.h:504
double getRANSACOutlierRejectionThreshold()
Get the inlier distance threshold for the internal outlier rejection loop as set by the user...
Definition: registration.h:308
std::vector< CorrespondenceRejectorPtr > correspondence_rejectors_
The list of correspondence rejectors to use.
Definition: registration.h:566
std::vector< CorrespondenceRejectorPtr > getCorrespondenceRejectors()
Get the list of correspondence rejectors.
Definition: registration.h:464
shared_ptr< Registration< PointSource, PointTarget, float > > Ptr
Definition: registration.h:71
Matrix4 final_transformation_
The final transformation matrix estimated by the registration method after N iterations.
Definition: registration.h:513
PointCloudTargetConstPtr target_
The input point cloud dataset target.
Definition: registration.h:510
typename KdTree::PointRepresentationConstPtr PointRepresentationConstPtr
Definition: registration.h:89
double getTransformationRotationEpsilon()
Get the transformation rotation epsilon (maximum allowable difference between two consecutive transfo...
Definition: registration.h:352
bool initCompute()
Internal computation initialization.
PCL base class.
Definition: pcl_base.h:70
bool searchForNeighbors(const PointCloudSource &cloud, int index, std::vector< int > &indices, std::vector< float > &distances)
Search for the closest nearest neighbor of a given point.
Definition: registration.h:596
double euclidean_fitness_epsilon_
The maximum allowed Euclidean error between two consecutive steps in the ICP loop, before the algorithm is considered to have converged.
Definition: registration.h:535
~Registration()
destructor.
Definition: registration.h:141
void setTransformationEpsilon(double epsilon)
Set the transformation epsilon (maximum allowable translation squared difference between two consecut...
Definition: registration.h:331
bool registerVisualizationCallback(std::function< UpdateVisualizerCallbackSignature > &visualizerCallback)
Register the user callback function which will be called from registration thread in order to update ...
Definition: registration.h:384
typename KdTreeReciprocal::Ptr KdTreeReciprocalPtr
Definition: registration.h:79
typename PointCloudSource::Ptr PointCloudSourcePtr
Definition: registration.h:82
void setRANSACIterations(int ransac_iterations)
Set the number of iterations RANSAC should run for.
Definition: registration.h:290
Registration represents the base registration class for general purpose, ICP-like methods...
Definition: registration.h:61
typename pcl::registration::TransformationEstimation< PointSource, PointTarget, float > TransformationEstimation
Definition: registration.h:91
typename TransformationEstimation::Ptr TransformationEstimationPtr
Definition: registration.h:92
double inlier_threshold_
The inlier distance threshold for the internal RANSAC outlier rejection loop.
Definition: registration.h:546
bool hasConverged() const
Return the state of convergence after the last align run.
Definition: registration.h:411
double transformation_rotation_epsilon_
The maximum rotation difference between two consecutive transformations in order to consider converge...
Definition: registration.h:529
void setSearchMethodSource(const KdTreeReciprocalPtr &tree, bool force_no_recompute=false)
Provide a pointer to the search object used to find correspondences in the source cloud (usually used...
Definition: registration.h:248
typename PointCloudSource::ConstPtr PointCloudSourceConstPtr
Definition: registration.h:83
bool converged_
Holds internal convergence state, given user parameters.
Definition: registration.h:549
double transformation_epsilon_
The maximum difference between two consecutive transformations in order to consider convergence (user...
Definition: registration.h:524
virtual void setInputCloud(const PointCloudConstPtr &cloud)
Provide a pointer to the input dataset.
Definition: pcl_base.hpp:65
shared_ptr< const PointCloud< PointSource > > ConstPtr
Definition: point_cloud.h:415
typename TransformationEstimation::ConstPtr TransformationEstimationConstPtr
Definition: registration.h:93
std::string reg_name_
The registration method name.
Definition: registration.h:490
typename PointCloudTarget::Ptr PointCloudTargetPtr
Definition: registration.h:86
double corr_dist_threshold_
The maximum distance threshold between two correspondent points in source <-> target.
Definition: registration.h:540
std::vector< pcl::Correspondence, Eigen::aligned_allocator< pcl::Correspondence > > Correspondences
PointCloudConstPtr input_
The input point cloud dataset.
Definition: pcl_base.h:148
Registration()
Empty constructor.
Definition: registration.h:112
double getTransformationEpsilon()
Get the transformation epsilon (maximum allowable translation squared difference between two consecut...
Definition: registration.h:337
bool force_no_recompute_
A flag which, if set, means the tree operating on the target cloud will never be recomputed.
Definition: registration.h:578
typename PointCloudTarget::ConstPtr PointCloudTargetConstPtr
Definition: registration.h:87
void setPointRepresentation(const PointRepresentationConstPtr &point_representation)
Provide a boost shared pointer to the PointRepresentation to be used when comparing points...
Definition: registration.h:374
int min_number_correspondences_
The minimum number of correspondences that the algorithm needs before attempting to estimate the tran...
Definition: registration.h:554
KdTreeReciprocalPtr getSearchMethodSource() const
Get a pointer to the search method used to find correspondences in the source cloud.
Definition: registration.h:263
void(const pcl::PointCloud< PointSource > &, const std::vector< int > &, const pcl::PointCloud< PointTarget > &, const std::vector< int > &) UpdateVisualizerCallbackSignature
The callback signature to the function updating intermediate source point cloud position during it&#39;s ...
Definition: registration.h:109
shared_ptr< const Registration< PointSource, PointTarget, float > > ConstPtr
Definition: registration.h:72
KdTreePtr getSearchMethodTarget() const
Get a pointer to the search method used to find correspondences in the target cloud.
Definition: registration.h:235
TransformationEstimation represents the base class for methods for transformation estimation based on...
void setTransformationRotationEpsilon(double epsilon)
Set the transformation rotation epsilon (maximum allowable rotation difference between two consecutiv...
Definition: registration.h:346
void setMaxCorrespondenceDistance(double distance_threshold)
Set the maximum distance threshold between two correspondent points in source <-> target...
Definition: registration.h:316
boost::shared_ptr< T > shared_ptr
Alias for boost::shared_ptr.
Definition: memory.h:81
shared_ptr< Correspondences > CorrespondencesPtr
Defines all the PCL and non-PCL macros used.
Abstract CorrespondenceEstimationBase class.