Point Cloud Library (PCL)  1.14.1-dev
transformation_estimation_symmetric_point_to_plane_lls.h
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Point Cloud Library (PCL) - www.pointclouds.org
5  * Copyright (c) 2019-, 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  */
37 
38 #pragma once
39 
40 #include <pcl/registration/transformation_estimation.h>
41 #include <pcl/cloud_iterator.h>
42 
43 namespace pcl {
44 namespace registration {
45 /** \brief @b TransformationEstimationSymmetricPointToPlaneLLS implements a Linear Least
46  * Squares (LLS) approximation for minimizing the symmetric point-to-plane distance
47  * between two clouds of corresponding points with normals.
48  *
49  * For additional details, see
50  * "Linear Least-Squares Optimization for Point-to-Plane ICP Surface Registration",
51  * Kok-Lim Low, 2004 "A Symmetric Objective Function for ICP", Szymon Rusinkiewicz, 2019
52  *
53  * \note The class is templated on the source and target point types as well as on the
54  * output scalar of the transformation matrix (i.e., float or double). Default: float.
55  * \author Matthew Cong
56  * \ingroup registration
57  */
58 template <typename PointSource, typename PointTarget, typename Scalar = float>
60 : public TransformationEstimation<PointSource, PointTarget, Scalar> {
61 public:
62  using Ptr = shared_ptr<TransformationEstimationSymmetricPointToPlaneLLS<PointSource,
63  PointTarget,
64  Scalar>>;
65  using ConstPtr =
66  shared_ptr<const TransformationEstimationSymmetricPointToPlaneLLS<PointSource,
67  PointTarget,
68  Scalar>>;
69 
70  using Matrix4 =
72  using Vector6 = Eigen::Matrix<Scalar, 6, 1>;
73 
76 
77  /** \brief Estimate a rigid rotation transformation between a source and a target
78  * point cloud using SVD. \param[in] cloud_src the source point cloud dataset
79  * \param[in] cloud_tgt the target point cloud dataset
80  * \param[out] transformation_matrix the resultant transformation matrix
81  */
82  inline void
84  const pcl::PointCloud<PointTarget>& cloud_tgt,
85  Matrix4& transformation_matrix) const override;
86 
87  /** \brief Estimate a rigid rotation transformation between a source and a target
88  * point cloud using SVD. \param[in] cloud_src the source point cloud dataset
89  * \param[in] indices_src the vector of indices describing the points of interest in
90  * \a cloud_src
91  * \param[in] cloud_tgt the target point cloud dataset
92  * \param[out] transformation_matrix the resultant transformation matrix
93  */
94  inline void
96  const pcl::Indices& indices_src,
97  const pcl::PointCloud<PointTarget>& cloud_tgt,
98  Matrix4& transformation_matrix) const override;
99 
100  /** \brief Estimate a rigid rotation transformation between a source and a target
101  * point cloud using SVD. \param[in] cloud_src the source point cloud dataset
102  * \param[in] indices_src the vector of indices describing the points of interest in
103  * \a cloud_src
104  * \param[in] cloud_tgt the target point cloud dataset
105  * \param[in] indices_tgt the vector of indices describing the correspondences of the
106  * interest points from \a indices_src
107  * \param[out] transformation_matrix the resultant transformation matrix
108  */
109  inline void
111  const pcl::Indices& indices_src,
112  const pcl::PointCloud<PointTarget>& cloud_tgt,
113  const pcl::Indices& indices_tgt,
114  Matrix4& transformation_matrix) const override;
115 
116  /** \brief Estimate a rigid rotation transformation between a source and a target
117  * point cloud using SVD. \param[in] cloud_src the source point cloud dataset
118  * \param[in] cloud_tgt the target point cloud dataset
119  * \param[in] correspondences the vector of correspondences between source and target
120  * point cloud \param[out] transformation_matrix the resultant transformation matrix
121  */
122  inline void
124  const pcl::PointCloud<PointTarget>& cloud_tgt,
125  const pcl::Correspondences& correspondences,
126  Matrix4& transformation_matrix) const override;
127 
128  /** \brief Set whether or not to negate source or target normals on a per-point basis
129  * such that they point in the same direction. \param[in]
130  * enforce_same_direction_normals whether to negate source or target normals on a
131  * per-point basis such that they point in the same direction.
132  */
133  inline void
134  setEnforceSameDirectionNormals(bool enforce_same_direction_normals);
135 
136  /** \brief Obtain whether source or target normals are negated on a per-point basis
137  * such that they point in the same direction or not */
138  inline bool
140 
141 protected:
142  /** \brief Estimate a rigid rotation transformation between a source and a target
143  * \param[in] source_it an iterator over the source point cloud dataset
144  * \param[in] target_it an iterator over the target point cloud dataset
145  * \param[out] transformation_matrix the resultant transformation matrix
146  */
147  void
150  Matrix4& transformation_matrix) const;
151 
152  /** \brief Construct a 4 by 4 transformation matrix from the provided rotation and
153  * translation. \param[in] parameters (alpha, beta, gamma, tx, ty, tz) specifying
154  * rotation about the x, y, and z-axis and translation along the the x, y, and z-axis
155  * respectively \param[out] transformation_matrix the resultant transformation matrix
156  */
157  inline void
158  constructTransformationMatrix(const Vector6& parameters,
159  Matrix4& transformation_matrix) const;
160 
161  /** \brief Whether or not to negate source and/or target normals such that they point
162  * in the same direction */
164 };
165 } // namespace registration
166 } // namespace pcl
167 
168 #include <pcl/registration/impl/transformation_estimation_symmetric_point_to_plane_lls.hpp>
Iterator class for point clouds with or without given indices.
TransformationEstimation represents the base class for methods for transformation estimation based on...
TransformationEstimationSymmetricPointToPlaneLLS implements a Linear Least Squares (LLS) approximatio...
bool enforce_same_direction_normals_
Whether or not to negate source and/or target normals such that they point in the same direction.
bool getEnforceSameDirectionNormals()
Obtain whether source or target normals are negated on a per-point basis such that they point in the ...
shared_ptr< const TransformationEstimationSymmetricPointToPlaneLLS< PointSource, PointTarget, Scalar > > ConstPtr
void estimateRigidTransformation(const pcl::PointCloud< PointSource > &cloud_src, const pcl::PointCloud< PointTarget > &cloud_tgt, Matrix4 &transformation_matrix) const override
Estimate a rigid rotation transformation between a source and a target point cloud using SVD.
shared_ptr< TransformationEstimationSymmetricPointToPlaneLLS< PointSource, PointTarget, Scalar > > Ptr
typename TransformationEstimation< PointSource, PointTarget, Scalar >::Matrix4 Matrix4
void setEnforceSameDirectionNormals(bool enforce_same_direction_normals)
Set whether or not to negate source or target normals on a per-point basis such that they point in th...
void constructTransformationMatrix(const Vector6 &parameters, Matrix4 &transformation_matrix) const
Construct a 4 by 4 transformation matrix from the provided rotation and translation.
std::vector< pcl::Correspondence, Eigen::aligned_allocator< pcl::Correspondence > > Correspondences
IndicesAllocator<> Indices
Type used for indices in PCL.
Definition: types.h:133