$search
00001 /**************************************************************** 00002 * 00003 * Copyright (c) 2011 00004 * 00005 * Fraunhofer Institute for Manufacturing Engineering 00006 * and Automation (IPA) 00007 * 00008 * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00009 * 00010 * Project name: care-o-bot 00011 * ROS stack name: cob_environment_perception_intern 00012 * ROS package name: cob_3d_mapping_semantics 00013 * Description: 00014 * 00015 * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00016 * 00017 * Author: Waqas Tanveer email:Waqas.Tanveer@ipa.fraunhofer.de 00018 * Supervised by: Georg Arbeiter, email:georg.arbeiter@ipa.fhg.de 00019 * 00020 * Date of creation: 11/2011 00021 * ToDo: 00022 * comments in doxygen style 00023 * 00024 * 00025 * 00026 * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00027 * 00028 * Redistribution and use in source and binary forms, with or without 00029 * modification, are permitted provided that the following conditions are met: 00030 * 00031 * * Redistributions of source code must retain the above copyright 00032 * notice, this list of conditions and the following disclaimer. 00033 * * Redistributions in binary form must reproduce the above copyright 00034 * notice, this list of conditions and the following disclaimer in the 00035 * documentation and/or other materials provided with the distribution. 00036 * * Neither the name of the Fraunhofer Institute for Manufacturing 00037 * Engineering and Automation (IPA) nor the names of its 00038 * contributors may be used to endorse or promote products derived from 00039 * this software without specific prior written permission. 00040 * 00041 * This program is free software: you can redistribute it and/or modify 00042 * it under the terms of the GNU Lesser General Public License LGPL as 00043 * published by the Free Software Foundation, either version 3 of the 00044 * License, or (at your option) any later version. 00045 * 00046 * This program is distributed in the hope that it will be useful, 00047 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00048 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00049 * GNU Lesser General Public License LGPL for more details. 00050 * 00051 * You should have received a copy of the GNU Lesser General Public 00052 * License LGPL along with this program. 00053 * If not, see <http://www.gnu.org/licenses/>. 00054 * 00055 ****************************************************************/ 00056 00057 #ifndef TABLE_EXTRACTION_H_ 00058 #define TABLE_EXTRACTION_H_ 00059 00060 //################## 00061 //#### includes #### 00062 00063 //standard includes 00064 #include <iostream> 00065 #include <fstream> 00066 #include <sstream> 00067 #include <string> 00068 #include <vector> 00069 #include <math.h> 00070 00071 //PCL includes 00072 #include "pcl/point_types.h" 00073 #include "pcl/common/centroid.h" 00074 #include "pcl/common/eigen.h" 00075 00076 //other includes 00077 #include <Eigen/Core> 00078 #include <boost/shared_ptr.hpp> 00079 #include <boost/thread/mutex.hpp> 00080 00081 #include <cob_3d_mapping_common/polygon.h> 00082 00083 using namespace cob_3d_mapping; 00084 00085 class TableExtraction 00086 { 00087 00088 public: 00089 00093 TableExtraction () 00094 :norm_x_min_(-0.1), 00095 norm_x_max_(0.1), 00096 norm_y_min_(-0.1), 00097 norm_y_max_(0.1), 00098 norm_z_min_ (-0.99), 00099 norm_z_max_ (0.99), 00100 height_min_ (0.4), 00101 height_max_ (1), 00102 area_min_ (1), 00103 area_max_ (3) 00104 { 00106 } 00107 00111 ~TableExtraction () 00112 { 00113 00115 } 00116 00117 void 00118 setNormalBounds (double tilt_angle) 00119 { 00120 static const double PI = 3.1415926; 00121 double ang_rad = tilt_angle * (PI / 180.0); 00122 double norm = cos ((PI/2)-ang_rad); 00123 setNormXMin (-norm); 00124 setNormXMax (norm); 00125 setNormYMin (-norm); 00126 setNormYMax (norm); 00127 setNormZMin (-cos (ang_rad)); 00128 setNormZMax (cos (ang_rad)); 00129 /*std::cout << "\n\t*tilt_angle = " << tilt_angle << std::endl; 00130 std::cout << "\n\t*norm_x_min = " << norm_x_min_ << std::endl; 00131 std::cout << "\n\t*norm_x_max = " << norm_x_max_ << std::endl; 00132 std::cout << "\n\t*norm_y_min = " << norm_y_min_ << std::endl; 00133 std::cout << "\n\t*norm_y_max = " << norm_y_max_ << std::endl; 00134 std::cout << "\n\t*norm_z_min = " << norm_z_min_ << std::endl; 00135 std::cout << "\n\t*norm_z_max = " << norm_z_max_ << std::endl;*/ 00136 } 00137 00144 void 00145 setNormXMin (double norm_x_min) 00146 { 00147 norm_x_min_ = norm_x_min; 00148 } 00149 00156 void 00157 setNormXMax (double norm_x_max) 00158 { 00159 norm_x_max_ = norm_x_max; 00160 } 00161 00168 void 00169 setNormYMin (double norm_y_min) 00170 { 00171 norm_y_min_ = norm_y_min; 00172 } 00173 00180 void 00181 setNormYMax (double norm_y_max) 00182 { 00183 00184 norm_y_max_ = norm_y_max; 00185 } 00186 00193 void 00194 setNormZMin (double norm_z_min) 00195 { 00196 norm_z_min_ = norm_z_min; 00197 } 00198 00205 void 00206 setNormZMax (double norm_z_max) 00207 { 00208 norm_z_max_ = norm_z_max; 00209 } 00216 void 00217 setHeightMin (double height_min) 00218 { 00219 height_min_ = height_min; 00220 } 00221 00228 void 00229 setHeightMax (double height_max) 00230 { 00231 height_max_ = height_max; 00232 } 00239 void 00240 setAreaMin (double area_min) 00241 { 00242 area_min_ = area_min; 00243 } 00244 00251 void 00252 setAreaMax (double area_max) 00253 { 00254 area_max_ = area_max; 00255 } 00256 00263 void setInputPolygon(Polygon::Ptr poly_ptr) 00264 { 00265 poly_ptr_ = poly_ptr; 00266 } 00267 00273 bool 00274 isTable(); 00275 00282 bool 00283 isHorizontal (); 00284 00291 bool 00292 isHeightOk (); 00293 00299 bool 00300 isSizeOk (); 00301 00302 protected: 00303 00304 double norm_x_min_, norm_x_max_; 00305 double norm_y_min_, norm_y_max_; 00306 double norm_z_min_, norm_z_max_; 00307 00308 double height_min_, height_max_; 00309 00310 double area_min_, area_max_; 00311 00312 Polygon::Ptr poly_ptr_; 00313 00314 }; 00315 00316 #endif /* TABLE_EXTRACTION_H_ */