- 76
- 0
- 约1.46万字
- 约 8页
- 2021-11-08 发布于重庆
- 举报
在 ROS系统中使用 PCL教程
在 ROS 中点云的数据类型
在 ROS 中表示点云的数据结构有:
sensor_msgs::PointCloud
sensor_msgs::PointCloud2
pcl::PointCloudT
关于 PCL 在 ros 的数据的结构,具体的介绍可查 看 wiki.ros.org/pcl/Overview
关于 sensor_msgs::PointCloud2 和 pcl::PointCloudT 之间的转换
使用 pcl::fromROSMsg 和 pcl::toROSMsg
sensor_msgs::PointCloud 和 sensor_msgs::PointCloud2 之间的转
换
使用 sensor_msgs::convertPointCloud2ToPointCloud 和
sensor_msgs::convertPointCloudToPointCloud2.
那么如何在 ROS 中使用 PCL 呢?
(1 )在建立的包下的 CMakeLists.txt 文件下添加依赖项
在 package.xml 文件里添加:
build_dependlibpcl-all-dev/build_depend run_dependlibpcl-
all/run_depend
在 src 文件夹下新建 .cpp 文件
#includeros/ros.h
// PCL specific includes
#include sensor_msgs/PointCloud2.h
#include pcl_conversions/pcl_conversions.h
#include pcl/point_cloud.h
#include pcl/point_types.h
ros::Publisher pub; void cloud_cb ( const sensor_msgs::PointCloud2ConstPtr input)
{ // Create a container for the data.
sensor_msgs::PointCloud2 output;
// Do data processing here...
output = *input;
// Publish the data.
pub.publish (output);
}
int main ( int argc, char ** argv)
{ // Initialize ROS
ros::init (argc, argv, my_pcl_tutorial );
ros::NodeHandle nh;
ros::Subscriber sub = nh.subscribe ( input , 1, cloud_cb);
pub = nh.advertisesensor_msgs::PointCloud2 ( output , 1);
// Spin
ros::spin ();
}
在 CMakeLists.txt 文件中添加 :
add_executable(example src/example.cpp)
target_link_libraries(example ${catkin_LIBRARIES})
catkin_make 之后生成可执行文件,运行以下命令
roslaunch openni_launch openni.launch 这是打开 kinect 发布的命令
rosrun ros_slam example input:=/camera/depth/points 运
您可能关注的文档
最近下载
- 2025年高中生物学学科核心素养内容解读课件.pdf VIP
- 高教社2025马工程教育学原理第二版教学课件第6章 学校教育制度.pptx VIP
- 2025重庆市璧山区璧泉街道社区工作者考试真题.docx VIP
- 深度解析(2026)《JBT 9041-2025吸附槽》.pptx VIP
- 量化投资 课件 第1、2章 绪论、基本假设与基本原则.pptx
- 影视话剧剧本_性情男女.docx
- 高教社2025马工程教育学原理第二版教学课件第5章 人的全面发展教育.pptx VIP
- 南昆山毛叶茶N-甲基转移酶基因的克隆与功能解析:咖啡碱代谢调控的分子机制探索.docx VIP
- 2024年南京机电职业技术学院高职单招职业适应性测试历年高频考点试题含答案解析.docx VIP
- 江苏海事职业技术学院单招职业技能考试题库含答案详解(精练).docx VIP
原创力文档

文档评论(0)