pcl实现了这部分功能,直接terminal输入:
rosrun pcl_ros pcd_to_pointcloud pcd_name 1(rate)
在上篇的简述中提到了ROS中的点云数据类型,本篇利用在pcl官网下载的一个pcd文件,创建节点发布,转换数据类型并在rviz中显示。源码如下:
#include<ros/ros.h>
#include<pcl/point_cloud.h>
#include<pcl_conversions/pcl_conversions.h>
#include<sensor_msgs/PointCloud2.h>
#include<pcl/io/pcd_io.h>//which contains the required definitions to load and store point clouds to PCD and other file formats.
main (int argc, char **argv)
{
ros::init (argc, argv, "UandBdetect");
ros::NodeHandle nh;
ros::Publisher pcl_pub = nh.advertise<sensor_msgs::PointCloud2> ("pcl_output1", 1);
pcl::PointCloud<pcl::PointXYZ> cloud;
sensor_msgs::PointCloud2 output;
pcl::io::loadPCDFile ("/home/uv/table_scene_lms400.pcd", cloud);
//Convert the cloud to ROS message
pcl::toROSMsg(cloud, output);
output.header.frame_id = "odom1";//this has been done in order t

本文介绍了如何在ROS环境中使用pcl_ros节点将PCD点云数据转换并发布,然后在rviz中进行显示。通过运行rosrun命令加载pcd文件并转换为sensor_msgs::PointCloud2消息类型,再在rviz中配置相应的订阅,成功实现点云数据的可视化。


被折叠的 条评论
为什么被折叠?



