iLab Neuromorphic Robotics Toolkit  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Registration.H
Go to the documentation of this file.
1 /*! @file
2  @author Shane Grant
3  @copyright GNU Public License (GPL v3)
4  @section License
5  @verbatim
6  // ////////////////////////////////////////////////////////////////////////
7  // The iLab Neuromorphic Robotics Toolkit (NRT) //
8  // Copyright 2010-2012 by the University of Southern California (USC) //
9  // and the iLab at USC. //
10  // //
11  // iLab - University of Southern California //
12  // Hedco Neurociences Building, Room HNB-10 //
13  // Los Angeles, Ca 90089-2520 - USA //
14  // //
15  // See http://ilab.usc.edu for information about this project. //
16  // ////////////////////////////////////////////////////////////////////////
17  // This file is part of The iLab Neuromorphic Robotics Toolkit. //
18  // //
19  // The iLab Neuromorphic Robotics Toolkit is free software: you can //
20  // redistribute it and/or modify it under the terms of the GNU General //
21  // Public License as published by the Free Software Foundation, either //
22  // version 3 of the License, or (at your option) any later version. //
23  // //
24  // The iLab Neuromorphic Robotics Toolkit is distributed in the hope //
25  // that it will be useful, but WITHOUT ANY WARRANTY; without even the //
26  // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //
27  // PURPOSE. See the GNU General Public License for more details. //
28  // //
29  // You should have received a copy of the GNU General Public License //
30  // along with The iLab Neuromorphic Robotics Toolkit. If not, see //
31  // <http://www.gnu.org/licenses/>. //
32  // ////////////////////////////////////////////////////////////////////////
33  @endverbatim */
34 
35 #ifdef NRT_HAVE_CLOUD
36 #ifndef INCLUDE_NRT_POINTCLOUD2_REGISTRATION_REGISTRATION_H_
37 #define INCLUDE_NRT_POINTCLOUD2_REGISTRATION_REGISTRATION_H_
38 
44 
45 namespace nrt
46 {
47  //! A class for registering point clouds
48  /*! Point cloud registration involves aligning one point cloud to another
49  one such that they exist within a common reference frame.
50 
51  The Registration framework is extremely flexible and allows for
52  a variety of ways to perform this alignment, using the following pieces:
53  * Correspondence Method - responsible for choosing which points in a source
54  point cloud correspond to those in a target cloud
55  * Correspondence Rejection Criteria - responsible for pruning the correspondences
56  found between the two clouds. This can be as
57  simple as distance, or involve some sort of
58  sample concensus like RANSAC, or anything else.
59  * Rigid Transformation Estimation - this takes the pruned set of points and computes
60  a rigid transformation that attempts to align them
61  together.
62  * Convergence Criteria - this evaluates the performance of a rigid transform and
63  determines whether it is good enough to consider convergence
64  as being reached */
66  {
67  public:
68  typedef PointCloud2::Matrix4 Matrix4;
69  typedef PointCloud2::AffineTransform AffineTransform;
70 
71  //! Create a new Registration object
72  /*! @param[in] correspondenceMethod The method of computing correspondence between points in
73  two point clouds.
74  @param[in] correspondenceRejectionCriteria An initial criteria for rejecting correspondences found
75  via correspondenceMethod.
76  @param[in] rigidEstimationMethod The method of computing a rigid transformation between the two sets
77  of points selected by the correspondence method (after rejection)
78  @param[in] convergeCriteria The method of determining convergence for the transformation between
79  the two clouds */
80  Registration( CorrespondenceEstimationBase::SharedPtr const correspondenceMethod,
81  std::vector<CorrespondenceRejectionBase::SharedPtr> const & correspondenceRejectionCriteria,
82  TransformationEstimationBase::SharedPtr const rigidEstimationMethod,
83  ConvergenceCriteriaBase::SharedPtr const convergeCriteria );
84 
85  //! Aligns a source cloud to a target cloud
86  /*! The details of how this alignment is performed are specified by the parameters
87  given during construction of the Registration object.
88 
89  @param source The cloud that will be aligned
90  @param target The target cloud the source will be aligned to
91  @param guess An initial guess for the alignment
92  @return The transformation that aligns the source with the target */
93  AffineTransform align( PointCloud2 const source, PointCloud2 const target, AffineTransform const & guess = AffineTransform::Identity() );
94 
95  //! Returns true if the most recent alignment converged
96  bool converged() const;
97 
98  private:
99  CorrespondenceEstimationBase::SharedPtr itsCorrespondenceEstimation;
100 
101  std::vector<CorrespondenceRejectionBase::SharedPtr> itsCorrespondenceRejection;
102 
103  TransformationEstimationBase::SharedPtr itsTransformationEstimation;
104 
105  ConvergenceCriteriaBase::SharedPtr itsConvergenceCriteria;
106 
107  bool itsConverged;
108  };
109 } //namespace nrt
110 
111 #endif // INCLUDE_NRT_POINTCLOUD2_REGISTRATION_REGISTRATION_H_
112 #endif // NRT_HAVE_CLOUD