pointcloud_reader_node.cc
Go to the documentation of this file.
00001 #include <pcl/point_cloud.h>
00002 #include "pcl/point_types.h"
00003 #include "ros/ros.h"
00004 #include <tf/transform_broadcaster.h>
00005 #include "pcl/io/pcd_io.h"
00006 #include <pointcloud_vrml/pointcloud_utils.h>
00007 #include <sensor_msgs/PointCloud2.h>
00008 #include <pcl_conversions/pcl_conversions.h>
00009 
00010 int
00011 main (int argc, char** argv)
00012 {
00013     if(argc<2)
00014     {
00015         ROS_INFO("wrong number of arguments!");
00016         return(-1);
00017     }
00018 
00019     sensor_msgs::PointCloud2 cloudMSG;
00020     pcl::PointCloud<pcl::PointXYZ> cloud;
00021 
00022     //load vrml file into cloud
00023     cloud = lslgeneric::readVRML<pcl::PointXYZ>(argv[1]);
00024     pcl::toROSMsg(cloud,cloudMSG);
00025     ROS_INFO ("Loaded %d data points from %s with the following fields: %s", (int)(cloudMSG.width * cloudMSG.height),
00026               argv[1], pcl::getFieldsList (cloudMSG).c_str ());
00027 
00028     //create a broadcaster node
00029     ros::init(argc, argv, "pointcloud_vrml");
00030     ros::NodeHandle n;
00031     ros::Publisher vrmlPublisher =
00032         n.advertise<sensor_msgs::PointCloud2>("points2_in", 10);
00033     ros::Rate loop_rate(0.1);
00034     int count = 0;
00035 
00036     static tf::TransformBroadcaster br;
00037     tf::Transform transform;
00038     transform.setOrigin(tf::Vector3(0, 0, 0.0));
00039     transform.setRotation(tf::Quaternion(0, 0, 0, 1));
00040     cloudMSG.header.frame_id = "/pc_frame";
00041 
00042     while (ros::ok())
00043     {
00044         cloudMSG.header.stamp = ros::Time::now();
00045         vrmlPublisher.publish(cloudMSG);
00046         br.sendTransform(tf::StampedTransform(transform, ros::Time::now(), "/world", "/pc_frame"));
00047         ros::spinOnce();
00048         loop_rate.sleep();
00049         ++count;
00050     }
00051 
00052     return (0);
00053 }
00054 
00055 
00056 


pointcloud_vrml
Author(s): Todor Stoyanov
autogenerated on Wed Oct 8 2014 23:30:29