ROS学习笔记

您所在的位置:网站首页 rviz怎么导入地图 ROS学习笔记

ROS学习笔记

2023-08-12 18:17| 来源: 网络整理| 查看: 265

pcl实现了这部分功能,直接terminal输入:

rosrun pcl_ros pcd_to_pointcloud pcd_name  1(rate)

在上篇的简述中提到了ROS中的点云数据类型,本篇利用在pcl官网下载的一个pcd文件,创建节点发布,转换数据类型并在rviz中显示。源码如下:

#include #include #include #include #include//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 ("pcl_output1", 1); pcl::PointCloud 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 to be able to visualize our PointCloud2 message on the RViz visualizer ros::Rate loop_rate(1); while (ros::ok()) { pcl_pub.publish(output); ros::spinOnce(); loop_rate.sleep(); } return 0; }

加载一个pcd文件后,通过pcl::toROSMsg(cloud, output)将pcd转换到 sensor_msgs::PointCloud2。在rviz中添加PointCloud2插件,修改fixed frame并订阅对应的主题,便可在rviz中显示一帧点云数据:

 



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3