Point Cloud Library (PCL)  1.9.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/pcl_macros.h>
47 #include <pcl/search/kdtree.h>
48 #include <pcl/kdtree/kdtree_flann.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  typedef Eigen::Matrix<Scalar, 4, 4> Matrix4;
65 
66  // using PCLBase<PointSource>::initCompute;
70 
71  typedef boost::shared_ptr< Registration<PointSource, PointTarget, Scalar> > Ptr;
72  typedef boost::shared_ptr< const Registration<PointSource, PointTarget, Scalar> > ConstPtr;
73 
77 
80 
84 
88 
90 
94 
98 
99  /** \brief Empty constructor. */
101  : reg_name_ ()
102  , tree_ (new KdTree)
103  , tree_reciprocal_ (new KdTreeReciprocal)
104  , nr_iterations_ (0)
105  , max_iterations_ (10)
106  , ransac_iterations_ (0)
107  , target_ ()
108  , final_transformation_ (Matrix4::Identity ())
109  , transformation_ (Matrix4::Identity ())
110  , previous_transformation_ (Matrix4::Identity ())
113  , euclidean_fitness_epsilon_ (-std::numeric_limits<double>::max ())
114  , corr_dist_threshold_ (std::sqrt (std::numeric_limits<double>::max ()))
115  , inlier_threshold_ (0.05)
116  , converged_ (false)
122  , target_cloud_updated_ (true)
123  , source_cloud_updated_ (true)
124  , force_no_recompute_ (false)
126  , point_representation_ ()
127  {
128  }
129 
130  /** \brief destructor. */
132 
133  /** \brief Provide a pointer to the transformation estimation object.
134  * (e.g., SVD, point to plane etc.)
135  *
136  * \param[in] te is the pointer to the corresponding transformation estimation object
137  *
138  * Code example:
139  *
140  * \code
141  * TransformationEstimationPointToPlaneLLS<PointXYZ, PointXYZ>::Ptr trans_lls (new TransformationEstimationPointToPlaneLLS<PointXYZ, PointXYZ>);
142  * icp.setTransformationEstimation (trans_lls);
143  * // or...
144  * TransformationEstimationSVD<PointXYZ, PointXYZ>::Ptr trans_svd (new TransformationEstimationSVD<PointXYZ, PointXYZ>);
145  * icp.setTransformationEstimation (trans_svd);
146  * \endcode
147  */
148  void
149  setTransformationEstimation (const TransformationEstimationPtr &te) { transformation_estimation_ = te; }
150 
151  /** \brief Provide a pointer to the correspondence estimation object.
152  * (e.g., regular, reciprocal, normal shooting etc.)
153  *
154  * \param[in] ce is the pointer to the corresponding correspondence estimation object
155  *
156  * Code example:
157  *
158  * \code
159  * CorrespondenceEstimation<PointXYZ, PointXYZ>::Ptr ce (new CorrespondenceEstimation<PointXYZ, PointXYZ>);
160  * ce->setInputSource (source);
161  * ce->setInputTarget (target);
162  * icp.setCorrespondenceEstimation (ce);
163  * // or...
164  * CorrespondenceEstimationNormalShooting<PointNormal, PointNormal, PointNormal>::Ptr cens (new CorrespondenceEstimationNormalShooting<PointNormal, PointNormal>);
165  * ce->setInputSource (source);
166  * ce->setInputTarget (target);
167  * ce->setSourceNormals (source);
168  * ce->setTargetNormals (target);
169  * icp.setCorrespondenceEstimation (cens);
170  * \endcode
171  */
172  void
173  setCorrespondenceEstimation (const CorrespondenceEstimationPtr &ce) { correspondence_estimation_ = ce; }
174 
175  /** \brief Provide a pointer to the input source
176  * (e.g., the point cloud that we want to align to the target)
177  *
178  * \param[in] cloud the input point cloud source
179  */
180  virtual void
181  setInputSource (const PointCloudSourceConstPtr &cloud)
182  {
183  source_cloud_updated_ = true;
185  }
186 
187  /** \brief Get a pointer to the input point cloud dataset target. */
188  inline PointCloudSourceConstPtr const
189  getInputSource () { return (input_ ); }
190 
191  /** \brief Provide a pointer to the input target (e.g., the point cloud that we want to align the input source to)
192  * \param[in] cloud the input point cloud target
193  */
194  virtual inline void
195  setInputTarget (const PointCloudTargetConstPtr &cloud);
196 
197  /** \brief Get a pointer to the input point cloud dataset target. */
198  inline PointCloudTargetConstPtr const
199  getInputTarget () { return (target_ ); }
200 
201 
202  /** \brief Provide a pointer to the search object used to find correspondences in
203  * the target cloud.
204  * \param[in] tree a pointer to the spatial search object.
205  * \param[in] force_no_recompute If set to true, this tree will NEVER be
206  * recomputed, regardless of calls to setInputTarget. Only use if you are
207  * confident that the tree will be set correctly.
208  */
209  inline void
210  setSearchMethodTarget (const KdTreePtr &tree,
211  bool force_no_recompute = false)
212  {
213  tree_ = tree;
214  if (force_no_recompute)
215  {
216  force_no_recompute_ = true;
217  }
218  // Since we just set a new tree, we need to check for updates
219  target_cloud_updated_ = true;
220  }
221 
222  /** \brief Get a pointer to the search method used to find correspondences in the
223  * target cloud. */
224  inline KdTreePtr
226  {
227  return (tree_);
228  }
229 
230  /** \brief Provide a pointer to the search object used to find correspondences in
231  * the source cloud (usually used by reciprocal correspondence finding).
232  * \param[in] tree a pointer to the spatial search object.
233  * \param[in] force_no_recompute If set to true, this tree will NEVER be
234  * recomputed, regardless of calls to setInputSource. Only use if you are
235  * extremely confident that the tree will be set correctly.
236  */
237  inline void
238  setSearchMethodSource (const KdTreeReciprocalPtr &tree,
239  bool force_no_recompute = false)
240  {
241  tree_reciprocal_ = tree;
242  if ( force_no_recompute )
243  {
245  }
246  // Since we just set a new tree, we need to check for updates
247  source_cloud_updated_ = true;
248  }
249 
250  /** \brief Get a pointer to the search method used to find correspondences in the
251  * source cloud. */
252  inline KdTreeReciprocalPtr
254  {
255  return (tree_reciprocal_);
256  }
257 
258  /** \brief Get the final transformation matrix estimated by the registration method. */
259  inline Matrix4
261 
262  /** \brief Get the last incremental transformation matrix estimated by the registration method. */
263  inline Matrix4
265 
266  /** \brief Set the maximum number of iterations the internal optimization should run for.
267  * \param[in] nr_iterations the maximum number of iterations the internal optimization should run for
268  */
269  inline void
270  setMaximumIterations (int nr_iterations) { max_iterations_ = nr_iterations; }
271 
272  /** \brief Get the maximum number of iterations the internal optimization should run for, as set by the user. */
273  inline int
275 
276  /** \brief Set the number of iterations RANSAC should run for.
277  * \param[in] ransac_iterations is the number of iterations RANSAC should run for
278  */
279  inline void
280  setRANSACIterations (int ransac_iterations) { ransac_iterations_ = ransac_iterations; }
281 
282  /** \brief Get the number of iterations RANSAC should run for, as set by the user. */
283  inline double
285 
286  /** \brief Set the inlier distance threshold for the internal RANSAC outlier rejection loop.
287  *
288  * The method considers a point to be an inlier, if the distance between the target data index and the transformed
289  * source index is smaller than the given inlier distance threshold.
290  * The value is set by default to 0.05m.
291  * \param[in] inlier_threshold the inlier distance threshold for the internal RANSAC outlier rejection loop
292  */
293  inline void
294  setRANSACOutlierRejectionThreshold (double inlier_threshold) { inlier_threshold_ = inlier_threshold; }
295 
296  /** \brief Get the inlier distance threshold for the internal outlier rejection loop as set by the user. */
297  inline double
299 
300  /** \brief Set the maximum distance threshold between two correspondent points in source <-> target. If the
301  * distance is larger than this threshold, the points will be ignored in the alignment process.
302  * \param[in] distance_threshold the maximum distance threshold between a point and its nearest neighbor
303  * correspondent in order to be considered in the alignment process
304  */
305  inline void
306  setMaxCorrespondenceDistance (double distance_threshold) { corr_dist_threshold_ = distance_threshold; }
307 
308  /** \brief Get the maximum distance threshold between two correspondent points in source <-> target. If the
309  * distance is larger than this threshold, the points will be ignored in the alignment process.
310  */
311  inline double
313 
314  /** \brief Set the transformation epsilon (maximum allowable translation squared difference between two consecutive
315  * transformations) in order for an optimization to be considered as having converged to the final
316  * solution.
317  * \param[in] epsilon the transformation epsilon in order for an optimization to be considered as having
318  * converged to the final solution.
319  */
320  inline void
321  setTransformationEpsilon (double epsilon) { transformation_epsilon_ = epsilon; }
322 
323  /** \brief Get the transformation epsilon (maximum allowable translation squared difference between two consecutive
324  * transformations) as set by the user.
325  */
326  inline double
328 
329  /** \brief Set the transformation rotation epsilon (maximum allowable rotation difference between two consecutive
330  * transformations) in order for an optimization to be considered as having converged to the final
331  * solution.
332  * \param[in] epsilon the transformation rotation epsilon in order for an optimization to be considered as having
333  * converged to the final solution (epsilon is the cos(angle) in a axis-angle representation).
334  */
335  inline void
337 
338  /** \brief Get the transformation rotation epsilon (maximum allowable difference between two consecutive
339  * transformations) as set by the user (epsilon is the cos(angle) in a axis-angle representation).
340  */
341  inline double
343 
344  /** \brief Set the maximum allowed Euclidean error between two consecutive steps in the ICP loop, before
345  * the algorithm is considered to have converged.
346  * The error is estimated as the sum of the differences between correspondences in an Euclidean sense,
347  * divided by the number of correspondences.
348  * \param[in] epsilon the maximum allowed distance error before the algorithm will be considered to have
349  * converged
350  */
351  inline void
353 
354  /** \brief Get the maximum allowed distance error before the algorithm will be considered to have converged,
355  * as set by the user. See \ref setEuclideanFitnessEpsilon
356  */
357  inline double
359 
360  /** \brief Provide a boost shared pointer to the PointRepresentation to be used when comparing points
361  * \param[in] point_representation the PointRepresentation to be used by the k-D tree
362  */
363  inline void
364  setPointRepresentation (const PointRepresentationConstPtr &point_representation)
365  {
366  point_representation_ = point_representation;
367  }
368 
369  /** \brief Register the user callback function which will be called from registration thread
370  * in order to update point cloud obtained after each iteration
371  * \param[in] visualizerCallback reference of the user callback function
372  */
373  template<typename FunctionSignature> inline bool
374  registerVisualizationCallback (boost::function<FunctionSignature> &visualizerCallback)
375  {
376  if (visualizerCallback != NULL)
377  {
378  update_visualizer_ = visualizerCallback;
379  return (true);
380  }
381  else
382  return (false);
383  }
384 
385  /** \brief Obtain the Euclidean fitness score (e.g., sum of squared distances from the source to the target)
386  * \param[in] max_range maximum allowable distance between a point and its correspondence in the target
387  * (default: double::max)
388  */
389  inline double
390  getFitnessScore (double max_range = std::numeric_limits<double>::max ());
391 
392  /** \brief Obtain the Euclidean fitness score (e.g., sum of squared distances from the source to the target)
393  * from two sets of correspondence distances (distances between source and target points)
394  * \param[in] distances_a the first set of distances between correspondences
395  * \param[in] distances_b the second set of distances between correspondences
396  */
397  inline double
398  getFitnessScore (const std::vector<float> &distances_a, const std::vector<float> &distances_b);
399 
400  /** \brief Return the state of convergence after the last align run */
401  inline bool
402  hasConverged () { return (converged_); }
403 
404  /** \brief Call the registration algorithm which estimates the transformation and returns the transformed source
405  * (input) as \a output.
406  * \param[out] output the resultant input transformed point cloud dataset
407  */
408  inline void
409  align (PointCloudSource &output);
410 
411  /** \brief Call the registration algorithm which estimates the transformation and returns the transformed source
412  * (input) as \a output.
413  * \param[out] output the resultant input transformed point cloud dataset
414  * \param[in] guess the initial gross estimation of the transformation
415  */
416  inline void
417  align (PointCloudSource &output, const Matrix4& guess);
418 
419  /** \brief Abstract class get name method. */
420  inline const std::string&
421  getClassName () const { return (reg_name_); }
422 
423  /** \brief Internal computation initialization. */
424  bool
425  initCompute ();
426 
427  /** \brief Internal computation when reciprocal lookup is needed */
428  bool
430 
431  /** \brief Add a new correspondence rejector to the list
432  * \param[in] rejector the new correspondence rejector to concatenate
433  *
434  * Code example:
435  *
436  * \code
437  * CorrespondenceRejectorDistance rej;
438  * rej.setInputCloud<PointXYZ> (keypoints_src);
439  * rej.setInputTarget<PointXYZ> (keypoints_tgt);
440  * rej.setMaximumDistance (1);
441  * rej.setInputCorrespondences (all_correspondences);
442  *
443  * // or...
444  *
445  * \endcode
446  */
447  inline void
448  addCorrespondenceRejector (const CorrespondenceRejectorPtr &rejector)
449  {
450  correspondence_rejectors_.push_back (rejector);
451  }
452 
453  /** \brief Get the list of correspondence rejectors. */
454  inline std::vector<CorrespondenceRejectorPtr>
456  {
457  return (correspondence_rejectors_);
458  }
459 
460  /** \brief Remove the i-th correspondence rejector in the list
461  * \param[in] i the position of the correspondence rejector in the list to remove
462  */
463  inline bool
465  {
466  if (i >= correspondence_rejectors_.size ())
467  return (false);
469  return (true);
470  }
471 
472  /** \brief Clear the list of correspondence rejectors. */
473  inline void
475  {
476  correspondence_rejectors_.clear ();
477  }
478 
479  protected:
480  /** \brief The registration method name. */
481  std::string reg_name_;
482 
483  /** \brief A pointer to the spatial search object. */
484  KdTreePtr tree_;
485 
486  /** \brief A pointer to the spatial search object of the source. */
487  KdTreeReciprocalPtr tree_reciprocal_;
488 
489  /** \brief The number of iterations the internal optimization ran for (used internally). */
491 
492  /** \brief The maximum number of iterations the internal optimization should run for.
493  * The default value is 10.
494  */
496 
497  /** \brief The number of iterations RANSAC should run for. */
499 
500  /** \brief The input point cloud dataset target. */
501  PointCloudTargetConstPtr target_;
502 
503  /** \brief The final transformation matrix estimated by the registration method after N iterations. */
505 
506  /** \brief The transformation matrix estimated by the registration method. */
508 
509  /** \brief The previous transformation matrix estimated by the registration method (used internally). */
511 
512  /** \brief The maximum difference between two consecutive transformations in order to consider convergence
513  * (user defined).
514  */
516 
517  /** \brief The maximum rotation difference between two consecutive transformations in order to consider convergence
518  * (user defined).
519  */
521 
522  /** \brief The maximum allowed Euclidean error between two consecutive steps in the ICP loop, before the
523  * algorithm is considered to have converged. The error is estimated as the sum of the differences between
524  * correspondences in an Euclidean sense, divided by the number of correspondences.
525  */
527 
528  /** \brief The maximum distance threshold between two correspondent points in source <-> target. If the
529  * distance is larger than this threshold, the points will be ignored in the alignment process.
530  */
532 
533  /** \brief The inlier distance threshold for the internal RANSAC outlier rejection loop.
534  * The method considers a point to be an inlier, if the distance between the target data index and the transformed
535  * source index is smaller than the given inlier distance threshold. The default value is 0.05.
536  */
538 
539  /** \brief Holds internal convergence state, given user parameters. */
541 
542  /** \brief The minimum number of correspondences that the algorithm needs before attempting to estimate the
543  * transformation. The default value is 3.
544  */
546 
547  /** \brief The set of correspondences determined at this ICP step. */
549 
550  /** \brief A TransformationEstimation object, used to calculate the 4x4 rigid transformation. */
551  TransformationEstimationPtr transformation_estimation_;
552 
553  /** \brief A CorrespondenceEstimation object, used to estimate correspondences between the source and the target cloud. */
554  CorrespondenceEstimationPtr correspondence_estimation_;
555 
556  /** \brief The list of correspondence rejectors to use. */
557  std::vector<CorrespondenceRejectorPtr> correspondence_rejectors_;
558 
559  /** \brief Variable that stores whether we have a new target cloud, meaning we need to pre-process it again.
560  * This way, we avoid rebuilding the kd-tree for the target cloud every time the determineCorrespondences () method
561  * is called. */
563  /** \brief Variable that stores whether we have a new source cloud, meaning we need to pre-process it again.
564  * This way, we avoid rebuilding the reciprocal kd-tree for the source cloud every time the determineCorrespondences () method
565  * is called. */
567  /** \brief A flag which, if set, means the tree operating on the target cloud
568  * will never be recomputed*/
570 
571  /** \brief A flag which, if set, means the tree operating on the source cloud
572  * will never be recomputed*/
574 
575  /** \brief Callback function to update intermediate source point cloud position during it's registration
576  * to the target point cloud.
577  */
578  boost::function<void(const pcl::PointCloud<PointSource> &cloud_src,
579  const std::vector<int> &indices_src,
580  const pcl::PointCloud<PointTarget> &cloud_tgt,
581  const std::vector<int> &indices_tgt)> update_visualizer_;
582 
583  /** \brief Search for the closest nearest neighbor of a given point.
584  * \param cloud the point cloud dataset to use for nearest neighbor search
585  * \param index the index of the query point
586  * \param indices the resultant vector of indices representing the k-nearest neighbors
587  * \param distances the resultant distances from the query point to the k-nearest neighbors
588  */
589  inline bool
590  searchForNeighbors (const PointCloudSource &cloud, int index,
591  std::vector<int> &indices, std::vector<float> &distances)
592  {
593  int k = tree_->nearestKSearch (cloud, index, 1, indices, distances);
594  if (k == 0)
595  return (false);
596  return (true);
597  }
598 
599  /** \brief Abstract transformation computation method with initial guess */
600  virtual void
601  computeTransformation (PointCloudSource &output, const Matrix4& guess) = 0;
602 
603  private:
604  /** \brief The point representation used (internal). */
605  PointRepresentationConstPtr point_representation_;
606  public:
607  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
608  };
609 }
610 
611 #include <pcl/registration/impl/registration.hpp>
KdTreeReciprocalPtr tree_reciprocal_
A pointer to the spatial search object of the source.
Definition: registration.h:487
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:566
Matrix4 getLastIncrementalTransformation()
Get the last incremental transformation matrix estimated by the registration method.
Definition: registration.h:264
pcl::registration::CorrespondenceEstimationBase< PointSource, PointTarget, Scalar > CorrespondenceEstimation
Definition: registration.h:95
KdTreeReciprocalPtr getSearchMethodSource() const
Get a pointer to the search method used to find correspondences in the source cloud.
Definition: registration.h:253
void align(PointCloudSource &output)
Call the registration algorithm which estimates the transformation and returns the transformed source...
void addCorrespondenceRejector(const CorrespondenceRejectorPtr &rejector)
Add a new correspondence rejector to the list.
Definition: registration.h:448
TransformationEstimationPtr transformation_estimation_
A TransformationEstimation object, used to calculate the 4x4 rigid transformation.
Definition: registration.h:551
void setRANSACOutlierRejectionThreshold(double inlier_threshold)
Set the inlier distance threshold for the internal RANSAC outlier rejection loop. ...
Definition: registration.h:294
pcl::registration::TransformationEstimation< PointSource, PointTarget, Scalar > TransformationEstimation
Definition: registration.h:91
boost::shared_ptr< const Registration< PointSource, PointTarget, Scalar > > ConstPtr
Definition: registration.h:72
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:181
CorrespondenceEstimationPtr correspondence_estimation_
A CorrespondenceEstimation object, used to estimate correspondences between the source and the target...
Definition: registration.h:554
This file defines compatibility wrappers for low level I/O functions.
Definition: convolution.h:44
int nr_iterations_
The number of iterations the internal optimization ran for (used internally).
Definition: registration.h:490
KdTree::PointRepresentationConstPtr PointRepresentationConstPtr
Definition: registration.h:89
pcl::PointCloud< PointTarget > PointCloudTarget
Definition: registration.h:85
CorrespondencesPtr correspondences_
The set of correspondences determined at this ICP step.
Definition: registration.h:548
PointCloudTargetConstPtr const getInputTarget()
Get a pointer to the input point cloud dataset target.
Definition: registration.h:199
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:562
boost::shared_ptr< Registration< PointSource, PointTarget, Scalar > > Ptr
Definition: registration.h:71
void setTransformationEstimation(const TransformationEstimationPtr &te)
Provide a pointer to the transformation estimation object.
Definition: registration.h:149
bool removeCorrespondenceRejector(unsigned int i)
Remove the i-th correspondence rejector in the list.
Definition: registration.h:464
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:260
bool registerVisualizationCallback(boost::function< FunctionSignature > &visualizerCallback)
Register the user callback function which will be called from registration thread in order to update ...
Definition: registration.h:374
PointCloudSource::ConstPtr PointCloudSourceConstPtr
Definition: registration.h:83
pcl::search::KdTree< PointSource > KdTreeReciprocal
Definition: registration.h:78
boost::shared_ptr< TransformationEstimation< PointSource, PointTarget, Scalar > > Ptr
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:210
double getFitnessScore(double max_range=std::numeric_limits< double >::max())
Obtain the Euclidean fitness score (e.g., sum of squared distances from the source to the target) ...
int ransac_iterations_
The number of iterations RANSAC should run for.
Definition: registration.h:498
int getMaximumIterations()
Get the maximum number of iterations the internal optimization should run for, as set by the user...
Definition: registration.h:274
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:573
double getRANSACIterations()
Get the number of iterations RANSAC should run for, as set by the user.
Definition: registration.h:284
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...
TransformationEstimation::Ptr TransformationEstimationPtr
Definition: registration.h:92
void clearCorrespondenceRejectors()
Clear the list of correspondence rejectors.
Definition: registration.h:474
double getEuclideanFitnessEpsilon()
Get the maximum allowed distance error before the algorithm will be considered to have converged...
Definition: registration.h:358
Eigen::Matrix< Scalar, 4, 4 > Matrix4
Definition: registration.h:64
PointCloudSource::Ptr PointCloudSourcePtr
Definition: registration.h:82
boost::shared_ptr< PointCloud< PointSource > > Ptr
Definition: point_cloud.h:427
KdTreePtr tree_
A pointer to the spatial search object.
Definition: registration.h:484
void setCorrespondenceEstimation(const CorrespondenceEstimationPtr &ce)
Provide a pointer to the correspondence estimation object.
Definition: registration.h:173
PointCloudSourceConstPtr const getInputSource()
Get a pointer to the input point cloud dataset target.
Definition: registration.h:189
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:352
const std::string & getClassName() const
Abstract class get name method.
Definition: registration.h:421
Matrix4 previous_transformation_
The previous transformation matrix estimated by the registration method (used internally).
Definition: registration.h:510
Matrix4 transformation_
The transformation matrix estimated by the registration method.
Definition: registration.h:507
CorrespondenceEstimation::Ptr CorrespondenceEstimationPtr
Definition: registration.h:96
double getMaxCorrespondenceDistance()
Get the maximum distance threshold between two correspondent points in source <-> target...
Definition: registration.h:312
void setMaximumIterations(int nr_iterations)
Set the maximum number of iterations the internal optimization should run for.
Definition: registration.h:270
int max_iterations_
The maximum number of iterations the internal optimization should run for.
Definition: registration.h:495
double getRANSACOutlierRejectionThreshold()
Get the inlier distance threshold for the internal outlier rejection loop as set by the user...
Definition: registration.h:298
std::vector< CorrespondenceRejectorPtr > correspondence_rejectors_
The list of correspondence rejectors to use.
Definition: registration.h:557
std::vector< CorrespondenceRejectorPtr > getCorrespondenceRejectors()
Get the list of correspondence rejectors.
Definition: registration.h:455
boost::shared_ptr< KdTree< PointT, Tree > > Ptr
Definition: kdtree.h:78
Matrix4 final_transformation_
The final transformation matrix estimated by the registration method after N iterations.
Definition: registration.h:504
PointCloudTargetConstPtr target_
The input point cloud dataset target.
Definition: registration.h:501
CorrespondenceEstimation::ConstPtr CorrespondenceEstimationConstPtr
Definition: registration.h:97
double getTransformationRotationEpsilon()
Get the transformation rotation epsilon (maximum allowable difference between two consecutive transfo...
Definition: registration.h:342
bool initCompute()
Internal computation initialization.
PCL base class.
Definition: pcl_base.h:68
std::vector< pcl::Correspondence, Eigen::aligned_allocator< pcl::Correspondence > > Correspondences
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:590
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:526
~Registration()
destructor.
Definition: registration.h:131
void setTransformationEpsilon(double epsilon)
Set the transformation epsilon (maximum allowable translation squared difference between two consecut...
Definition: registration.h:321
PointCloudTarget::Ptr PointCloudTargetPtr
Definition: registration.h:86
boost::shared_ptr< const PointCloud< PointSource > > ConstPtr
Definition: point_cloud.h:428
TransformationEstimation::ConstPtr TransformationEstimationConstPtr
Definition: registration.h:93
void setRANSACIterations(int ransac_iterations)
Set the number of iterations RANSAC should run for.
Definition: registration.h:280
Registration represents the base registration class for general purpose, ICP-like methods...
Definition: registration.h:61
boost::shared_ptr< Correspondences > CorrespondencesPtr
pcl::registration::CorrespondenceRejector::Ptr CorrespondenceRejectorPtr
Definition: registration.h:74
double inlier_threshold_
The inlier distance threshold for the internal RANSAC outlier rejection loop.
Definition: registration.h:537
double transformation_rotation_epsilon_
The maximum rotation difference between two consecutive transformations in order to consider converge...
Definition: registration.h:520
pcl::search::KdTree< PointTarget >::Ptr KdTreePtr
Definition: registration.h:76
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:238
boost::shared_ptr< const TransformationEstimation< PointSource, PointTarget, Scalar > > ConstPtr
pcl::search::KdTree< PointTarget > KdTree
Definition: registration.h:75
boost::shared_ptr< const PointRepresentation > PointRepresentationConstPtr
Definition: kdtree.h:67
bool converged_
Holds internal convergence state, given user parameters.
Definition: registration.h:540
double transformation_epsilon_
The maximum difference between two consecutive transformations in order to consider convergence (user...
Definition: registration.h:515
KdTreePtr getSearchMethodTarget() const
Get a pointer to the search method used to find correspondences in the target cloud.
Definition: registration.h:225
PointCloudTarget::ConstPtr PointCloudTargetConstPtr
Definition: registration.h:87
virtual void setInputCloud(const PointCloudConstPtr &cloud)
Provide a pointer to the input dataset.
Definition: pcl_base.hpp:66
KdTreeReciprocal::Ptr KdTreeReciprocalPtr
Definition: registration.h:79
std::string reg_name_
The registration method name.
Definition: registration.h:481
boost::function< void(const pcl::PointCloud< PointSource > &cloud_src, const std::vector< int > &indices_src, const pcl::PointCloud< PointTarget > &cloud_tgt, const std::vector< int > &indices_tgt)> update_visualizer_
Callback function to update intermediate source point cloud position during it&#39;s registration to the ...
Definition: registration.h:581
double corr_dist_threshold_
The maximum distance threshold between two correspondent points in source <-> target.
Definition: registration.h:531
PointCloudConstPtr input_
The input point cloud dataset.
Definition: pcl_base.h:150
Registration()
Empty constructor.
Definition: registration.h:100
double getTransformationEpsilon()
Get the transformation epsilon (maximum allowable translation squared difference between two consecut...
Definition: registration.h:327
bool force_no_recompute_
A flag which, if set, means the tree operating on the target cloud will never be recomputed.
Definition: registration.h:569
void setPointRepresentation(const PointRepresentationConstPtr &point_representation)
Provide a boost shared pointer to the PointRepresentation to be used when comparing points...
Definition: registration.h:364
int min_number_correspondences_
The minimum number of correspondences that the algorithm needs before attempting to estimate the tran...
Definition: registration.h:545
TransformationEstimation represents the base class for methods for transformation estimation based on...
pcl::PointCloud< PointSource > PointCloudSource
Definition: registration.h:81
boost::shared_ptr< CorrespondenceRejector > Ptr
void setTransformationRotationEpsilon(double epsilon)
Set the transformation rotation epsilon (maximum allowable rotation difference between two consecutiv...
Definition: registration.h:336
void setMaxCorrespondenceDistance(double distance_threshold)
Set the maximum distance threshold between two correspondent points in source <-> target...
Definition: registration.h:306
boost::shared_ptr< const CorrespondenceEstimationBase< PointSource, PointTarget, Scalar > > ConstPtr
bool hasConverged()
Return the state of convergence after the last align run.
Definition: registration.h:402
boost::shared_ptr< CorrespondenceEstimationBase< PointSource, PointTarget, Scalar > > Ptr
Abstract CorrespondenceEstimationBase class.