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_filters 00013 * Description: 00014 * 00015 * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 00016 * 00017 * Author: Joshua Hampp, email:joshua.hampp@ipa.fhg.de 00018 * Supervised by: Joshua Hampp, email:joshua.hampp@ipa.fhg.de 00019 * 00020 * Date of creation: 05/2013 00021 * 00022 * Redistribution and use in source and binary forms, with or without 00023 * modification, are permitted provided that the following conditions are met: 00024 * 00025 * * Redistributions of source code must retain the above copyright 00026 * notice, this list of conditions and the following disclaimer. 00027 * * Redistributions in binary form must reproduce the above copyright 00028 * notice, this list of conditions and the following disclaimer in the 00029 * documentation and/or other materials provided with the distribution. 00030 * * Neither the name of the Fraunhofer Institute for Manufacturing 00031 * Engineering and Automation (IPA) nor the names of its 00032 * contributors may be used to endorse or promote products derived from 00033 * this software without specific prior written permission. 00034 * 00035 * This program is free software: you can redistribute it and/or modify 00036 * it under the terms of the GNU Lesser General Public License LGPL as 00037 * published by the Free Software Foundation, either version 3 of the 00038 * License, or (at your option) any later version. 00039 * 00040 * This program is distributed in the hope that it will be useful, 00041 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00042 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00043 * GNU Lesser General Public License LGPL for more details. 00044 * 00045 * You should have received a copy of the GNU Lesser General Public 00046 * License LGPL along with this program. 00047 * If not, see <http://www.gnu.org/licenses/>. 00048 * 00049 ****************************************************************/ 00050 00051 //################## 00052 //#### includes #### 00053 // standard includes 00054 //-- 00055 // ROS includes 00056 #include <ros/ros.h> 00057 #include <pluginlib/class_list_macros.h> 00058 #include <nodelet/nodelet.h> 00059 #include <pcl_ros/point_cloud.h> 00060 00061 // pcl includes 00062 #include <pcl/point_types.h> 00063 00064 // cob_3d_mapping_filters includes 00065 //#include <cob_3d_mapping_common/point_types.h> 00066 #include <cob_3d_mapping_filters/smoothing_filter.h> 00067 #include <cob_3d_mapping_filters/impl/smoothing_filter.hpp> 00068 00069 //###################### 00070 //#### nodelet class#### 00071 class SmoothingFilter : public nodelet::Nodelet 00072 { 00073 public: 00074 typedef pcl::PointXYZI PointT; 00075 typedef pcl::PointCloud<PointT> PointCloud; 00076 00077 // Constructor 00078 SmoothingFilter () 00079 { 00080 // 00081 } 00082 00083 // Destructor 00084 ~ SmoothingFilter () 00085 { 00087 } 00088 00089 void 00090 onInit () 00091 { 00092 n_ = getPrivateNodeHandle (); 00093 00094 point_cloud_sub_ = n_.subscribe ("point_cloud_in", 1, &SmoothingFilter::pointCloudSubCallback, this); 00095 point_cloud_pub_ = n_.advertise<PointCloud> ("point_cloud_out", 1); 00096 00097 double edge_threshold; 00098 double smoothing_factor; 00099 double integral_factor; 00100 n_.param ("edge_threshold", edge_threshold, 0.05); 00101 n_.param ("smoothing_factor", smoothing_factor, 0.25); 00102 n_.param ("integral_factor", integral_factor, 0.25); 00103 filter_.setFilterLimits (edge_threshold, smoothing_factor, integral_factor); 00104 } 00105 00106 void 00107 pointCloudSubCallback (PointCloud::ConstPtr pc) 00108 { 00109 PointCloud cloud_filtered; 00110 filter_.setInputCloud (pc); 00111 filter_.filter (cloud_filtered); 00112 00113 point_cloud_pub_.publish (cloud_filtered); 00114 } 00115 00116 protected: 00117 ros::NodeHandle n_; 00118 ros::Subscriber point_cloud_sub_; 00119 ros::Publisher point_cloud_pub_; 00120 00121 cob_3d_mapping_filters::SmoothingFilter<PointT> filter_; 00122 }; 00123 00124 PLUGINLIB_DECLARE_CLASS(cob_3d_mapping_filters, SmoothingFilter, SmoothingFilter, nodelet::Nodelet) 00125