Point Cloud Library (PCL)  1.11.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 \param[in] cloud_tgt the target point cloud dataset \param[out]
94  * transformation_matrix the resultant transformation matrix
95  */
96  inline void
98  const std::vector<int>& indices_src,
99  const pcl::PointCloud<PointTarget>& cloud_tgt,
100  Matrix4& transformation_matrix) const;
101 
102  /** \brief Estimate a rigid rotation transformation between a source and a target
103  * point cloud using SVD. \param[in] cloud_src the source point cloud dataset
104  * \param[in] indices_src the vector of indices describing the points of interest in
105  * \a cloud_src \param[in] cloud_tgt the target point cloud dataset \param[in]
106  * indices_tgt the vector of indices describing the correspondences of the interest
107  * points from \a indices_src \param[out] transformation_matrix the resultant
108  * transformation matrix
109  */
110  inline void
112  const std::vector<int>& indices_src,
113  const pcl::PointCloud<PointTarget>& cloud_tgt,
114  const std::vector<int>& indices_tgt,
115  Matrix4& transformation_matrix) const;
116 
117  /** \brief Estimate a rigid rotation transformation between a source and a target
118  * point cloud using SVD. \param[in] cloud_src the source point cloud dataset
119  * \param[in] cloud_tgt the target point cloud dataset
120  * \param[in] correspondences the vector of correspondences between source and target
121  * point cloud \param[out] transformation_matrix the resultant transformation matrix
122  */
123  inline void
125  const pcl::PointCloud<PointTarget>& cloud_tgt,
126  const pcl::Correspondences& correspondences,
127  Matrix4& transformation_matrix) const;
128 
129  /** \brief Set the weights for the correspondences.
130  * \param[in] weights the weights for each correspondence
131  */
132  inline void
133  setCorrespondenceWeights(const std::vector<Scalar>& weights)
134  {
135  weights_ = weights;
136  }
137 
138 protected:
139  /** \brief Estimate a rigid rotation transformation between a source and a target
140  * \param[in] source_it an iterator over the source point cloud dataset
141  * \param[in] target_it an iterator over the target point cloud dataset
142  * \param weights_it
143  * \param[out] transformation_matrix the resultant transformation matrix
144  */
145  void
148  typename std::vector<Scalar>::const_iterator& weights_it,
149  Matrix4& transformation_matrix) const;
150 
151  /** \brief Construct a 4 by 4 transformation matrix from the provided rotation and
152  * translation. \param[in] alpha the rotation about the x-axis \param[in] beta the
153  * rotation about the y-axis \param[in] gamma the rotation about the z-axis \param[in]
154  * tx the x translation \param[in] ty the y translation \param[in] tz the z
155  * translation \param[out] transformation_matrix the resultant transformation matrix
156  */
157  inline void
158  constructTransformationMatrix(const double& alpha,
159  const double& beta,
160  const double& gamma,
161  const double& tx,
162  const double& ty,
163  const double& tz,
164  Matrix4& transformation_matrix) const;
165 
166  std::vector<Scalar> weights_;
167 };
168 } // namespace registration
169 } // namespace pcl
170 
171 #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:77
pcl::registration::TransformationEstimationPointToPlaneLLSWeighted
TransformationEstimationPointToPlaneLLSWeighted implements a Linear Least Squares (LLS) approximation...
Definition: transformation_estimation_point_to_plane_lls_weighted.h:63
pcl::registration::TransformationEstimationPointToPlaneLLSWeighted::~TransformationEstimationPointToPlaneLLSWeighted
virtual ~TransformationEstimationPointToPlaneLLSWeighted()
Definition: transformation_estimation_point_to_plane_lls_weighted.h:78
pcl::registration::TransformationEstimation::Matrix4
Eigen::Matrix< Scalar, 4, 4 > Matrix4
Definition: transformation_estimation.h:64
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:52
pcl::registration::TransformationEstimationPointToPlaneLLSWeighted::Matrix4
typename TransformationEstimation< PointSource, PointTarget, Scalar >::Matrix4 Matrix4
Definition: transformation_estimation_point_to_plane_lls_weighted.h:75
pcl::registration::TransformationEstimationPointToPlaneLLSWeighted::ConstPtr
shared_ptr< const TransformationEstimationPointToPlaneLLSWeighted< PointSource, PointTarget, Scalar > > ConstPtr
Definition: transformation_estimation_point_to_plane_lls_weighted.h:72
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:133
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:162
pcl::ConstCloudIterator
Iterator class for point clouds with or without given indices.
Definition: cloud_iterator.h:120
pcl::registration::TransformationEstimationPointToPlaneLLSWeighted::Ptr
shared_ptr< TransformationEstimationPointToPlaneLLSWeighted< PointSource, PointTarget, Scalar > > Ptr
Definition: transformation_estimation_point_to_plane_lls_weighted.h:68
pcl::registration::TransformationEstimationPointToPlaneLLSWeighted::weights_
std::vector< Scalar > weights_
Definition: transformation_estimation_point_to_plane_lls_weighted.h:166
pcl::Correspondences
std::vector< pcl::Correspondence, Eigen::aligned_allocator< pcl::Correspondence > > Correspondences
Definition: correspondence.h:89
pcl::registration::TransformationEstimation
TransformationEstimation represents the base class for methods for transformation estimation based on...
Definition: transformation_estimation.h:62