Point Cloud Library (PCL)  1.9.1
meta_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_META_REGISTRATION_H_
39 #define PCL_REGISTRATION_META_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 Meta @ref Registration class
48  * \note This method accumulates all registered points and becomes more costly with each registered point cloud.
49  *
50  * This class provides a way to register a stream of clouds where each cloud
51  * will be aligned to the conglomerate of all previous clouds.
52  *
53  * \code
54  * IterativeClosestPoint<PointXYZ,PointXYZ>::Ptr icp (new IterativeClosestPoint<PointXYZ,PointXYZ>);
55  * icp->setMaxCorrespondenceDistance (0.05);
56  * icp->setMaximumIterations (50);
57  *
58  * MetaRegistration<PointXYZ> mreg;
59  * mreg.setRegistration (icp);
60  *
61  * while (true)
62  * {
63  * PointCloud<PointXYZ>::Ptr cloud (new PointCloud<PointXYZ>);
64  * read_cloud (*cloud);
65  * mreg.registerCloud (cloud);
66  *
67  * PointCloud<PointXYZ>::Ptr tmp (new PointCloud<PointXYZ>);
68  * transformPointCloud (*cloud, *tmp, mreg.getAbsoluteTransform ());
69  * write_cloud (*tmp);
70  * }
71  * \endcode
72  *
73  * \author Michael 'v4hn' Goerner
74  * \ingroup registration
75  */
76  template <typename PointT, typename Scalar = float>
78  public:
81 
84 
86 
87  /** \brief Empty destructor */
88  virtual ~MetaRegistration () {};
89 
90  /** \brief Register new point cloud
91  * \note You have to set a valid registration object with @ref setICP before using this
92  * \param[in] cloud point cloud to register
93  * \param[in] delta_estimate estimated transform between last registered cloud and this one
94  * \return true if ICP converged
95  */
96  bool
97  registerCloud (const PointCloudConstPtr& cloud, const Matrix4& delta_estimate = Matrix4::Identity ());
98 
99  /** \brief Get estimated transform of the last registered cloud */
100  inline Matrix4
101  getAbsoluteTransform () const;
102 
103  /** \brief Reset MetaICP without resetting registration_ */
104  inline void
105  reset ();
106 
107  /** \brief Set registration instance used to align clouds */
108  inline void
109  setRegistration (RegistrationPtr);
110 
111  /** \brief get accumulated meta point cloud */
112  inline PointCloudConstPtr
113  getMetaCloud () const;
114  protected:
115 
116  /** \brief registered accumulated point cloud */
117  PointCloudPtr full_cloud_;
118 
119  /** \brief registration instance to align clouds */
120  RegistrationPtr registration_;
121 
122  /** \brief estimated transform */
123  Matrix4 abs_transform_;
124  };
125 
126  }
127 }
128 
129 #include <pcl/registration/impl/meta_registration.hpp>
130 
131 #endif /*PCL_REGISTRATION_META_REGISTRATION_H_*/
pcl::PointCloud< PointT >::Ptr PointCloudPtr
This file defines compatibility wrappers for low level I/O functions.
Definition: convolution.h:45
void reset()
Reset MetaICP without resetting registration_.
PointCloudPtr full_cloud_
registered accumulated point cloud
pcl::Registration< PointT, PointT, Scalar >::Matrix4 Matrix4
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
Matrix4 getAbsoluteTransform() const
Get estimated transform of the last registered cloud.
RegistrationPtr registration_
registration instance to align clouds
void setRegistration(RegistrationPtr)
Set registration instance used to align clouds.
PointCloudConstPtr getMetaCloud() const
get accumulated meta point cloud
pcl::PointCloud< PointT >::ConstPtr PointCloudConstPtr
virtual ~MetaRegistration()
Empty destructor.
boost::shared_ptr< const PointCloud< PointT > > ConstPtr
Definition: point_cloud.h:429
Matrix4 abs_transform_
estimated transform
bool registerCloud(const PointCloudConstPtr &cloud, const Matrix4 &delta_estimate=Matrix4::Identity())
Register new point cloud.
pcl::Registration< PointT, PointT, Scalar >::Ptr RegistrationPtr