transform_point_cloud.cpp
Go to the documentation of this file.
00001 
00002 #include <string>
00003 
00004 #include <ros/ros.h>
00005 
00006 #include <boost/thread/mutex.hpp>
00007 
00008 #include <sensor_msgs/PointCloud.h>
00009 #include <sensor_msgs/PointCloud2.h>
00010 #include <sensor_msgs/point_cloud_conversion.h>
00011 #include <visualization_msgs/Marker.h>
00012 
00013 #include <tf/transform_listener.h>
00014 #include <tf/transform_broadcaster.h>
00015 
00016 #include <pcl/point_cloud.h>
00017 #include <pcl/point_types.h>
00018 #include <pcl/io/io.h>
00019 #include <pcl/filters/voxel_grid.h>
00020 #include <pcl/filters/passthrough.h>
00021 #include <pcl/filters/extract_indices.h>
00022 #include <pcl/features/normal_3d.h>
00023 #include <pcl/kdtree/kdtree_ann.h>
00024 #include <pcl/sample_consensus/method_types.h>
00025 #include <pcl/sample_consensus/model_types.h>
00026 #include <pcl/segmentation/sac_segmentation.h>
00027 #include <pcl/filters/project_inliers.h>
00028 #include <pcl/surface/convex_hull.h>
00029 #include <pcl/segmentation/extract_polygonal_prism_data.h>
00030 #include <pcl/segmentation/extract_clusters.h>
00031 
00032   // std::string topic = nh_.resolveName("cloud_new_in");
00033   // ROS_INFO("Tabletop detection service called; waiting for a point_cloud2 on topic %s", topic.c_str());
00034 
00035   sensor_msgs::PointCloud2::ConstPtr recent_cloud = 
00036     ros::topic::waitForMessage<sensor_msgs::PointCloud2>('pr2_segment_object', nh_, ros::Duration(6.0));
00037               
00038   if (!recent_cloud)
00039   {
00040     ROS_ERROR("Cloud Transformer: no point_cloud2 has been received");
00041   }
00042 
00043   ROS_INFO("Point cloud received; processing");
00044   if (!processing_frame_.empty())
00045   {
00046     //convert cloud to base link frame
00047     sensor_msgs::PointCloud old_cloud;  
00048     sensor_msgs::convertPointCloud2ToPointCloud (*recent_cloud, old_cloud);
00049     try
00050     {
00051       listener_.transformPointCloud('torso_lift_link', old_cloud, old_cloud);    
00052     }
00053     catch (tf::TransformException ex)
00054     {
00055       ROS_ERROR("Failed to transform cloud from frame %s into frame %s", old_cloud.header.frame_id.c_str(), 
00056                 'torso_lift_link');
00057     }
00058 
00059     sensor_msgs::PointCloud2 converted_cloud;
00060     sensor_msgs::convertPointCloudToPointCloud2 (old_cloud, converted_cloud);
00061     ROS_INFO("Input cloud converted to %s frame", processing_frame_.c_str());
00062     //republish cloud here now for python processing stuff
00063     processCloud(converted_cloud, request.return_clusters, request.return_models, response.detection);
00064   }
00065 
00066   return 1;
00067 }


pr2_playpen
Author(s): Marc Killpack / mkillpack3@gatech.edu, Advisor: Prof. Charlie Kemp, Lab: Healthcare Robotics Lab at Georgia Tech
autogenerated on Wed Nov 27 2013 12:18:32