Point Cloud Library (PCL)  1.11.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 
77 
78  /** \brief Estimate a rigid rotation transformation between a source and a target
79  * point cloud using SVD. \param[in] cloud_src the source point cloud dataset
80  * \param[in] cloud_tgt the target point cloud dataset
81  * \param[out] transformation_matrix the resultant transformation matrix
82  */
83  inline void
85  const pcl::PointCloud<PointTarget>& cloud_tgt,
86  Matrix4& transformation_matrix) const override;
87 
88  /** \brief Estimate a rigid rotation transformation between a source and a target
89  * point cloud using SVD. \param[in] cloud_src the source point cloud dataset
90  * \param[in] indices_src the vector of indices describing the points of interest in
91  * \a cloud_src \param[in] cloud_tgt the target point cloud dataset \param[out]
92  * transformation_matrix the resultant transformation matrix
93  */
94  inline void
96  const std::vector<int>& 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 \param[in] cloud_tgt the target point cloud dataset \param[in]
104  * indices_tgt the vector of indices describing the correspondences of the interest
105  * points from \a indices_src \param[out] transformation_matrix the resultant
106  * transformation matrix
107  */
108  inline void
110  const std::vector<int>& indices_src,
111  const pcl::PointCloud<PointTarget>& cloud_tgt,
112  const std::vector<int>& indices_tgt,
113  Matrix4& transformation_matrix) const override;
114 
115  /** \brief Estimate a rigid rotation transformation between a source and a target
116  * point cloud using SVD. \param[in] cloud_src the source point cloud dataset
117  * \param[in] cloud_tgt the target point cloud dataset
118  * \param[in] correspondences the vector of correspondences between source and target
119  * point cloud \param[out] transformation_matrix the resultant transformation matrix
120  */
121  inline void
123  const pcl::PointCloud<PointTarget>& cloud_tgt,
124  const pcl::Correspondences& correspondences,
125  Matrix4& transformation_matrix) const override;
126 
127  /** \brief Set whether or not to negate source or target normals on a per-point basis
128  * such that they point in the same direction. \param[in]
129  * enforce_same_direction_normals whether to negate source or target normals on a
130  * per-point basis such that they point in the same direction.
131  */
132  inline void
133  setEnforceSameDirectionNormals(bool enforce_same_direction_normals);
134 
135  /** \brief Obtain whether source or target normals are negated on a per-point basis
136  * such that they point in the same direction or not */
137  inline bool
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[out] transformation_matrix the resultant transformation matrix
145  */
146  void
149  Matrix4& transformation_matrix) const;
150 
151  /** \brief Construct a 4 by 4 transformation matrix from the provided rotation and
152  * translation. \param[in] parameters (alpha, beta, gamma, tx, ty, tz) specifying
153  * rotation about the x, y, and z-axis and translation along the the x, y, and z-axis
154  * respectively \param[out] transformation_matrix the resultant transformation matrix
155  */
156  inline void
157  constructTransformationMatrix(const Vector6& parameters,
158  Matrix4& transformation_matrix) const;
159 
160  /** \brief Whether or not to negate source and/or target normals such that they point
161  * in the same direction */
163 };
164 } // namespace registration
165 } // namespace pcl
166 
167 #include <pcl/registration/impl/transformation_estimation_symmetric_point_to_plane_lls.hpp>
pcl::registration::TransformationEstimationSymmetricPointToPlaneLLS::Ptr
shared_ptr< TransformationEstimationSymmetricPointToPlaneLLS< PointSource, PointTarget, Scalar > > Ptr
Definition: transformation_estimation_symmetric_point_to_plane_lls.h:64
pcl
Definition: convolution.h:46
pcl::registration::TransformationEstimationSymmetricPointToPlaneLLS::Matrix4
typename TransformationEstimation< PointSource, PointTarget, Scalar >::Matrix4 Matrix4
Definition: transformation_estimation_symmetric_point_to_plane_lls.h:71
pcl::registration::TransformationEstimation::Matrix4
Eigen::Matrix< Scalar, 4, 4 > Matrix4
Definition: transformation_estimation.h:64
pcl::registration::TransformationEstimationSymmetricPointToPlaneLLS::enforce_same_direction_normals_
bool enforce_same_direction_normals_
Whether or not to negate source and/or target normals such that they point in the same direction.
Definition: transformation_estimation_symmetric_point_to_plane_lls.h:162
pcl::registration::TransformationEstimationSymmetricPointToPlaneLLS::estimateRigidTransformation
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.
Definition: transformation_estimation_symmetric_point_to_plane_lls.hpp:49
pcl::PointCloud< PointSource >
pcl::registration::TransformationEstimationSymmetricPointToPlaneLLS::setEnforceSameDirectionNormals
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...
Definition: transformation_estimation_symmetric_point_to_plane_lls.hpp:206
pcl::registration::TransformationEstimationSymmetricPointToPlaneLLS::constructTransformationMatrix
void constructTransformationMatrix(const Vector6 &parameters, Matrix4 &transformation_matrix) const
Construct a 4 by 4 transformation matrix from the provided rotation and translation.
Definition: transformation_estimation_symmetric_point_to_plane_lls.hpp:131
pcl::registration::TransformationEstimationSymmetricPointToPlaneLLS::ConstPtr
shared_ptr< const TransformationEstimationSymmetricPointToPlaneLLS< PointSource, PointTarget, Scalar > > ConstPtr
Definition: transformation_estimation_symmetric_point_to_plane_lls.h:68
pcl::registration::TransformationEstimationSymmetricPointToPlaneLLS::Vector6
Eigen::Matrix< Scalar, 6, 1 > Vector6
Definition: transformation_estimation_symmetric_point_to_plane_lls.h:72
pcl::registration::TransformationEstimationSymmetricPointToPlaneLLS
TransformationEstimationSymmetricPointToPlaneLLS implements a Linear Least Squares (LLS) approximatio...
Definition: transformation_estimation_symmetric_point_to_plane_lls.h:59
pcl::registration::TransformationEstimationSymmetricPointToPlaneLLS::getEnforceSameDirectionNormals
bool getEnforceSameDirectionNormals()
Obtain whether source or target normals are negated on a per-point basis such that they point in the ...
Definition: transformation_estimation_symmetric_point_to_plane_lls.hpp:214
pcl::registration::TransformationEstimationSymmetricPointToPlaneLLS::~TransformationEstimationSymmetricPointToPlaneLLS
~TransformationEstimationSymmetricPointToPlaneLLS()
Definition: transformation_estimation_symmetric_point_to_plane_lls.h:76
pcl::ConstCloudIterator
Iterator class for point clouds with or without given indices.
Definition: cloud_iterator.h:120
pcl::registration::TransformationEstimationSymmetricPointToPlaneLLS::TransformationEstimationSymmetricPointToPlaneLLS
TransformationEstimationSymmetricPointToPlaneLLS()
Definition: transformation_estimation_symmetric_point_to_plane_lls.h:74
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