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