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 d
ata:
- 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 Delet
e: 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: