transform_pointcloud.cpp
Go to the documentation of this file.
00001 
00062 // ROS core
00063 #include <ros/ros.h>
00064 #include <tf/transform_listener.h>
00065 // PCL includes
00066 #include <pcl/io/io.h>
00067 #include <pcl/io/pcd_io.h>
00068 #include <pcl/point_types.h>
00069 #include <pcl_ros/transforms.h>
00070 
00071 
00072 using namespace std;
00073 
00074 class TransformPointCloud
00075 {
00076   protected:
00077     ros::NodeHandle nh_;
00078 
00079   public:
00080     string cloud_topic_sub_;
00081     string cloud_topic_pub_;
00082     string target_frame_;
00083 
00084     tf::TransformListener tf_listener_;
00085     ros::Subscriber sub_;
00086     ros::Publisher pub_;
00087 
00088     TransformPointCloud() :
00089       nh_("~")
00090     {
00091       cloud_topic_sub_="input";
00092       cloud_topic_pub_="output";
00093       target_frame_ = "/map";
00094 
00095       pub_ = nh_.advertise<sensor_msgs::PointCloud2>(cloud_topic_pub_,1);
00096       sub_ = nh_.subscribe (cloud_topic_sub_, 1,  &TransformPointCloud::cloud_cb, this);
00097     }
00098 
00100     // Callback
00101     void
00102       cloud_cb (const sensor_msgs::PointCloud2ConstPtr& cloud)
00103     {
00104       sensor_msgs::PointCloud2 cloud_out;
00105       pcl_ros::transformPointCloud (target_frame_, *cloud, cloud_out, tf_listener_);
00106       cloud_out.header.stamp = cloud->header.stamp;
00107       pub_.publish(cloud_out);
00108     }
00109 
00110 };
00111 
00112 /* ---[ */
00113 int
00114   main (int argc, char** argv)
00115 {
00116   ros::init (argc, argv, "transform_pointcloud", ros::init_options::AnonymousName);
00117 
00118   TransformPointCloud b;
00119   ros::spin ();
00120 
00121   return (0);
00122 }
00123 /* ]--- */


cob_3d_transform_nodes
Author(s): Georg Arbeiter
autogenerated on Wed Aug 26 2015 11:05:06