pcl_hull_to_polygon.cpp
Go to the documentation of this file.
00001 #include <ros/ros.h>
00002 #include <boost/bind.hpp>
00003 #include <boost/foreach.hpp>
00004 #include <pcl/point_cloud.h>
00005 #include <pcl/point_types.h>
00006 #include <ros/subscriber.h>
00007 #include <geometry_msgs/PolygonStamped.h>
00008 #include <sensor_msgs/PointCloud2.h>
00009 #include <pcl/ros/conversions.h>
00010 
00011 typedef pcl::PointXYZ Point;
00012 typedef pcl::PointCloud<Point> PointCloud;
00013 
00014 ros::Subscriber PointCloudSubscriber;
00015 ros::Publisher polygon_pub;
00016 
00017 void pointCloudToPolygonCb(const sensor_msgs::PointCloud2ConstPtr &input)
00018 {
00019   PointCloud cloud;
00020   pcl::fromROSMsg (*input, cloud);
00021   geometry_msgs::PolygonStamped polygon;
00022 
00023   polygon.header = cloud.header;
00024   BOOST_FOREACH(const pcl::PointXYZ &pt, cloud.points)
00025   {
00026     geometry_msgs::Point32 out_pt;
00027     out_pt.x = pt.x;
00028     out_pt.y = pt.y;
00029     out_pt.z = pt.z;
00030     polygon.polygon.points.push_back(out_pt);
00031   }
00032 
00033   polygon_pub.publish(polygon);
00034 }
00035 
00036 int main(int argc, char *argv[])
00037 {
00038   ros::init(argc, argv, "pcl_hull_to_polygon");
00039   ros::NodeHandle nh("~");
00040   polygon_pub = nh.advertise<geometry_msgs::PolygonStamped>("output", 10);
00041   PointCloudSubscriber = nh.subscribe("input", 10, pointCloudToPolygonCb);
00042 
00043   ros::spin();
00044 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Friends Defines


pcl_cloud_tools
Author(s): Nico Blodow, Zoltan-Csaba Marton, Dejan Pangercic
autogenerated on Thu May 23 2013 17:11:36