Ask Your Question

PCL_tutorial, how to show the point cloud

asked 2012-11-19 04:27:59 -0500

Pierre gravatar image

updated 2016-10-24 08:36:52 -0500

ngrennan gravatar image


I am following the tutorial of PCL with ROS (

When i launch the openni i can see the topic is publishing. But when i try to use it to see the result, nothing happen (only black screen is showed in the rviz window).

What i have to do to show the result?

here is the code i use:

#include <ros/ros.h>
// PCL specific includes
#include <pcl/ros/conversions.h>
#include <pcl/point_cloud.h>
#include <pcl/point_types.h>

#include <pcl/filters/voxel_grid.h>

ros::Publisher pub;

void cloud_cb (const sensor_msgs::PointCloud2ConstPtr& cloud){
sensor_msgs::PointCloud2 cloud_filtered;

 // Perform the actual filtering
pcl::VoxelGrid<sensor_msgs::PointCloud2> sor;
sor.setInputCloud (cloud);
sor.setLeafSize (0.01, 0.01, 0.01);
sor.filter (cloud_filtered);

// Publish the data
pub.publish (cloud_filtered);

int main (int argc, char** argv){
// Initialize ROS
ros::init (argc, argv, "my_pcl_tutorial");
ros::NodeHandle nh;

 // Create a ROS subscriber for the input point cloud
ros::Subscriber sub = nh.subscribe ("input", 1, cloud_cb);

// Create a ROS publisher for the output point cloud
pub = nh.advertise<sensor_msgs::PointCloud2> ("output", 1);

// Spin
ros::spin ();



edit retag flag offensive close merge delete


Did you add the correct type and the topic you're interested in correctly in Rviz?

Albert K gravatar image Albert K  ( 2012-11-19 05:06:19 -0500 )edit

I think so. I add a pointCloud2. And in the topic i selected the output(sensor_msgs/PointCloud2).

Pierre gravatar image Pierre  ( 2012-11-19 05:16:17 -0500 )edit

What about the topic you subscribe to? If you try to catch the data published by openni node, the topic you subscribe to shouldn't be "input".

Albert K gravatar image Albert K  ( 2012-11-19 05:19:26 -0500 )edit

For the topic i subscribe i just followed the tutorial putting in the terminal: rosrun my_pcl_tutorial example input:=/narrow_stereo_textured/points2

Pierre gravatar image Pierre  ( 2012-11-19 05:26:11 -0500 )edit

If you're using openni (assuming you're using the openni_launch files), your input cloud should be /camera/depth/points or /camera/depth_registered/points. Nothing in openni_launch publishes /narrow_stereo_textured/point2. The PCL tutorial assumes you have a stereo vision system that does.

Ed Venator gravatar image Ed Venator  ( 2012-11-19 13:44:33 -0500 )edit

I don't understand, because yesterday i tried it with input:=/camera/depth_registered/points and that produced an error on the openni_launch terminal. But today it works... Thank you so much for your help.

Pierre gravatar image Pierre  ( 2012-11-20 02:26:36 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2014-04-17 10:19:17 -0500

Ken_in_JAPAN gravatar image

Please check this page( ) if you have some trouble. I think that a result on this page is useful for you.

edit flag offensive delete link more

answered 2012-11-20 06:11:20 -0500

Pierre gravatar image

Thank you Ed Venator. With input:=/camera/depth_registered/points that work perfectly.

"The PCL tutorial assumes you have a stereo vision system that does." What stereo vision system are you talking about?

edit flag offensive delete link more


I don't know; it may be that the author of that tutorial was using a stereo vision system of his own creation. I believe that tutorial predates the use of the Kinect in ROS.

Ed Venator gravatar image Ed Venator  ( 2012-11-30 09:12:10 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2012-11-19 04:27:59 -0500

Seen: 4,149 times

Last updated: Apr 17 '14