作者:雲痕影落_969 | 来源:互联网 | 2023-09-07 19:11
一:读取pld文件
#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_output", 1);
pcl::PointCloud cloud;
sensor_msgs::PointCloud2 output;
pcl::io::loadPCDFile ("/home/jzm/lidar_date/00.pcd", cloud); //修改pcd文件所在路径
//Convert the cloud to ROS message
pcl::toROSMsg(cloud, output);
output.header.frame_id = "odom";
ros::Rate loop_rate(1);
while (ros::ok())
{
pcl_pub.publish(output);
ros::spinOnce();
loop_rate.sleep();
}
return 0;
}
二:从.bag中提取点云pcd文件
rosrun pcl_ros bag_to_pcd test1_my.bag /lslidar_point_cloud /home/jzm/桌面/未命名文件夹