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