3 #include <pcl/point_types.h>
4 #include <pcl_ros/point_cloud.h>
5 #include <ros/publisher.h>
7 #include <tf/transform_listener.h>
8 #include <sensor_msgs/point_cloud_conversion.h>
9 #include <pcl/filters/voxel_grid.h>
10 #include <pcl/io/pcd_io.h>
21 sensor_msgs::convertPointCloud2ToPointCloud(*msg, transformed);
22 transformed.header.stamp = ros::Time(0);
23 tf_listener->transformPointCloud(
"/map",transformed,transformed);
25 sensor_msgs::PointCloud2 transformed2;
26 sensor_msgs::convertPointCloudToPointCloud2(transformed, transformed2);
27 sensor_msgs::PointCloud2 output;
28 pcl::concatenatePointCloud(transformed2,
cloud, output);
43 ROS_ERROR_STREAM(
"caught error " << e);
48 int main(
int argc,
char** argv)
50 ros::init(argc, argv,
"map");
56 std::string delimiter =
" ";
58 std::list<ros::Subscriber> subs;
60 ros::NodeHandle pNh(
"~");
62 if(!pNh.hasParam(
"topics"))
63 ROS_ERROR_STREAM(
"no param");
65 pNh.getParam(
"topics", topics);
68 while((pos = topics.find(delimiter)) != std::string::npos)
70 std::string token = topics.substr(0, pos);
71 ROS_ERROR_STREAM(token);
72 topics.erase(0,pos+delimiter.length());
76 ROS_ERROR_STREAM(topics);
79 cloud.header.frame_id =
"/map";
81 _pointcloud_pub = nh.advertise<sensor_msgs::PointCloud2>(
"/pointcloud/map", 1);
83 tf_listener->waitForTransform(
"/map",
"/lidar", ros::Time(0), ros::Duration(5));
void nodeCallback(const sensor_msgs::PointCloud2::ConstPtr &msg)
sensor_msgs::PointCloud2 cloud
ros::Publisher _pointcloud_pub
pcl::PointCloud< pcl::PointXYZ > PointCloud
int main(int argc, char **argv)
tf::TransformListener * tf_listener