How to use a PCL tutorial in ROS

   日期:2024-12-26    作者:m472b 移动:http://mip.riyuangf.com/mobile/quote/49709.html

How to use a PCL tutorial in ROS

A comprehensive list of PCL tutorials can be found on PCL's . Here are a few of the tutorials that you might want to check out:
The following tutorial describes how to use any of the existing tutorials on in a ROS ecosystem using nodes or nodelets. for hydro use This will create a new ROS package with the necessary dependencies. For Hydro modify the package.xml to add Create an empty file called src/example.cpp and paste the following code in it: The code above does nothing but initialize ROS, create a subscriber and a publisher for PointCloud2 data. Edit the CMakeLists.txt file in your newly created package and add: All PCL versions prior to 2.0, have two different ways of representing point cloud data:
  • through a sensor_msgs/PointCloud2 ROS message
  • through a pcl/PointCloud<T> data structure
The following two code examples will discuss both formats. The sensor_msgs/PointCloud2 format was designed as a ROS message, and is the preferred choice for ROS applications. In the following example, we downsample a PointCloud2 structure using a 3D grid, thus reducing the number of points in the input dataset considerably. To add this capability to the code skeleton above, perform the following steps:
  • visit , click on Tutorials, then navigate to the Downsampling a PointCloud using a VoxelGrid filter tutorial ()
  • In these lines, the input dataset is named cloud, and the output dataset is called cloud_filtered. Copy these lines, in the code snippet above, by modifying the callback function as follows:
Save the output file then build: Then run:
rosrun my_pcl_tutorial example input:=/narrow_stereo_textured/points2
For Hydro, make following changes in the code Delete: Add: Modified the callback function to use pcl::PCLPointCloud2 instead of sensor_msgs:: as:-<br> (It's given at hydro migration : ) The pcl/PointCloud<T> format represents the internal PCL point cloud format. For modularity and efficiency reasons, the format is templated on the point type, and PCL provides a list of templated common types which are SSE aligned. In the following example, we estimate the planar coefficients of the largest plane found in a scene. To add this capability to the code skeleton above, perform the following steps:
  • visit , click on Tutorials, then navigate to the Planar model segmentation tutorial ()
  • In these lines, the input dataset is named cloud and is of type pcl::<pcl::PointXYZ>, and the output is represented by a set of point indices that contain the plane together with the plane coefficients. cloud.makeShared() creates a object for the object cloud (see documentation).
Copy these lines, in the code snippet above, by modifying the callback function as follows: In addition, since we're now publishing the planar model coefficients found rather than point cloud data, we have to change our publisher type from:
  // Create a ROS publisher for the output point cloud
  pub = nh.advertise<sensor_msgs::PointCloud2> ("output", 1);
to:
  // Create a ROS publisher for the output model coefficients
  pub = nh.advertise<pcl::ModelCoefficients> ("output", 1);
Save the output file, then compile and run the code above:

特别提示:本信息由相关用户自行提供,真实性未证实,仅供参考。请谨慎采用,风险自负。


举报收藏 0评论 0
0相关评论
相关最新动态
推荐最新动态
点击排行
{
网站首页  |  关于我们  |  联系方式  |  使用协议  |  隐私政策  |  版权隐私  |  网站地图  |  排名推广  |  广告服务  |  积分换礼  |  网站留言  |  RSS订阅  |  违规举报  |  鄂ICP备2020018471号