Point Cloud Library (PCL)  1.14.1-dev
incremental_registration.h
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Point Cloud Library (PCL) - www.pointclouds.org
5  * Copyright (c) 2015, Michael 'v4hn' Goerner
6  * Copyright (c) 2015-, Open Perception, Inc.
7  *
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  *
14  * * Redistributions of source code must retain the above copyright
15  * notice, this list of conditions and the following disclaimer.
16  * * Redistributions in binary form must reproduce the above
17  * copyright notice, this list of conditions and the following
18  * disclaimer in the documentation and/or other materials provided
19  * with the distribution.
20  * * Neither the name of the copyright holder(s) nor the names of its
21  * contributors may be used to endorse or promote products derived
22  * from this software without specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
29  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
34  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35  * POSSIBILITY OF SUCH DAMAGE.
36  */
37 
38 #pragma once
39 
40 #include <pcl/registration/registration.h>
41 #include <pcl/point_cloud.h>
42 
43 namespace pcl {
44 namespace registration {
45 
46 /** \brief Incremental @ref IterativeClosestPoint class
47  *
48  * This class provides a way to register a stream of clouds where each cloud will be
49  * aligned to the previous cloud.
50  *
51  * \code
52  * IterativeClosestPoint<PointXYZ,PointXYZ>::Ptr icp
53  * (new IterativeClosestPoint<PointXYZ,PointXYZ>);
54  * icp->setMaxCorrespondenceDistance (0.05);
55  * icp->setMaximumIterations (50);
56  *
57  * IncrementalRegistration<PointXYZ> iicp;
58  * iicp.setRegistration (icp);
59  *
60  * while (true){
61  * PointCloud<PointXYZ>::Ptr cloud (new PointCloud<PointXYZ>);
62  * read_cloud (*cloud);
63  * iicp.registerCloud (cloud);
64  *
65  * PointCloud<PointXYZ>::Ptr tmp (new PointCloud<PointXYZ>);
66  * transformPointCloud (*cloud, *tmp, iicp.getAbsoluteTransform ());
67  * write_cloud (*tmp);
68  * }
69  * \endcode
70  *
71  * \author Michael 'v4hn' Goerner
72  * \ingroup registration
73  */
74 template <typename PointT, typename Scalar = float>
76 public:
79 
82 
84 
85  /** \brief Empty destructor */
86  virtual ~IncrementalRegistration() = default;
87 
88  /** \brief Register new point cloud incrementally
89  * \note You have to set a valid registration object with @ref setRegistration before
90  * using this \note The class doesn't copy cloud. If you afterwards change cloud, that
91  * will affect this class. \param[in] cloud point cloud to register \param[in]
92  * delta_estimate estimated transform between last registered cloud and this one
93  * \return true if registration converged
94  */
95  bool
96  registerCloud(const PointCloudConstPtr& cloud,
97  const Matrix4& delta_estimate = Matrix4::Identity());
98 
99  /** \brief Get estimated transform between the last two registered clouds */
100  inline Matrix4
101  getDeltaTransform() const;
102 
103  /** \brief Get estimated overall transform */
104  inline Matrix4
105  getAbsoluteTransform() const;
106 
107  /** \brief Reset incremental Registration without resetting registration_ */
108  inline void
109  reset();
110 
111  /** \brief Set registration instance used to align clouds */
112  inline void setRegistration(RegistrationPtr);
113 
115 
116 protected:
117  /** \brief last registered point cloud */
119 
120  /** \brief registration instance to align clouds */
122 
123  /** \brief estimated transforms */
126 };
127 
128 } // namespace registration
129 } // namespace pcl
130 
131 #include <pcl/registration/impl/incremental_registration.hpp>
shared_ptr< PointCloud< PointT > > Ptr
Definition: point_cloud.h:413
shared_ptr< const PointCloud< PointT > > ConstPtr
Definition: point_cloud.h:414
shared_ptr< Registration< PointSource, PointTarget, Scalar > > Ptr
Definition: registration.h:66
Eigen::Matrix< Scalar, 4, 4 > Matrix4
Definition: registration.h:59
Incremental IterativeClosestPoint class.
void setRegistration(RegistrationPtr)
Set registration instance used to align clouds.
RegistrationPtr registration_
registration instance to align clouds
bool registerCloud(const PointCloudConstPtr &cloud, const Matrix4 &delta_estimate=Matrix4::Identity())
Register new point cloud incrementally.
Matrix4 getDeltaTransform() const
Get estimated transform between the last two registered clouds.
Matrix4 getAbsoluteTransform() const
Get estimated overall transform.
typename pcl::PointCloud< PointT >::ConstPtr PointCloudConstPtr
typename pcl::PointCloud< PointT >::Ptr PointCloudPtr
typename pcl::Registration< PointT, PointT, Scalar >::Ptr RegistrationPtr
void reset()
Reset incremental Registration without resetting registration_.
PointCloudConstPtr last_cloud_
last registered point cloud
virtual ~IncrementalRegistration()=default
Empty destructor.
typename pcl::Registration< PointT, PointT, Scalar >::Matrix4 Matrix4
#define PCL_MAKE_ALIGNED_OPERATOR_NEW
Macro to signal a class requires a custom allocator.
Definition: memory.h:86