Point Cloud Library (PCL) 1.15.1-dev
Loading...
Searching...
No Matches
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/registration/correspondence_estimation.h>
45#include <pcl/registration/correspondence_rejection.h>
46#include <pcl/registration/transformation_estimation.h>
47#include <pcl/search/search.h>
48#include <pcl/memory.h>
49#include <pcl/pcl_base.h>
50#include <pcl/pcl_macros.h>
51
52namespace pcl {
53/** \brief @b Registration represents the base registration class for general purpose,
54 * ICP-like methods. \author Radu B. Rusu, Michael Dixon \ingroup registration
55 */
56template <typename PointSource, typename PointTarget, typename Scalar = float>
57class Registration : public PCLBase<PointSource> {
58public:
59 using Matrix4 = Eigen::Matrix<Scalar, 4, 4>;
60
61 // using PCLBase<PointSource>::initCompute;
62 using PCLBase<PointSource>::deinitCompute;
63 using PCLBase<PointSource>::input_;
64 using PCLBase<PointSource>::indices_;
65
66 using Ptr = shared_ptr<Registration<PointSource, PointTarget, Scalar>>;
67 using ConstPtr = shared_ptr<const Registration<PointSource, PointTarget, Scalar>>;
68
71 using KdTreePtr = typename KdTree::Ptr;
72
75
79
83
86
87 using TransformationEstimation = typename pcl::registration::
88 TransformationEstimation<PointSource, PointTarget, Scalar>;
89 using TransformationEstimationPtr = typename TransformationEstimation::Ptr;
90 using TransformationEstimationConstPtr = typename TransformationEstimation::ConstPtr;
91
96
97 /** \brief The callback signature to the function updating intermediate source point
98 * cloud position during it's registration to the target point cloud. \param[in]
99 * cloud_src - the point cloud which will be updated to match target \param[in]
100 * indices_src - a selector of points in cloud_src \param[in] cloud_tgt - the point
101 * cloud we want to register against \param[in] indices_tgt - a selector of points in
102 * cloud_tgt
103 */
105 const pcl::Indices&,
107 const pcl::Indices&);
108
109 /** \brief Empty constructor. */
111 : target_()
112 , final_transformation_(Matrix4::Identity())
113 , transformation_(Matrix4::Identity())
114 , previous_transformation_(Matrix4::Identity())
115 , euclidean_fitness_epsilon_(-std::numeric_limits<double>::max())
116 , corr_dist_threshold_(std::sqrt(std::numeric_limits<double>::max()))
120 , point_representation_()
121 {}
122
123 /** \brief destructor. */
124 ~Registration() override = default;
125
126 /** \brief Provide a pointer to the transformation estimation object.
127 * (e.g., SVD, point to plane etc.)
128 *
129 * \param[in] te is the pointer to the corresponding transformation estimation object
130 *
131 * Code example:
132 *
133 * \code
134 * TransformationEstimationPointToPlaneLLS<PointXYZ, PointXYZ>::Ptr trans_lls
135 * (new TransformationEstimationPointToPlaneLLS<PointXYZ, PointXYZ>);
136 * icp.setTransformationEstimation (trans_lls);
137 * // or...
138 * TransformationEstimationSVD<PointXYZ, PointXYZ>::Ptr trans_svd
139 * (new TransformationEstimationSVD<PointXYZ, PointXYZ>);
140 * icp.setTransformationEstimation (trans_svd);
141 * \endcode
142 */
143 void
148
149 /** \brief Provide a pointer to the correspondence estimation object.
150 * (e.g., regular, reciprocal, normal shooting etc.)
151 *
152 * \param[in] ce is the pointer to the corresponding correspondence estimation object
153 *
154 * Code example:
155 *
156 * \code
157 * CorrespondenceEstimation<PointXYZ, PointXYZ>::Ptr
158 * ce (new CorrespondenceEstimation<PointXYZ, PointXYZ>);
159 * ce->setInputSource (source);
160 * ce->setInputTarget (target);
161 * icp.setCorrespondenceEstimation (ce);
162 * // or...
163 * CorrespondenceEstimationNormalShooting<PointNormal, PointNormal, PointNormal>::Ptr
164 * cens (new CorrespondenceEstimationNormalShooting<PointNormal, PointNormal>);
165 * ce->setInputSource (source);
166 * ce->setInputTarget (target);
167 * ce->setSourceNormals (source);
168 * ce->setTargetNormals (target);
169 * icp.setCorrespondenceEstimation (cens);
170 * \endcode
171 */
172 void
177
178 /** \brief Provide a pointer to the input source
179 * (e.g., the point cloud that we want to align to the target)
180 *
181 * \param[in] cloud the input point cloud source
182 */
183 virtual void
185
186 /** \brief Get a pointer to the input point cloud dataset target. */
187 inline PointCloudSourceConstPtr const
189 {
190 return (input_);
191 }
192
193 /** \brief Provide a pointer to the input target (e.g., the point cloud that we want
194 * to align the input source to) \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
202 {
203 return (target_);
204 }
205
206 /** \brief Provide a pointer to the search object used to find correspondences in
207 * the target cloud.
208 * \param[in] tree a pointer to the spatial search object.
209 * \param[in] force_no_recompute If set to true, this tree will NEVER be
210 * recomputed, regardless of calls to setInputTarget. Only use if you are
211 * confident that the tree will be set correctly.
212 */
213 inline void
214 setSearchMethodTarget(const KdTreePtr& tree, bool force_no_recompute = false)
215 {
216 tree_ = tree;
217 force_no_recompute_ = force_no_recompute;
218 // Since we just set a new tree, we need to check for updates
220 }
221
222 /** \brief Get a pointer to the search method used to find correspondences in the
223 * target cloud. */
224 inline KdTreePtr
226 {
227 return (tree_);
228 }
229
230 /** \brief Provide a pointer to the search object used to find correspondences in
231 * the source cloud (usually used by reciprocal correspondence finding).
232 * \param[in] tree a pointer to the spatial search object.
233 * \param[in] force_no_recompute If set to true, this tree will NEVER be
234 * recomputed, regardless of calls to setInputSource. Only use if you are
235 * extremely confident that the tree will be set correctly.
236 */
237 inline void
239 bool force_no_recompute = false)
240 {
241 tree_reciprocal_ = tree;
242 force_no_recompute_reciprocal_ = force_no_recompute;
243 // Since we just set a new tree, we need to check for updates
245 }
246
247 /** \brief Get a pointer to the search method used to find correspondences in the
248 * source cloud. */
251 {
252 return (tree_reciprocal_);
253 }
254
255 /** \brief Get the final transformation matrix estimated by the registration method.
256 */
257 inline Matrix4
262
263 /** \brief Get the last incremental transformation matrix estimated by the
264 * registration method. */
265 inline Matrix4
270
271 /** \brief Set the maximum number of iterations the internal optimization should run
272 * for. \param[in] nr_iterations the maximum number of iterations the internal
273 * optimization should run for
274 */
275 inline void
276 setMaximumIterations(int nr_iterations)
277 {
278 max_iterations_ = nr_iterations;
279 }
280
281 /** \brief Get the maximum number of iterations the internal optimization should run
282 * for, as set by the user. */
283 inline int
285 {
286 return (max_iterations_);
287 }
288
289 /** \brief Set the number of iterations RANSAC should run for.
290 * \param[in] ransac_iterations is the number of iterations RANSAC should run for
291 */
292 inline void
293 setRANSACIterations(int ransac_iterations)
294 {
295 ransac_iterations_ = ransac_iterations;
296 }
297
298 /** \brief Get the number of iterations RANSAC should run for, as set by the user. */
299 inline double
301 {
302 return (ransac_iterations_);
303 }
304
305 /** \brief Set the inlier distance threshold for the internal RANSAC outlier rejection
306 * loop.
307 *
308 * The method considers a point to be an inlier, if the distance between the target
309 * data index and the transformed source index is smaller than the given inlier
310 * distance threshold. The value is set by default to 0.05m. \param[in]
311 * inlier_threshold the inlier distance threshold for the internal RANSAC outlier
312 * rejection loop
313 */
314 inline void
315 setRANSACOutlierRejectionThreshold(double inlier_threshold)
316 {
317 inlier_threshold_ = inlier_threshold;
318 }
319
320 /** \brief Get the inlier distance threshold for the internal outlier rejection loop
321 * as set by the user. */
322 inline double
327
328 /** \brief Set the maximum distance threshold between two correspondent points in
329 * source <-> target. If the distance is larger than this threshold, the points will
330 * be ignored in the alignment process. \param[in] distance_threshold the maximum
331 * distance threshold between a point and its nearest neighbor correspondent in order
332 * to be considered in the alignment process
333 */
334 inline void
335 setMaxCorrespondenceDistance(double distance_threshold)
336 {
337 corr_dist_threshold_ = distance_threshold;
338 }
339
340 /** \brief Get the maximum distance threshold between two correspondent points in
341 * source <-> target. If the distance is larger than this threshold, the points will
342 * be ignored in the alignment process.
343 */
344 inline double
349
350 /** \brief Set the transformation epsilon (maximum allowable translation squared
351 * difference between two consecutive transformations) in order for an optimization to
352 * be considered as having converged to the final solution. \param[in] epsilon the
353 * transformation epsilon in order for an optimization to be considered as having
354 * converged to the final solution.
355 */
356 inline void
358 {
359 transformation_epsilon_ = epsilon;
360 }
361
362 /** \brief Get the transformation epsilon (maximum allowable translation squared
363 * difference between two consecutive transformations) as set by the user.
364 */
365 inline double
370
371 /** \brief Set the transformation rotation epsilon (maximum allowable rotation
372 * difference between two consecutive transformations) in order for an optimization to
373 * be considered as having converged to the final solution. \param[in] epsilon the
374 * transformation rotation epsilon in order for an optimization to be considered as
375 * having converged to the final solution (epsilon is the cos(angle) in a axis-angle
376 * representation).
377 */
378 inline void
380 {
382 }
383
384 /** \brief Get the transformation rotation epsilon (maximum allowable difference
385 * between two consecutive transformations) as set by the user (epsilon is the
386 * cos(angle) in a axis-angle representation).
387 */
388 inline double
393
394 /** \brief Set the maximum allowed Euclidean error between two consecutive steps in
395 * the ICP loop, before the algorithm is considered to have converged. The error is
396 * estimated as the sum of the differences between correspondences in an Euclidean
397 * sense, divided by the number of correspondences. \param[in] epsilon the maximum
398 * allowed distance error before the algorithm will be considered to have converged
399 */
400 inline void
402 {
404 }
405
406 /** \brief Get the maximum allowed distance error before the algorithm will be
407 * considered to have converged, as set by the user. See \ref
408 * setEuclideanFitnessEpsilon
409 */
410 inline double
415
416 /** \brief Provide a boost shared pointer to the PointRepresentation to be used when
417 * comparing points \param[in] point_representation the PointRepresentation to be used
418 * by the k-D tree
419 */
420 inline void
422 {
423 point_representation_ = point_representation;
424 }
425
426 /** \brief Register the user callback function which will be called from registration
427 * thread in order to update point cloud obtained after each iteration \param[in]
428 * visualizerCallback reference of the user callback function
429 */
430 inline bool
432 std::function<UpdateVisualizerCallbackSignature>& visualizerCallback)
433 {
434 if (visualizerCallback) {
435 update_visualizer_ = visualizerCallback;
436 pcl::Indices indices;
437 update_visualizer_(*input_, indices, *target_, indices);
438 return (true);
439 }
440 return (false);
441 }
442
443 /** \brief Obtain the Euclidean fitness score (e.g., mean of squared distances from
444 * the source to the target) \param[in] max_range maximum allowable distance between a
445 * point and its correspondence in the target (default: double::max)
446 * \param[in] use_indices whether to use the registered indices or all points
447 * (default: false)
448 */
449 inline double
450 getFitnessScore(double max_range = std::numeric_limits<double>::max(),
451 bool use_indices = false);
452
453 /** \brief Obtain the Euclidean fitness score (e.g., mean of squared distances from
454 * the source to the target) from two sets of correspondence distances (distances
455 * between source and target points) \param[in] distances_a the first set of distances
456 * between correspondences \param[in] distances_b the second set of distances between
457 * correspondences
458 */
459 inline double
460 getFitnessScore(const std::vector<float>& distances_a,
461 const std::vector<float>& distances_b);
462
463 /** \brief Return the state of convergence after the last align run */
464 inline bool
466 {
467 return (converged_);
468 }
469
470 /** \brief Call the registration algorithm which estimates the transformation and
471 * returns the transformed source (input) as \a output. \param[out] output the
472 * resultant input transformed point cloud dataset
473 */
474 inline void
475 align(PointCloudSource& output);
476
477 /** \brief Call the registration algorithm which estimates the transformation and
478 * returns the transformed source (input) as \a output. \param[out] output the
479 * resultant input transformed point cloud dataset \param[in] guess the initial gross
480 * estimation of the transformation
481 */
482 inline void
483 align(PointCloudSource& output, const Matrix4& guess);
484
485 /** \brief Abstract class get name method. */
486 inline const std::string&
488 {
489 return (reg_name_);
490 }
491
492 /** \brief Internal computation initialization. */
493 bool
494 initCompute();
495
496 /** \brief Internal computation when reciprocal lookup is needed */
497 bool
499
500 /** \brief Add a new correspondence rejector to the list
501 * \param[in] rejector the new correspondence rejector to concatenate
502 *
503 * Code example:
504 *
505 * \code
506 * CorrespondenceRejectorDistance rej;
507 * rej.setInputCloud<PointXYZ> (keypoints_src);
508 * rej.setInputTarget<PointXYZ> (keypoints_tgt);
509 * rej.setMaximumDistance (1);
510 * rej.setInputCorrespondences (all_correspondences);
511 *
512 * // or...
513 *
514 * \endcode
515 */
516 inline void
518 {
519 correspondence_rejectors_.push_back(rejector);
520 }
521
522 /** \brief Get the list of correspondence rejectors. */
523 inline std::vector<CorrespondenceRejectorPtr>
528
529 /** \brief Remove the i-th correspondence rejector in the list
530 * \param[in] i the position of the correspondence rejector in the list to remove
531 */
532 inline bool
534 {
535 if (i >= correspondence_rejectors_.size())
536 return (false);
538 return (true);
539 }
540
541 /** \brief Clear the list of correspondence rejectors. */
542 inline void
547
548protected:
549 /** \brief The registration method name. */
550 std::string reg_name_;
551
552 /** \brief A pointer to the spatial search object. */
554
555 /** \brief A pointer to the spatial search object of the source. */
557
558 /** \brief The number of iterations the internal optimization ran for (used
559 * internally). */
561
562 /** \brief The maximum number of iterations the internal optimization should run for.
563 * The default value is 10.
564 */
566
567 /** \brief The number of iterations RANSAC should run for. */
569
570 /** \brief The input point cloud dataset target. */
572
573 /** \brief The final transformation matrix estimated by the registration method after
574 * N iterations. */
576
577 /** \brief The transformation matrix estimated by the registration method. */
579
580 /** \brief The previous transformation matrix estimated by the registration method
581 * (used internally). */
583
584 /** \brief The maximum difference between two consecutive transformations in order to
585 * consider convergence (user defined).
586 */
588
589 /** \brief The maximum rotation difference between two consecutive transformations in
590 * order to consider convergence (user defined).
591 */
593
594 /** \brief The maximum allowed Euclidean error between two consecutive steps in the
595 * ICP loop, before the algorithm is considered to have converged. The error is
596 * estimated as the sum of the differences between correspondences in an Euclidean
597 * sense, divided by the number of correspondences.
598 */
600
601 /** \brief The maximum distance threshold between two correspondent points in source
602 * <-> target. If the distance is larger than this threshold, the points will be
603 * ignored in the alignment process.
604 */
606
607 /** \brief The inlier distance threshold for the internal RANSAC outlier rejection
608 * loop. The method considers a point to be an inlier, if the distance between the
609 * target data index and the transformed source index is smaller than the given inlier
610 * distance threshold. The default value is 0.05.
611 */
612 double inlier_threshold_{0.05};
613
614 /** \brief Holds internal convergence state, given user parameters. */
615 bool converged_{false};
616
617 /** \brief The minimum number of correspondences that the algorithm needs before
618 * attempting to estimate the transformation. The default value is 3.
619 */
621
622 /** \brief The set of correspondences determined at this ICP step. */
624
625 /** \brief A TransformationEstimation object, used to calculate the 4x4 rigid
626 * transformation. */
628
629 /** \brief A CorrespondenceEstimation object, used to estimate correspondences between
630 * the source and the target cloud. */
632
633 /** \brief The list of correspondence rejectors to use. */
634 std::vector<CorrespondenceRejectorPtr> correspondence_rejectors_;
635
636 /** \brief Variable that stores whether we have a new target cloud, meaning we need to
637 * pre-process it again. This way, we avoid rebuilding the kd-tree for the target
638 * cloud every time the determineCorrespondences () method is called. */
640 /** \brief Variable that stores whether we have a new source cloud, meaning we need to
641 * pre-process it again. This way, we avoid rebuilding the reciprocal kd-tree for the
642 * source cloud every time the determineCorrespondences () method is called. */
644 /** \brief A flag which, if set, means the tree operating on the target cloud
645 * will never be recomputed*/
647
648 /** \brief A flag which, if set, means the tree operating on the source cloud
649 * will never be recomputed*/
651
652 /** \brief Callback function to update intermediate source point cloud position during
653 * it's registration to the target point cloud.
654 */
655 std::function<UpdateVisualizerCallbackSignature> update_visualizer_;
656
657 /** \brief Search for the closest nearest neighbor of a given point.
658 * \param cloud the point cloud dataset to use for nearest neighbor search
659 * \param index the index of the query point
660 * \param indices the resultant vector of indices representing the k-nearest neighbors
661 * \param distances the resultant distances from the query point to the k-nearest
662 * neighbors
663 */
664 inline bool
666 int index,
667 pcl::Indices& indices,
668 std::vector<float>& distances)
669 {
670 int k = tree_->nearestKSearchT(cloud[index], 1, indices, distances);
671 if (k == 0)
672 return (false);
673 return (true);
674 }
675
676 /** \brief Abstract transformation computation method with initial guess */
677 virtual void
679
680private:
681 /** \brief The point representation used (internal). */
682 PointRepresentationConstPtr point_representation_;
683
684 /**
685 * \brief Remove from public API in favor of \ref setInputSource
686 *
687 * Still gives the correct result (with a warning)
688 */
689 void
690 setInputCloud(const PointCloudSourceConstPtr& cloud) override
691 {
692 PCL_WARN("[pcl::registration::Registration] setInputCloud is deprecated."
693 "Please use setInputSource instead.\n");
694 setInputSource(cloud);
695 }
696
697public:
699};
700} // namespace pcl
701
702#include <pcl/registration/impl/registration.hpp>
PCL base class.
Definition pcl_base.h:70
PointCloudConstPtr input_
The input point cloud dataset.
Definition pcl_base.h:147
IndicesPtr indices_
A pointer to the vector of point indices to use.
Definition pcl_base.h:150
bool deinitCompute()
This method should get called after finishing the actual computation.
Definition pcl_base.hpp:175
shared_ptr< PointCloud< PointSource > > Ptr
shared_ptr< const PointCloud< PointSource > > ConstPtr
shared_ptr< const PointRepresentation< PointT > > ConstPtr
Registration represents the base registration class for general purpose, ICP-like methods.
bool target_cloud_updated_
Variable that stores whether we have a new target cloud, meaning we need to pre-process it again.
Matrix4 final_transformation_
The final transformation matrix estimated by the registration method after N iterations.
typename KdTreeReciprocal::Ptr KdTreeReciprocalPtr
bool initCompute()
Internal computation initialization.
std::function< UpdateVisualizerCallbackSignature > update_visualizer_
Callback function to update intermediate source point cloud position during it's registration to the ...
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)
double corr_dist_threshold_
The maximum distance threshold between two correspondent points in source <-> target.
void clearCorrespondenceRejectors()
Clear the list of correspondence rejectors.
typename PointRepresentation< PointTarget >::ConstPtr PointRepresentationConstPtr
double getTransformationEpsilon()
Get the transformation epsilon (maximum allowable translation squared difference between two consecut...
void(const pcl::PointCloud< PointSource > &, const pcl::Indices &, const pcl::PointCloud< PointTarget > &, const pcl::Indices &) UpdateVisualizerCallbackSignature
The callback signature to the function updating intermediate source point cloud position during it's ...
std::string reg_name_
The registration method name.
Matrix4 getFinalTransformation()
Get the final transformation matrix estimated by the registration method.
void setRANSACIterations(int ransac_iterations)
Set the number of iterations RANSAC should run for.
shared_ptr< const Registration< PointSource, PointTarget, Scalar > > ConstPtr
Matrix4 transformation_
The transformation matrix estimated by the registration method.
pcl::PointCloud< PointSource > PointCloudSource
KdTreeReciprocalPtr tree_reciprocal_
A pointer to the spatial search object of the source.
bool removeCorrespondenceRejector(unsigned int i)
Remove the i-th correspondence rejector in the list.
void setCorrespondenceEstimation(const CorrespondenceEstimationPtr &ce)
Provide a pointer to the correspondence estimation object.
typename CorrespondenceEstimation::ConstPtr CorrespondenceEstimationConstPtr
void setMaximumIterations(int nr_iterations)
Set the maximum number of iterations the internal optimization should run for.
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...
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.
typename PointCloudSource::ConstPtr PointCloudSourceConstPtr
typename KdTree::Ptr KdTreePtr
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...
bool registerVisualizationCallback(std::function< UpdateVisualizerCallbackSignature > &visualizerCallback)
Register the user callback function which will be called from registration thread in order to update ...
typename TransformationEstimation::Ptr TransformationEstimationPtr
typename PointCloudSource::Ptr PointCloudSourcePtr
void setPointRepresentation(const PointRepresentationConstPtr &point_representation)
Provide a boost shared pointer to the PointRepresentation to be used when comparing points.
CorrespondenceEstimationPtr correspondence_estimation_
A CorrespondenceEstimation object, used to estimate correspondences between the source and the target...
typename PointCloudTarget::ConstPtr PointCloudTargetConstPtr
double getTransformationRotationEpsilon()
Get the transformation rotation epsilon (maximum allowable difference between two consecutive transfo...
bool force_no_recompute_
A flag which, if set, means the tree operating on the target cloud will never be recomputed.
void setRANSACOutlierRejectionThreshold(double inlier_threshold)
Set the inlier distance threshold for the internal RANSAC outlier rejection loop.
void setMaxCorrespondenceDistance(double distance_threshold)
Set the maximum distance threshold between two correspondent points in source <-> target.
void addCorrespondenceRejector(const CorrespondenceRejectorPtr &rejector)
Add a new correspondence rejector to the list.
int nr_iterations_
The number of iterations the internal optimization ran for (used internally).
shared_ptr< Registration< PointSource, PointTarget, Scalar > > Ptr
double getRANSACOutlierRejectionThreshold()
Get the inlier distance threshold for the internal outlier rejection loop as set by the user.
double getEuclideanFitnessEpsilon()
Get the maximum allowed distance error before the algorithm will be considered to have converged,...
double getMaxCorrespondenceDistance()
Get the maximum distance threshold between two correspondent points in source <-> target.
KdTreePtr getSearchMethodTarget() const
Get a pointer to the search method used to find correspondences in the target cloud.
KdTreePtr tree_
A pointer to the spatial search object.
Registration()
Empty constructor.
Matrix4 getLastIncrementalTransformation()
Get the last incremental transformation matrix estimated by the registration method.
typename PointCloudTarget::Ptr PointCloudTargetPtr
Matrix4 previous_transformation_
The previous transformation matrix estimated by the registration method (used internally).
bool converged_
Holds internal convergence state, given user parameters.
int ransac_iterations_
The number of iterations RANSAC should run for.
Eigen::Matrix< Scalar, 4, 4 > Matrix4
void align(PointCloudSource &output)
Call the registration algorithm which estimates the transformation and returns the transformed source...
PointCloudTargetConstPtr const getInputTarget()
Get a pointer to the input point cloud dataset target.
CorrespondencesPtr correspondences_
The set of correspondences determined at this ICP step.
TransformationEstimationPtr transformation_estimation_
A TransformationEstimation object, used to calculate the 4x4 rigid transformation.
bool searchForNeighbors(const PointCloudSource &cloud, int index, pcl::Indices &indices, std::vector< float > &distances)
Search for the closest nearest neighbor of a given point.
int max_iterations_
The maximum number of iterations the internal optimization should run for.
double transformation_rotation_epsilon_
The maximum rotation difference between two consecutive transformations in order to consider converge...
unsigned int min_number_correspondences_
The minimum number of correspondences that the algorithm needs before attempting to estimate the tran...
double euclidean_fitness_epsilon_
The maximum allowed Euclidean error between two consecutive steps in the ICP loop,...
double inlier_threshold_
The inlier distance threshold for the internal RANSAC outlier rejection loop.
pcl::registration::CorrespondenceRejector::Ptr CorrespondenceRejectorPtr
PointCloudSourceConstPtr const getInputSource()
Get a pointer to the input point cloud dataset target.
typename TransformationEstimation::ConstPtr TransformationEstimationConstPtr
typename pcl::registration::TransformationEstimation< PointSource, PointTarget, Scalar > TransformationEstimation
bool hasConverged() const
Return the state of convergence after the last align run.
void setTransformationEstimation(const TransformationEstimationPtr &te)
Provide a pointer to the transformation estimation object.
bool force_no_recompute_reciprocal_
A flag which, if set, means the tree operating on the source cloud will never be recomputed.
double transformation_epsilon_
The maximum difference between two consecutive transformations in order to consider convergence (user...
std::vector< CorrespondenceRejectorPtr > getCorrespondenceRejectors()
Get the list of correspondence rejectors.
double getFitnessScore(double max_range=std::numeric_limits< double >::max(), bool use_indices=false)
Obtain the Euclidean fitness score (e.g., mean of squared distances from the source to the target)
std::vector< CorrespondenceRejectorPtr > correspondence_rejectors_
The list of correspondence rejectors to use.
KdTreeReciprocalPtr getSearchMethodSource() const
Get a pointer to the search method used to find correspondences in the source cloud.
~Registration() override=default
destructor.
int getMaximumIterations()
Get the maximum number of iterations the internal optimization should run for, as set by the user.
void setTransformationRotationEpsilon(double epsilon)
Set the transformation rotation epsilon (maximum allowable rotation difference between two consecutiv...
bool initComputeReciprocal()
Internal computation when reciprocal lookup is needed.
virtual void computeTransformation(PointCloudSource &output, const Matrix4 &guess)=0
Abstract transformation computation method with initial guess.
typename CorrespondenceEstimation::Ptr CorrespondenceEstimationPtr
void setEuclideanFitnessEpsilon(double epsilon)
Set the maximum allowed Euclidean error between two consecutive steps in the ICP loop,...
void setTransformationEpsilon(double epsilon)
Set the transformation epsilon (maximum allowable translation squared difference between two consecut...
bool source_cloud_updated_
Variable that stores whether we have a new source cloud, meaning we need to pre-process it again.
PointCloudTargetConstPtr target_
The input point cloud dataset target.
const std::string & getClassName() const
Abstract class get name method.
double getRANSACIterations()
Get the number of iterations RANSAC should run for, as set by the user.
Abstract CorrespondenceEstimationBase class.
shared_ptr< const CorrespondenceEstimationBase< PointSource, PointTarget, Scalar > > ConstPtr
shared_ptr< CorrespondenceEstimationBase< PointSource, PointTarget, Scalar > > Ptr
shared_ptr< CorrespondenceRejector > Ptr
shared_ptr< pcl::search::Search< PointTarget > > Ptr
Definition search.h:84
#define PCL_MAKE_ALIGNED_OPERATOR_NEW
Macro to signal a class requires a custom allocator.
Definition memory.h:86
Defines functions, macros and traits for allocating and using memory.
shared_ptr< Correspondences > CorrespondencesPtr
std::vector< pcl::Correspondence, Eigen::aligned_allocator< pcl::Correspondence > > Correspondences
IndicesAllocator<> Indices
Type used for indices in PCL.
Definition types.h:133
Defines all the PCL and non-PCL macros used.