Rosanswers logo


It took me a while to run the sample code for down-sampling a point cloud using voxel grid, as given in tutorial page at : http://wiki.ros.org/pcl/Tutorials?action=AttachFile&do=view&target=example_voxelgrid.cpp, tutorial link : http://wiki.ros.org/pcl/Tutorials
I am using ROS Hydro on Ubuntu12.04, and catkin build. I am thinking of updating these links and add code for Hydro. Kindly let me know if some changes I made are redundent etc. Specifically I made the following changes:-

  1. Code :
    • Deleted : #include <pcl/ros/conversions.h>
      Added: #include <pcl_conversions/pcl_conversions.h>
        #include <sensor_msgs/PointCloud2.h>
    • Modified the callback function to use pcl::PCLPointCloud2 instead of sensor_msgs::PointCloud2 as:-
      (It's given at hydro migration : http://wiki.ros.org/hydro/Migration)

      void cloud_cb (const pcl::PCLPointCloud2ConstPtr& input) { pcl::PCLPointCloud2 cloud_filtered; pcl::VoxelGrid<pcl::PCLPointCloud2> sor; sor.setInputCloud (input); sor.setLeafSize (0.01, 0.01, 0.01); sor.filter (cloud_filtered);

      // Publish the dataSize pub.publish (cloud_filtered); }

  2. IN package.xml (from http://wiki.ros.org/hydro/Migration
    (....pcl is no longer packaged by the ROS community as a catkin package, so any packages which directly depend on pcl should instead use the new rosdep rules libpcl-all and libpcl-all-dev...... )
    and understood it (I think) by seeing the post at http://www.pcl-users.org/How-do-I-use-PCL-from-ROS-Hydro-td4029613.html (3rd comment : given by, Matteo Munaro Sep 12, 2013; 3:46pm), and also https://github.com/ros-perception/pcl_conversions/commit/a868e1a16e442c135f66a9738619d290bc4ee896)
    Removed: build_depend>pcl</build_depend>
    Added: <build_depend>libpcl-all-dev</build_depend>
    I am wondering if the addition of libpcl-all-dev and libpcl-all, could automatically be done while creting the package.
  3. In CMakeList.txt
    Removed: pcl dependency Added: pcl_conversions dependency
    Again seeing the above mentioned link. Note: This could also be achieved by changing the package creation line to : catkin_create_pkg my_pcl_tutorial pcl_conversions pcl_ros roscpp sensor_msgs
I am quite sure that these changes must be done by many ppl who have run this tutorial and quite sad that they were not updated. Changes are a bit trivial once you understand, but still tutoral should run without giving any error, so that ppl like me could understand things easily :-).
Also is there a way to get libpcl-all-dev and libpcl-all directly in package.xml while creating the package.

Originally posted by aknirala on ROS Answers with karma: 339 on 2013-10-12

Post score: 3


1 Answer 1


Rosanswers logo

I have updated the tutorial, kindly let me know if it is correct.

The zip for my project it at: http://wiki.ros.org/pcl/Tutorials?action=AttachFile&do=view&target=my_pcl_tutorial2.tar.gz

Originally posted by aknirala with karma: 339 on 2013-11-04

This answer was ACCEPTED on the original site

Post score: 1

Original comments

Comment by mortonjt on 2014-01-10:
Thank you very much for posting your solution. Do you mind if you could post your CMakelists.txt? I'm still getting linker errors even with the changes that you suggested.

Comment by aknirala on 2014-01-26:
Hi, Sorry for the late reply, its running fine for me. I tried for pcl::PCLPointCloud2, and not pcl/PointCloud. I am uploading the zip file of my pcl project (named it 2 (my_pcl_tutorial2) as previous one was already there, which I have to move as example.cpp was in both). Link updated in answer.

Comment by lfelipesv on 2014-01-26:
Hello aknirala, i followed your tutorial and is working for me. But now, I can't save one input Point Cloud 2 to a PCD File. I think I need to follow some conversions first. My code is here: http://answers.ros.org/question/121856/write-pcd-file-from-a-topic-hydro-pcl-migration/ Thank you!


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.