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