当前位置:网站首页>ROS knowledge: reading point cloud data files
ROS knowledge: reading point cloud data files
2022-06-23 11:59:00 【Mr anhydrous】
One 、 Point cloud file
Point cloud files are actually very simple , It is simply a file composed of the coordinates of a large group of points . This document describes PCD( Point cloud data ) File format , And it's in the point cloud Library (PCL) How to use the . Open one pcd file , See the following :

For more details, see :(3 Bar message ) ROS knowledge : Point cloud file .pcd Format
here , We from github Get a point cloud file on model.pcd, The following will demonstrate how to start from ROS Read .
Two 、 Create a workspace :
mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/src
catkin_init_workspace
cd ~/catkin_ws
catkin_make
catkin_create_pkg load_pcd pcl_conversions pcl_ros roscpp sensor_msgs3、 ... and 、 Generate node program
stay catkin_ws/src Generate a new folder load_pcd, In it src Create a new one in the directory load_pcd.cpp file , And copy the following code :
#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_output", 1);
pcl::PointCloud<pcl::PointXYZ> cloud;
sensor_msgs::PointCloud2 output;
pcl::io::loadPCDFile ("/home/huatec/catkin_ws/src/load_pcd/src/model.pcd", cloud);
// Modify yourself pcd File path
//Convert the cloud to ROS message
pcl::toROSMsg(cloud, output);
output.header.frame_id = "odom";
//this has been done in order to be able to visualize our PointCloud2 message on the RViz visualizer
//!!! This step needs attention , It's the back rviz Of fixed_frame a key !!
ros::Rate loop_rate(1);
while (ros::ok())
{
pcl_pub.publish(output);
ros::spinOnce();
loop_rate.sleep();
}
return 0;
}Enter here load_pcd/src, take model.pcd It's also in this directory .
3、 ... and 、 modify CMakelist file
add_executable(load_pcd src/load_pcd.cpp)
add_targate_libarary (read_pcd ${catkin_LIBRARIES})Four 、package.xml Add :
<build_depend>libpcl-all-dev</build_depend>
<exec_depend>libpcl-all</exec_depend>
5、 ... and 、 Compile function packs
5.1 Terminal access catkin_ws Catalog :
catkin_makeAfter the compilation is successful OK 了 .
5.2 stay RVIZ Inside display
1) At respective terminals :
roscore2) Open the terminal again
rosrun load_pcd load_pcdSure rostopic list to glance at /output Has this news been released yet
3) Open the terminal again
rosrun rviz rviz
open rviz after add One pointcloud2, Topic choice pcl_output You can see the image .
It may be opening rviz after status newspaper tf Related error , Then open a terminal and execute the following commands :
rosrun tf static_transform_publisher 0.0 0.0 0.0 0.0 0.0 0.0 map odom 100
6、 ... and 、 Results show
Get into rviz after ,add Button , Join in pointcloud2, So it shows model.pcd Image :

边栏推荐
- Go 语言使用 MySQL 的常见故障分析和应对方法
- Mobile securities account opening transaction? Is it safe to open an account online now?
- 简单易懂的软路由刷机使用教程
- One picture decoding opencloudos community open day
- 请问,maxcompute执行sql查询有时特别慢是什么原因
- Introduction to redis - Chapter 1 - data structures and objects - simple dynamic string (SDS)
- How does easygbs solve the abnormal use of intercom function?
- 16路HD-SDI光端机多路HD-SDI高清视频光端机16路3G-SDI高清音视频光端机
- ESP32-C3入门教程 问题篇⑦—— fatal error: esp_bt.h: No such file or directory 找不到esp_bt.h
- 2022施工员-装饰方向-岗位技能(施工员)操作证考试题库模拟考试平台操作
猜你喜欢

Open classes are short videos! Tonight, I will teach you how to realize accurately!

Analysis of six dimensional chart: analysis of enterprise growth of CSCEC

Meta称英安全法可能“扫描所有私人信息” 或侵犯隐私

The country has entered the main flood season. The Ministry of transport: the lines that do not meet the conditions for safe operation will be resolutely shut down!

【云原生&微服务八】Ribbon负载均衡策略之WeightedResponseTimeRule源码剖析(响应时间加权)

go-zero微服务实战系列(六、缓存一致性保证)

@黑马粉丝,这份「高温补贴」你还没领?

Redis 入门-第一篇-数据结构与对象-简单动态字符串(SDS)

凭借32量子比特!Rigetti Computing打入英国量子计算市场

汉源高科1路千兆光口转4路千兆以太网电口千兆1光4电光纤收发器
随机推荐
年薪中位数超30万,南大AI专业首届毕业生薪资曝光
RF Analyzer Demo搭建
切比雪夫不等式证明及应用
Common fault analysis and Countermeasures of MySQL in go language
Learning notes sweep crawler framework
4E1 PDH光端机19英寸机架式单纤传输20km E1接口光纤网络光端机
蓝桥杯单片机(一)——关闭外设及熄灭LED
你真的理解LDO的輸出電容嗎!?
PPT制作3D旋转动画从入门到进阶
ROS知识:librviz库的调用实践
有没有碰到过flink1.15.0 和 flink-cdc-mysql 2.2.1不兼容的情况?f
wc 统计已过时,cloc 每一行代码都有效
汉源高科8路电话+1路百兆以太网RJ11电话光端机 8路PCM电话光端机
浅谈标注平台架构
HMS Core 视频编辑服务开放模板能力,助力用户一键Get同款酷炫视频
How many days is the general term of financial products?
简单易懂的软路由刷机使用教程
公开课丨玩的就是短视频!今晚教你精准变现!
Meta said that the UK security law may "scan all private information" or infringe privacy
爱可可AI前沿推介(6.23)