Point Cloud Library (PCL)  1.9.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/point_cloud.h>
41 #include <pcl/registration/registration.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 aligned to the previous cloud.
49  *
50  * \code
51  * IterativeClosestPoint<PointXYZ,PointXYZ>::Ptr icp (new IterativeClosestPoint<PointXYZ,PointXYZ>);
52  * icp->setMaxCorrespondenceDistance (0.05);
53  * icp->setMaximumIterations (50);
54  *
55  * IncrementalRegistration<PointXYZ> iicp;
56  * iicp.setRegistration (icp);
57  *
58  * while (true){
59  * PointCloud<PointXYZ>::Ptr cloud (new PointCloud<PointXYZ>);
60  * read_cloud (*cloud);
61  * iicp.registerCloud (cloud);
62  *
63  * PointCloud<PointXYZ>::Ptr tmp (new PointCloud<PointXYZ>);
64  * transformPointCloud (*cloud, *tmp, iicp.getAbsoluteTransform ());
65  * write_cloud (*tmp);
66  * }
67  * \endcode
68  *
69  * \author Michael 'v4hn' Goerner
70  * \ingroup registration
71  */
72  template <typename PointT, typename Scalar = float>
74  public:
77 
80 
82 
83  /** \brief Empty destructor */
85 
86  /** \brief Register new point cloud incrementally
87  * \note You have to set a valid registration object with @ref setRegistration before using this
88  * \note The class doesn't copy cloud. If you afterwards change cloud, that will affect this class.
89  * \param[in] cloud point cloud to register
90  * \param[in] delta_estimate estimated transform between last registered cloud and this one
91  * \return true if registration converged
92  */
93  bool
94  registerCloud (const PointCloudConstPtr& cloud, const Matrix4& delta_estimate = Matrix4::Identity ());
95 
96  /** \brief Get estimated transform between the last two registered clouds */
97  inline Matrix4
98  getDeltaTransform () const;
99 
100  /** \brief Get estimated overall transform */
101  inline Matrix4
102  getAbsoluteTransform () const;
103 
104  /** \brief Reset incremental Registration without resetting registration_ */
105  inline void
106  reset ();
107 
108  /** \brief Set registration instance used to align clouds */
109  inline void
111  protected:
112 
113  /** \brief last registered point cloud */
115 
116  /** \brief registration instance to align clouds */
118 
119  /** \brief estimated transforms */
122  };
123 
124  }
125 }
126 
127 #include <pcl/registration/impl/incremental_registration.hpp>
typename pcl::PointCloud< PointT >::Ptr PointCloudPtr
This file defines compatibility wrappers for low level I/O functions.
Definition: convolution.h:45
bool registerCloud(const PointCloudConstPtr &cloud, const Matrix4 &delta_estimate=Matrix4::Identity())
Register new point cloud incrementally.
typename pcl::Registration< PointT, PointT, Scalar >::Ptr RegistrationPtr
typename pcl::PointCloud< PointT >::ConstPtr PointCloudConstPtr
Eigen::Matrix< Scalar, 4, 4 > Matrix4
Definition: registration.h:63
PointCloudConstPtr last_cloud_
last registered point cloud
typename pcl::Registration< PointT, PointT, Scalar >::Matrix4 Matrix4
void reset()
Reset incremental Registration without resetting registration_.
RegistrationPtr registration_
registration instance to align clouds
boost::shared_ptr< PointCloud< PointT > > Ptr
Definition: point_cloud.h:444
Incremental IterativeClosestPoint class.
boost::shared_ptr< const PointCloud< PointT > > ConstPtr
Definition: point_cloud.h:445
Matrix4 getAbsoluteTransform() const
Get estimated overall transform.
Matrix4 getDeltaTransform() const
Get estimated transform between the last two registered clouds.
boost::shared_ptr< Registration< PointSource, PointTarget, Scalar > > Ptr
Definition: registration.h:70
void setRegistration(RegistrationPtr)
Set registration instance used to align clouds.