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