transform_pointcloud.cpp
Go to the documentation of this file.
00001 #include <iostream>
00002 #include <pcl/point_types.h>
00003 
00004 #include <ros/ros.h>
00005 #include <pcl_ros/point_cloud.h>
00006 #include <pcl_ros/transforms.h>
00007 #include <sensor_msgs/PointCloud2.h>
00008 #include <tf/transform_listener.h>
00009 
00010 
00011 ros::Publisher cloud_pub;
00012 std::string g_target_frame;
00013 tf::TransformListener* listener;
00014 
00015 void cloudCallback(const sensor_msgs::PointCloud2ConstPtr& cloud) {
00016         sensor_msgs::PointCloud2 out;
00017         pcl_ros::transformPointCloud(g_target_frame, *cloud, out, *listener);
00018         cloud_pub.publish(out);
00019 }
00020 
00021 int main (int argc, char** argv) {
00022         ros::init(argc, argv, "transform_pointcloud");
00023         ros::NodeHandle nh;
00024         ros::NodeHandle nhl("~");
00025         nhl.param("target_frame", g_target_frame, std::string("/map"));
00026         //ros::service::waitForService("assemble_scans");
00027         //client = nh.serviceClient<AssembleScans>("assemble_scans");
00028         cloud_pub = nh.advertise<sensor_msgs::PointCloud2>("cloud_transformed", 1);
00029         ros::Subscriber cloud_sub = nh.subscribe<sensor_msgs::PointCloud2>("cloud", 1, cloudCallback);
00030         listener = new tf::TransformListener();
00031         
00032         ros::spin();
00033         return 0;
00034 }


external_camera_localizer
Author(s): Daniel Lazewatsky
autogenerated on Mon Oct 6 2014 10:07:41