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