Point Cloud Library (PCL)  1.8.1
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 #ifndef PCL_REGISTRATION_INCREMENTAL_REGISTRATION_H_
39 #define PCL_REGISTRATION_INCREMENTAL_REGISTRATION_H_
40 
41 #include <pcl/point_cloud.h>
42 #include <pcl/registration/registration.h>
43 
44 namespace pcl {
45  namespace registration {
46 
47  /** \brief Incremental @ref IterativeClosestPoint class
48  *
49  * This class provides a way to register a stream of clouds where each cloud will be aligned to the previous cloud.
50  *
51  * \code
52  * IterativeClosestPoint<PointXYZ,PointXYZ>::Ptr icp (new IterativeClosestPoint<PointXYZ,PointXYZ>);
53  * icp->setMaxCorrespondenceDistance (0.05);
54  * icp->setMaximumIterations (50);
55  *
56  * IncrementalRegistration<PointXYZ> iicp;
57  * iicp.setRegistration (icp);
58  *
59  * while (true){
60  * PointCloud<PointXYZ>::Ptr cloud (new PointCloud<PointXYZ>);
61  * read_cloud (*cloud);
62  * iicp.registerCloud (cloud);
63  *
64  * PointCloud<PointXYZ>::Ptr tmp (new PointCloud<PointXYZ>);
65  * transformPointCloud (*cloud, *tmp, iicp.getAbsoluteTransform ());
66  * write_cloud (*tmp);
67  * }
68  * \endcode
69  *
70  * \author Michael 'v4hn' Goerner
71  * \ingroup registration
72  */
73  template <typename PointT, typename Scalar = float>
75  public:
78 
81 
83 
84  /** \brief Empty destructor */
86 
87  /** \brief Register new point cloud incrementally
88  * \note You have to set a valid registration object with @ref setRegistration before using this
89  * \note The class doesn't copy cloud. If you afterwards change cloud, that will affect this class.
90  * \param[in] cloud point cloud to register
91  * \param[in] delta_estimate estimated transform between last registered cloud and this one
92  * \return true if registration converged
93  */
94  bool
95  registerCloud (const PointCloudConstPtr& cloud, const Matrix4& delta_estimate = Matrix4::Identity ());
96 
97  /** \brief Get estimated transform between the last two registered clouds */
98  inline Matrix4
99  getDeltaTransform () const;
100 
101  /** \brief Get estimated overall transform */
102  inline Matrix4
103  getAbsoluteTransform () const;
104 
105  /** \brief Reset incremental Registration without resetting registration_ */
106  inline void
107  reset ();
108 
109  /** \brief Set registration instance used to align clouds */
110  inline void
111  setRegistration (RegistrationPtr);
112  protected:
113 
114  /** \brief last registered point cloud */
115  PointCloudConstPtr last_cloud_;
116 
117  /** \brief registration instance to align clouds */
118  RegistrationPtr registration_;
119 
120  /** \brief estimated transforms */
122  Matrix4 abs_transform_;
123  };
124 
125  }
126 }
127 
128 #include <pcl/registration/impl/incremental_registration.hpp>
129 
130 #endif /*PCL_REGISTRATION_INCREMENTAL_REGISTRATION_H_*/
bool registerCloud(const PointCloudConstPtr &cloud, const Matrix4 &delta_estimate=Matrix4::Identity())
Register new point cloud incrementally.
boost::shared_ptr< Registration< PointSource, PointTarget, Scalar > > Ptr
Definition: registration.h:72
Eigen::Matrix< Scalar, 4, 4 > Matrix4
Definition: registration.h:65
boost::shared_ptr< PointCloud< PointT > > Ptr
Definition: point_cloud.h:428
pcl::Registration< PointT, PointT, Scalar >::Matrix4 Matrix4
PointCloudConstPtr last_cloud_
last registered point cloud
void reset()
Reset incremental Registration without resetting registration_.
RegistrationPtr registration_
registration instance to align clouds
boost::shared_ptr< const PointCloud< PointT > > ConstPtr
Definition: point_cloud.h:429
Incremental IterativeClosestPoint class.
Matrix4 getAbsoluteTransform() const
Get estimated overall transform.
Matrix4 getDeltaTransform() const
Get estimated transform between the last two registered clouds.
pcl::Registration< PointT, PointT, Scalar >::Ptr RegistrationPtr
void setRegistration(RegistrationPtr)
Set registration instance used to align clouds.
pcl::PointCloud< PointT >::ConstPtr PointCloudConstPtr