Point Cloud Library (PCL)  1.11.1
transformation_estimation_point_to_plane_lls_weighted.h
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Point Cloud Library (PCL) - www.pointclouds.org
5  * Copyright (c) 2012-, Open Perception, Inc.
6  *
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * * Redistributions of source code must retain the above copyright
14  * notice, this list of conditions and the following disclaimer.
15  * * Redistributions in binary form must reproduce the above
16  * copyright notice, this list of conditions and the following
17  * disclaimer in the documentation and/or other materials provided
18  * with the distribution.
19  * * Neither the name of the copyright holder(s) nor the names of its
20  * contributors may be used to endorse or promote products derived
21  * from this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  * POSSIBILITY OF SUCH DAMAGE.
35  *
36  * $Id$
37  *
38  */
39 
40 #pragma once
41 
42 #include <pcl/registration/transformation_estimation.h>
43 #include <pcl/registration/warp_point_rigid.h>
44 #include <pcl/cloud_iterator.h>
45 
46 namespace pcl
47 {
48  namespace registration
49  {
50  /** \brief @b TransformationEstimationPointToPlaneLLSWeighted implements a Linear Least Squares (LLS) approximation
51  * for minimizing the point-to-plane distance between two clouds of corresponding points with normals, with the
52  * possibility of assigning weights to the correspondences.
53  *
54  * For additional details, see
55  * "Linear Least-Squares Optimization for Point-to-Plane ICP Surface Registration", Kok-Lim Low, 2004
56  *
57  * \note The class is templated on the source and target point types as well as on the output scalar of the
58  * transformation matrix (i.e., float or double). Default: float.
59  * \author Alex Ichim
60  * \ingroup registration
61  */
62  template <typename PointSource, typename PointTarget, typename Scalar = float>
63  class TransformationEstimationPointToPlaneLLSWeighted : public TransformationEstimation<PointSource, PointTarget, Scalar>
64  {
65  public:
66  using Ptr = shared_ptr<TransformationEstimationPointToPlaneLLSWeighted<PointSource, PointTarget, Scalar> >;
67  using ConstPtr = shared_ptr<const TransformationEstimationPointToPlaneLLSWeighted<PointSource, PointTarget, Scalar> >;
68 
70 
73 
74  /** \brief Estimate a rigid rotation transformation between a source and a target point cloud using SVD.
75  * \param[in] cloud_src the source point cloud dataset
76  * \param[in] cloud_tgt the target point cloud dataset
77  * \param[out] transformation_matrix the resultant transformation matrix
78  */
79  inline void
81  const pcl::PointCloud<PointSource> &cloud_src,
82  const pcl::PointCloud<PointTarget> &cloud_tgt,
83  Matrix4 &transformation_matrix) const;
84 
85  /** \brief Estimate a rigid rotation transformation between a source and a target point cloud using SVD.
86  * \param[in] cloud_src the source point cloud dataset
87  * \param[in] indices_src the vector of indices describing the points of interest in \a cloud_src
88  * \param[in] cloud_tgt the target point cloud dataset
89  * \param[out] transformation_matrix the resultant transformation matrix
90  */
91  inline void
93  const pcl::PointCloud<PointSource> &cloud_src,
94  const std::vector<int> &indices_src,
95  const pcl::PointCloud<PointTarget> &cloud_tgt,
96  Matrix4 &transformation_matrix) const;
97 
98  /** \brief Estimate a rigid rotation transformation between a source and a target point cloud using SVD.
99  * \param[in] cloud_src the source point cloud dataset
100  * \param[in] indices_src the vector of indices describing the points of interest in \a cloud_src
101  * \param[in] cloud_tgt the target point cloud dataset
102  * \param[in] indices_tgt the vector of indices describing the correspondences of the interest points from \a indices_src
103  * \param[out] transformation_matrix the resultant transformation matrix
104  */
105  inline void
107  const pcl::PointCloud<PointSource> &cloud_src,
108  const std::vector<int> &indices_src,
109  const pcl::PointCloud<PointTarget> &cloud_tgt,
110  const std::vector<int> &indices_tgt,
111  Matrix4 &transformation_matrix) const;
112 
113  /** \brief Estimate a rigid rotation transformation between a source and a target point cloud using SVD.
114  * \param[in] cloud_src the source point cloud dataset
115  * \param[in] cloud_tgt the target point cloud dataset
116  * \param[in] correspondences the vector of correspondences between source and target point cloud
117  * \param[out] transformation_matrix the resultant transformation matrix
118  */
119  inline void
121  const pcl::PointCloud<PointSource> &cloud_src,
122  const pcl::PointCloud<PointTarget> &cloud_tgt,
123  const pcl::Correspondences &correspondences,
124  Matrix4 &transformation_matrix) const;
125 
126 
127  /** \brief Set the weights for the correspondences.
128  * \param[in] weights the weights for each correspondence
129  */
130  inline void
131  setCorrespondenceWeights (const std::vector<Scalar> &weights)
132  { weights_ = weights; }
133 
134  protected:
135 
136  /** \brief Estimate a rigid rotation transformation between a source and a target
137  * \param[in] source_it an iterator over the source point cloud dataset
138  * \param[in] target_it an iterator over the target point cloud dataset
139  * \param weights_it
140  * \param[out] transformation_matrix the resultant transformation matrix
141  */
142  void
145  typename std::vector<Scalar>::const_iterator& weights_it,
146  Matrix4 &transformation_matrix) const;
147 
148  /** \brief Construct a 4 by 4 transformation matrix from the provided rotation and translation.
149  * \param[in] alpha the rotation about the x-axis
150  * \param[in] beta the rotation about the y-axis
151  * \param[in] gamma the rotation about the z-axis
152  * \param[in] tx the x translation
153  * \param[in] ty the y translation
154  * \param[in] tz the z translation
155  * \param[out] transformation_matrix the resultant transformation matrix
156  */
157  inline void
158  constructTransformationMatrix (const double & alpha, const double & beta, const double & gamma,
159  const double & tx, const double & ty, const double & tz,
160  Matrix4 &transformation_matrix) const;
161 
162  std::vector<Scalar> weights_;
163  };
164  }
165 }
166 
167 #include <pcl/registration/impl/transformation_estimation_point_to_plane_lls_weighted.hpp>
pcl
Definition: convolution.h:46
pcl::registration::TransformationEstimationPointToPlaneLLSWeighted::TransformationEstimationPointToPlaneLLSWeighted
TransformationEstimationPointToPlaneLLSWeighted()
Definition: transformation_estimation_point_to_plane_lls_weighted.h:71
pcl::registration::TransformationEstimationPointToPlaneLLSWeighted
TransformationEstimationPointToPlaneLLSWeighted implements a Linear Least Squares (LLS) approximation...
Definition: transformation_estimation_point_to_plane_lls_weighted.h:64
pcl::registration::TransformationEstimationPointToPlaneLLSWeighted::~TransformationEstimationPointToPlaneLLSWeighted
virtual ~TransformationEstimationPointToPlaneLLSWeighted()
Definition: transformation_estimation_point_to_plane_lls_weighted.h:72
pcl::registration::TransformationEstimation::Matrix4
Eigen::Matrix< Scalar, 4, 4 > Matrix4
Definition: transformation_estimation.h:65
pcl::PointCloud< PointSource >
pcl::registration::TransformationEstimationPointToPlaneLLSWeighted::estimateRigidTransformation
void estimateRigidTransformation(const pcl::PointCloud< PointSource > &cloud_src, const pcl::PointCloud< PointTarget > &cloud_tgt, Matrix4 &transformation_matrix) const
Estimate a rigid rotation transformation between a source and a target point cloud using SVD.
Definition: transformation_estimation_point_to_plane_lls_weighted.hpp:54
pcl::registration::TransformationEstimationPointToPlaneLLSWeighted::Matrix4
typename TransformationEstimation< PointSource, PointTarget, Scalar >::Matrix4 Matrix4
Definition: transformation_estimation_point_to_plane_lls_weighted.h:69
pcl::registration::TransformationEstimationPointToPlaneLLSWeighted::ConstPtr
shared_ptr< const TransformationEstimationPointToPlaneLLSWeighted< PointSource, PointTarget, Scalar > > ConstPtr
Definition: transformation_estimation_point_to_plane_lls_weighted.h:67
pcl::registration::TransformationEstimationPointToPlaneLLSWeighted::setCorrespondenceWeights
void setCorrespondenceWeights(const std::vector< Scalar > &weights)
Set the weights for the correspondences.
Definition: transformation_estimation_point_to_plane_lls_weighted.h:131
pcl::registration::TransformationEstimationPointToPlaneLLSWeighted::constructTransformationMatrix
void constructTransformationMatrix(const double &alpha, const double &beta, const double &gamma, const double &tx, const double &ty, const double &tz, Matrix4 &transformation_matrix) const
Construct a 4 by 4 transformation matrix from the provided rotation and translation.
Definition: transformation_estimation_point_to_plane_lls_weighted.hpp:161
pcl::ConstCloudIterator
Iterator class for point clouds with or without given indices.
Definition: cloud_iterator.h:121
pcl::registration::TransformationEstimationPointToPlaneLLSWeighted::Ptr
shared_ptr< TransformationEstimationPointToPlaneLLSWeighted< PointSource, PointTarget, Scalar > > Ptr
Definition: transformation_estimation_point_to_plane_lls_weighted.h:66
pcl::registration::TransformationEstimationPointToPlaneLLSWeighted::weights_
std::vector< Scalar > weights_
Definition: transformation_estimation_point_to_plane_lls_weighted.h:162
pcl::Correspondences
std::vector< pcl::Correspondence, Eigen::aligned_allocator< pcl::Correspondence > > Correspondences
Definition: correspondence.h:90
pcl::registration::TransformationEstimation
TransformationEstimation represents the base class for methods for transformation estimation based on...
Definition: transformation_estimation.h:63