|
Point Cloud Library (PCL)
1.5.1
|
00001 /* 00002 * Software License Agreement (BSD License) 00003 * 00004 * Point Cloud Library (PCL) - www.pointclouds.org 00005 * Copyright (c) 2011, Willow Garage, Inc. 00006 * 00007 * All rights reserved. 00008 * 00009 * Redistribution and use in source and binary forms, with or without 00010 * modification, are permitted provided that the following conditions 00011 * are met: 00012 * 00013 * * Redistributions of source code must retain the above copyright 00014 * notice, this list of conditions and the following disclaimer. 00015 * * Redistributions in binary form must reproduce the above 00016 * copyright notice, this list of conditions and the following 00017 * disclaimer in the documentation and/or other materials provided 00018 * with the distribution. 00019 * * Neither the name of Willow Garage, Inc. nor the names of its 00020 * contributors may be used to endorse or promote products derived 00021 * from this software without specific prior written permission. 00022 * 00023 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00024 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00025 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00026 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00027 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00028 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00029 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00030 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00031 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00032 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00033 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00034 * POSSIBILITY OF SUCH DAMAGE. 00035 * 00036 * $Id: elch.h 4702 2012-02-23 09:39:33Z gedikli $ 00037 * 00038 */ 00039 00040 #ifndef PCL_ELCH_H_ 00041 #define PCL_ELCH_H_ 00042 00043 #include <boost/graph/adjacency_list.hpp> 00044 #include <boost/graph/graph_traits.hpp> 00045 #include <boost/shared_ptr.hpp> 00046 00047 #include <Eigen/Geometry> 00048 00049 #include <pcl/pcl_base.h> 00050 #include <pcl/point_types.h> 00051 #include <pcl/point_cloud.h> 00052 #include <pcl/registration/registration.h> 00053 #include <pcl/registration/icp.h> 00054 00055 namespace pcl 00056 { 00057 namespace registration 00058 { 00063 template <typename PointT> 00064 class ELCH : public PCLBase<PointT> 00065 { 00066 public: 00067 typedef boost::shared_ptr< ELCH<PointT> > Ptr; 00068 typedef boost::shared_ptr< const ELCH<PointT> > ConstPtr; 00069 00070 typedef pcl::PointCloud<PointT> PointCloud; 00071 typedef typename PointCloud::Ptr PointCloudPtr; 00072 typedef typename PointCloud::ConstPtr PointCloudConstPtr; 00073 00074 struct Vertex 00075 { 00076 PointCloudPtr cloud; 00077 }; 00078 00080 typedef boost::adjacency_list< 00081 boost::listS, boost::vecS, boost::undirectedS, 00082 Vertex, 00083 boost::no_property> 00084 LoopGraph; 00085 00086 typedef boost::shared_ptr< LoopGraph > LoopGraphPtr; 00087 00088 typedef typename pcl::Registration<PointT, PointT> Registration; 00089 typedef typename Registration::Ptr RegistrationPtr; 00090 typedef typename Registration::ConstPtr RegistrationConstPtr; 00091 00093 ELCH () : loop_graph_ (new LoopGraph), loop_start_ (0), loop_end_ (0), reg_ (new pcl::IterativeClosestPoint<PointT, PointT>), compute_loop_ (true) 00094 {}; 00095 00099 inline void 00100 addPointCloud (PointCloudPtr cloud) 00101 { 00102 typename boost::graph_traits<LoopGraph>::vertex_descriptor vd = add_vertex (*loop_graph_); 00103 (*loop_graph_)[vd].cloud = cloud; 00104 if (num_vertices (*loop_graph_) > 1) 00105 add_edge (vd_, vd, *loop_graph_); 00106 vd_ = vd; 00107 } 00108 00110 inline LoopGraphPtr 00111 getLoopGraph () 00112 { 00113 return (loop_graph_); 00114 } 00115 00119 inline void 00120 setLoopGraph (LoopGraphPtr loop_graph) 00121 { 00122 loop_graph_ = loop_graph; 00123 } 00124 00126 inline typename boost::graph_traits<LoopGraph>::vertex_descriptor 00127 getLoopStart () 00128 { 00129 return (loop_start_); 00130 } 00131 00135 inline void 00136 setLoopStart (const typename boost::graph_traits<LoopGraph>::vertex_descriptor &loop_start) 00137 { 00138 loop_start_ = loop_start; 00139 } 00140 00142 inline typename boost::graph_traits<LoopGraph>::vertex_descriptor 00143 getLoopEnd () 00144 { 00145 return (loop_end_); 00146 } 00147 00151 inline void 00152 setLoopEnd (const typename boost::graph_traits<LoopGraph>::vertex_descriptor &loop_end) 00153 { 00154 loop_end_ = loop_end; 00155 } 00156 00158 inline RegistrationPtr 00159 getReg () 00160 { 00161 return (reg_); 00162 } 00163 00167 inline void 00168 setReg (RegistrationPtr reg) 00169 { 00170 reg_ = reg; 00171 } 00172 00174 inline Eigen::Matrix4f 00175 getLoopTransform () 00176 { 00177 return (loop_transform_); 00178 } 00179 00183 inline void 00184 setLoopTransform (const Eigen::Matrix4f &loop_transform) 00185 { 00186 loop_transform_ = loop_transform; 00187 compute_loop_ = false; 00188 } 00189 00194 void 00195 compute (); 00196 00197 protected: 00198 using PCLBase<PointT>::deinitCompute; 00199 00201 virtual bool 00202 initCompute (); 00203 00204 private: 00206 typedef boost::adjacency_list< 00207 boost::listS, boost::vecS, boost::undirectedS, 00208 boost::no_property, 00209 boost::property< boost::edge_weight_t, double > > 00210 LOAGraph; 00211 00219 void 00220 loopOptimizerAlgorithm (LOAGraph &g, double *weights); 00221 00223 LoopGraphPtr loop_graph_; 00224 00226 typename boost::graph_traits<LoopGraph>::vertex_descriptor loop_start_; 00227 00229 typename boost::graph_traits<LoopGraph>::vertex_descriptor loop_end_; 00230 00232 RegistrationPtr reg_; 00233 00235 Eigen::Matrix4f loop_transform_; 00236 bool compute_loop_; 00237 00239 typename boost::graph_traits<LoopGraph>::vertex_descriptor vd_; 00240 00241 public: 00242 EIGEN_MAKE_ALIGNED_OPERATOR_NEW 00243 }; 00244 } 00245 } 00246 00247 #include "pcl/registration/impl/elch.hpp" 00248 00249 #endif // PCL_ELCH_H_
1.8.0