simple_segmentation_nodelet.h
Go to the documentation of this file.
00001 
00063 #ifndef __SIMPLE_SEGMENTATION_NODELET_H__
00064 #define __SIMPLE_SEGMENTATION_NODELET_H__
00065 
00066 #include <boost/thread.hpp>
00067 
00068 // PCL includes
00069 //#include <pcl/surface/concave_hull.h>
00070 #include <pcl/point_types.h>
00071 
00072 // ROS includes
00073 #include <nodelet/nodelet.h>
00074 #include <pcl_ros/transforms.h>
00075 #include <pcl_ros/point_cloud.h>
00076 #include <tf_conversions/tf_eigen.h>
00077 #include <dynamic_reconfigure/server.h>
00078 #include <cob_3d_segmentation/segmentation_nodeletConfig.h>
00079 #include <actionlib/server/simple_action_server.h>
00080 
00081 // Package includes
00082 #include "cob_3d_mapping_msgs/TriggerAction.h"
00083 #include "cob_3d_mapping_common/point_types.h"
00084 #include "cob_3d_features/organized_normal_estimation_omp.h"
00085 #include "cob_3d_segmentation/impl/fast_segmentation.hpp"
00086 #include <cob_3d_segmentation/cluster_conversion.h>
00087 
00088 namespace cob_3d_segmentation
00089 {
00090   class SimpleSegmentationNodelet : public nodelet::Nodelet
00091   {
00092     public:
00093     typedef pcl::PointCloud<pcl::PointXYZRGB> PointCloud;
00094     typedef pcl::PointCloud<pcl::Normal> NormalCloud;
00095     typedef pcl::PointCloud<PointLabel> LabelCloud;
00096     typedef FastSegmentation<pcl::PointXYZRGB, pcl::Normal, PointLabel>::ClusterPtr ClusterPtr;
00097 
00098     public:
00099     SimpleSegmentationNodelet()
00100       : one_()
00101       , seg_()
00102       , down_(new PointCloud)
00103       , segmented_(new PointCloud)
00104       , normals_(new NormalCloud)
00105       , labels_(new LabelCloud)
00106       , centroid_passthrough_(5.0f)
00107       , min_cluster_size_(100)
00108       , filter_(false)
00109       , downsample_(false)
00110       , colorize_(true)
00111       , enable_action_mode_(false)
00112       , is_running_(false)
00113     { }
00114 
00115     ~SimpleSegmentationNodelet()
00116     { if(as_) delete as_; }
00117 
00118     protected:
00119     void onInit();
00120     void configCallback(cob_3d_segmentation::segmentation_nodeletConfig& config, uint32_t levels);
00121 
00122     void actionCallback(const cob_3d_mapping_msgs::TriggerGoalConstPtr& goal);
00123     void topicCallback(const PointCloud::ConstPtr& cloud);
00124     void computeAndPublish();
00125     void publishClassifiedCloud();
00126     void computeTexture(ClusterPtr &c, Eigen::Affine3f &trf, unsigned int id);
00127 
00128     boost::mutex mutex_;
00129 
00130     ros::NodeHandle nh_;
00131     ros::Subscriber sub_points_;
00132     ros::Publisher pub_segmented_;
00133     ros::Publisher pub_classified_;
00134     ros::Publisher pub_shape_array_;
00135     actionlib::SimpleActionServer<cob_3d_mapping_msgs::TriggerAction>* as_;
00136 
00137     boost::shared_ptr<dynamic_reconfigure::Server<cob_3d_segmentation::segmentation_nodeletConfig> > config_server_;
00138 
00139     cob_3d_features::OrganizedNormalEstimationOMP<pcl::PointXYZRGB, pcl::Normal, PointLabel> one_;
00140     FastSegmentation<pcl::PointXYZRGB, pcl::Normal, PointLabel> seg_;
00141     ClusterConversion<pcl::PointXYZRGB> conv_;
00142 
00143     PointCloud::Ptr down_;
00144     PointCloud::Ptr segmented_;
00145     NormalCloud::Ptr normals_;
00146     LabelCloud::Ptr labels_;
00147 
00148     float centroid_passthrough_;
00149     int min_cluster_size_;
00150     bool filter_;
00151     bool downsample_;
00152     bool colorize_;
00153     bool enable_action_mode_;
00154     bool is_running_;
00155   };
00156 }
00157 
00158 
00159 #endif


cob_3d_segmentation
Author(s): Georg Arbeiter
autogenerated on Wed Aug 26 2015 11:03:03