$search
00001 /********************************************************************* 00002 * 00003 * Software License Agreement (BSD License) 00004 * 00005 * Copyright (c) 2011, Robert Bosch LLC. 00006 * All rights reserved. 00007 * 00008 * Redistribution and use in source and binary forms, with or without 00009 * modification, are permitted provided that the following conditions 00010 * are met: 00011 * 00012 * * Redistributions of source code must retain the above copyright 00013 * notice, this list of conditions and the following disclaimer. 00014 * * Redistributions in binary form must reproduce the above 00015 * copyright notice, this list of conditions and the following 00016 * disclaimer in the documentation and/or other materials provided 00017 * with the distribution. 00018 * * Neither the name of the Robert Bosch nor the names of its 00019 * contributors may be used to endorse or promote products derived 00020 * from this software without specific prior written permission. 00021 * 00022 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00023 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00024 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00025 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00026 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00027 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00028 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00029 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00030 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00031 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00032 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00033 * POSSIBILITY OF SUCH DAMAGE. 00034 * 00035 *********************************************************************/ 00036 00037 #ifndef TABLE_DETECTOR_H 00038 #define TABLE_DETECTOR_H 00039 00040 #include <sensor_msgs/Image.h> 00041 #include <sensor_msgs/CameraInfo.h> 00042 #include <sensor_msgs/PointCloud.h> 00043 #include <sensor_msgs/PointCloud2.h> 00044 #include <visualization_msgs/Marker.h> 00045 #include <tabletop_object_detector/Table.h> 00046 #include <tf/tf.h> 00047 #include <pcl/point_types.h> 00048 #include <pcl/kdtree/kdtree_flann.h> 00049 #include <pcl/ModelCoefficients.h> 00050 00051 namespace bosch_object_segmentation_gui { 00052 00053 class TableDetector 00054 { 00055 public: 00056 typedef pcl::PointXYZ Point; 00057 typedef pcl::KdTree<Point>::Ptr KdTreePtr; 00058 00059 TableDetector(); 00060 ~TableDetector(); 00061 00062 // main detection routine 00063 bool detectTable(const sensor_msgs::PointCloud2 &cloud, tabletop_object_detector::Table& table); 00064 // create table markers 00065 visualization_msgs::Marker getTableMarker(const tabletop_object_detector::Table& table); 00067 int inlier_threshold_; 00069 double plane_detection_voxel_size_; 00071 double clustering_voxel_size_; 00073 double z_filter_min_, z_filter_max_; 00075 double table_z_filter_min_, table_z_filter_max_; 00077 double cluster_distance_; 00079 int min_cluster_size_; 00082 std::string processing_frame_; 00084 double up_direction_; 00085 private: 00086 // create table structure 00087 tabletop_object_detector::Table getTable(const std_msgs::Header& header, const tf::Transform &table_plane_trans, const sensor_msgs::PointCloud &table_points); 00089 tf::Transform getPlaneTransform (pcl::ModelCoefficients coeffs, double up_direction); 00090 bool getPlanePoints (const pcl::PointCloud<Point> &table, 00091 const tf::Transform& table_plane_trans, 00092 sensor_msgs::PointCloud &table_points); 00094 int current_marker_id_; 00095 00096 }; 00097 00098 } 00099 00100 #endif // TABLE_DETECTOR_H