Point Cloud Library (PCL)  1.14.1-dev
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 namespace registration {
48 /** \brief @b TransformationEstimationPointToPlaneLLSWeighted implements a Linear Least
49  * Squares (LLS) approximation for minimizing the point-to-plane distance between two
50  * clouds of corresponding points with normals, with the possibility of assigning
51  * weights to the correspondences.
52  *
53  * For additional details, see
54  * "Linear Least-Squares Optimization for Point-to-Plane ICP Surface Registration",
55  * Kok-Lim Low, 2004
56  *
57  * \note The class is templated on the source and target point types as well as on the
58  * output scalar of the 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>
64 : public TransformationEstimation<PointSource, PointTarget, Scalar> {
65 public:
66  using Ptr = shared_ptr<TransformationEstimationPointToPlaneLLSWeighted<PointSource,
67  PointTarget,
68  Scalar>>;
69  using ConstPtr =
70  shared_ptr<const TransformationEstimationPointToPlaneLLSWeighted<PointSource,
71  PointTarget,
72  Scalar>>;
73 
74  using Matrix4 =
76 
79 
80  /** \brief Estimate a rigid rotation transformation between a source and a target
81  * point cloud using SVD. \param[in] cloud_src the source point cloud dataset
82  * \param[in] cloud_tgt the target point cloud dataset
83  * \param[out] transformation_matrix the resultant transformation matrix
84  */
85  inline void
87  const pcl::PointCloud<PointTarget>& cloud_tgt,
88  Matrix4& transformation_matrix) const;
89 
90  /** \brief Estimate a rigid rotation transformation between a source and a target
91  * point cloud using SVD. \param[in] cloud_src the source point cloud dataset
92  * \param[in] indices_src the vector of indices describing the points of interest in
93  * \a cloud_src
94  * \param[in] cloud_tgt the target point cloud dataset
95  * \param[out] transformation_matrix the resultant transformation matrix
96  */
97  inline void
99  const pcl::Indices& indices_src,
100  const pcl::PointCloud<PointTarget>& cloud_tgt,
101  Matrix4& transformation_matrix) const;
102 
103  /** \brief Estimate a rigid rotation transformation between a source and a target
104  * point cloud using SVD. \param[in] cloud_src the source point cloud dataset
105  * \param[in] indices_src the vector of indices describing the points of interest in
106  * \a cloud_src
107  * \param[in] cloud_tgt the target point cloud dataset
108  * \param[in] indices_tgt the vector of indices describing the correspondences of the
109  * interest points from \a indices_src
110  * \param[out] transformation_matrix the resultant transformation matrix
111  */
112  inline void
114  const pcl::Indices& indices_src,
115  const pcl::PointCloud<PointTarget>& cloud_tgt,
116  const pcl::Indices& indices_tgt,
117  Matrix4& transformation_matrix) const;
118 
119  /** \brief Estimate a rigid rotation transformation between a source and a target
120  * point cloud using SVD. \param[in] cloud_src the source point cloud dataset
121  * \param[in] cloud_tgt the target point cloud dataset
122  * \param[in] correspondences the vector of correspondences between source and target
123  * point cloud \param[out] transformation_matrix the resultant transformation matrix
124  */
125  inline void
127  const pcl::PointCloud<PointTarget>& cloud_tgt,
128  const pcl::Correspondences& correspondences,
129  Matrix4& transformation_matrix) const;
130 
131  /** \brief Set the weights for the correspondences.
132  * \param[in] weights the weights for each correspondence
133  */
134  inline void
135  setCorrespondenceWeights(const std::vector<Scalar>& weights)
136  {
137  weights_ = weights;
138  }
139 
140 protected:
141  /** \brief Estimate a rigid rotation transformation between a source and a target
142  * \param[in] source_it an iterator over the source point cloud dataset
143  * \param[in] target_it an iterator over the target point cloud dataset
144  * \param weights_it
145  * \param[out] transformation_matrix the resultant transformation matrix
146  */
147  void
150  typename std::vector<Scalar>::const_iterator& weights_it,
151  Matrix4& transformation_matrix) const;
152 
153  /** \brief Construct a 4 by 4 transformation matrix from the provided rotation and
154  * translation. \param[in] alpha the rotation about the x-axis \param[in] beta the
155  * rotation about the y-axis \param[in] gamma the rotation about the z-axis \param[in]
156  * tx the x translation \param[in] ty the y translation \param[in] tz the z
157  * translation \param[out] transformation_matrix the resultant transformation matrix
158  */
159  inline void
160  constructTransformationMatrix(const double& alpha,
161  const double& beta,
162  const double& gamma,
163  const double& tx,
164  const double& ty,
165  const double& tz,
166  Matrix4& transformation_matrix) const;
167 
168  std::vector<Scalar> weights_;
169 };
170 } // namespace registration
171 } // namespace pcl
172 
173 #include <pcl/registration/impl/transformation_estimation_point_to_plane_lls_weighted.hpp>
Iterator class for point clouds with or without given indices.
TransformationEstimation represents the base class for methods for transformation estimation based on...
TransformationEstimationPointToPlaneLLSWeighted implements a Linear Least Squares (LLS) approximation...
shared_ptr< const TransformationEstimationPointToPlaneLLSWeighted< PointSource, PointTarget, Scalar > > ConstPtr
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.
shared_ptr< TransformationEstimationPointToPlaneLLSWeighted< PointSource, PointTarget, Scalar > > Ptr
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.
typename TransformationEstimation< PointSource, PointTarget, Scalar >::Matrix4 Matrix4
void setCorrespondenceWeights(const std::vector< Scalar > &weights)
Set the weights for the correspondences.
std::vector< pcl::Correspondence, Eigen::aligned_allocator< pcl::Correspondence > > Correspondences
IndicesAllocator<> Indices
Type used for indices in PCL.
Definition: types.h:133