Point Cloud Library (PCL)  1.14.1-dev
transformation_estimation_2D.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  *
37  */
38 
39 #pragma once
40 
41 #include <pcl/registration/transformation_estimation.h>
42 
43 namespace pcl {
44 namespace registration {
45 /** @b TransformationEstimation2D implements a simple 2D rigid transformation
46  * estimation (x, y, theta) for a given pair of datasets.
47  *
48  * The two datasets should already be transformed so that the reference plane
49  * equals z = 0.
50  *
51  * \note The class is templated on the source and target point types as well as on the
52  * output scalar of the transformation matrix (i.e., float or double). Default: float.
53  *
54  * \author Suat Gedikli
55  * \ingroup registration
56  */
57 template <typename PointSource, typename PointTarget, typename Scalar = float>
59 : public TransformationEstimation<PointSource, PointTarget, Scalar> {
60 public:
61  using Ptr = shared_ptr<TransformationEstimation2D<PointSource, PointTarget, Scalar>>;
62  using ConstPtr =
63  shared_ptr<const TransformationEstimation2D<PointSource, PointTarget, Scalar>>;
64 
65  using Matrix4 =
67 
69  virtual ~TransformationEstimation2D() = default;
70 
71  /** \brief Estimate a rigid transformation between a source and a target point cloud
72  * in 2D. \param[in] cloud_src the source point cloud dataset \param[in] cloud_tgt the
73  * target point cloud dataset \param[out] transformation_matrix the resultant
74  * transformation matrix
75  */
76  inline void
78  const pcl::PointCloud<PointTarget>& cloud_tgt,
79  Matrix4& transformation_matrix) const;
80 
81  /** \brief Estimate a rigid transformation between a source and a target point cloud
82  * in 2D. \param[in] cloud_src the source point cloud dataset \param[in] indices_src
83  * the vector of indices describing the points of interest in \a cloud_src
84  * \param[in] cloud_tgt the target point cloud dataset
85  * \param[out] transformation_matrix the resultant transformation matrix
86  */
87  inline void
89  const pcl::Indices& indices_src,
90  const pcl::PointCloud<PointTarget>& cloud_tgt,
91  Matrix4& transformation_matrix) const;
92 
93  /** \brief Estimate a rigid transformation between a source and a target point cloud
94  * in 2D. \param[in] cloud_src the source point cloud dataset \param[in] indices_src
95  * the vector of indices describing the points of interest in \a cloud_src
96  * \param[in] cloud_tgt the target point cloud dataset
97  * \param[in] indices_tgt the vector of indices describing the correspondences of the
98  * interest points from \a indices_src
99  * \param[out] transformation_matrix the resultant transformation matrix
100  */
101  virtual void
103  const pcl::Indices& indices_src,
104  const pcl::PointCloud<PointTarget>& cloud_tgt,
105  const pcl::Indices& indices_tgt,
106  Matrix4& transformation_matrix) const;
107 
108  /** \brief Estimate a rigid transformation between a source and a target point cloud
109  * in 2D. \param[in] cloud_src the source point cloud dataset \param[in] cloud_tgt the
110  * target point cloud dataset \param[in] correspondences the vector of correspondences
111  * between source and target point cloud \param[out] transformation_matrix the
112  * resultant transformation matrix
113  */
114  virtual void
116  const pcl::PointCloud<PointTarget>& cloud_tgt,
117  const pcl::Correspondences& correspondences,
118  Matrix4& transformation_matrix) const;
119 
120 protected:
121  /** \brief Estimate a rigid rotation transformation between a source and a target
122  * \param[in] source_it an iterator over the source point cloud dataset
123  * \param[in] target_it an iterator over the target point cloud dataset
124  * \param[out] transformation_matrix the resultant transformation matrix
125  */
126  void
129  Matrix4& transformation_matrix) const;
130 
131  /** \brief Obtain a 4x4 rigid transformation matrix from a correlation matrix H = src
132  * * tgt' \param[in] cloud_src_demean the input source cloud, demeaned, in Eigen
133  * format \param[in] centroid_src the input source centroid, in Eigen format
134  * \param[in] cloud_tgt_demean the input target cloud, demeaned, in Eigen format
135  * \param[in] centroid_tgt the input target cloud, in Eigen format
136  * \param[out] transformation_matrix the resultant 4x4 rigid transformation matrix
137  */
138  void
140  const Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic>& cloud_src_demean,
141  const Eigen::Matrix<Scalar, 4, 1>& centroid_src,
142  const Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic>& cloud_tgt_demean,
143  const Eigen::Matrix<Scalar, 4, 1>& centroid_tgt,
144  Matrix4& transformation_matrix) const;
145 };
146 
147 } // namespace registration
148 } // namespace pcl
149 
150 #include <pcl/registration/impl/transformation_estimation_2D.hpp>
Iterator class for point clouds with or without given indices.
TransformationEstimation2D implements a simple 2D rigid transformation estimation (x,...
void getTransformationFromCorrelation(const Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic > &cloud_src_demean, const Eigen::Matrix< Scalar, 4, 1 > &centroid_src, const Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic > &cloud_tgt_demean, const Eigen::Matrix< Scalar, 4, 1 > &centroid_tgt, Matrix4 &transformation_matrix) const
Obtain a 4x4 rigid transformation matrix from a correlation matrix H = src.
void estimateRigidTransformation(const pcl::PointCloud< PointSource > &cloud_src, const pcl::PointCloud< PointTarget > &cloud_tgt, Matrix4 &transformation_matrix) const
Estimate a rigid transformation between a source and a target point cloud in 2D.
typename TransformationEstimation< PointSource, PointTarget, Scalar >::Matrix4 Matrix4
shared_ptr< const TransformationEstimation2D< PointSource, PointTarget, Scalar > > ConstPtr
shared_ptr< TransformationEstimation2D< PointSource, PointTarget, Scalar > > Ptr
TransformationEstimation represents the base class for methods for transformation estimation based on...
std::vector< pcl::Correspondence, Eigen::aligned_allocator< pcl::Correspondence > > Correspondences
IndicesAllocator<> Indices
Type used for indices in PCL.
Definition: types.h:133