PCL_tutorial, how to show the point cloud
Hello,
I am following the tutorial of PCL with ROS (www.ros.org/wiki/pcl/Tutorials).
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 ();
}
Thanks
--Pierre
Did you add the correct type and the topic you're interested in correctly in Rviz?
I think so. I add a pointCloud2. And in the topic i selected the output(sensor_msgs/PointCloud2).
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".
For the topic i subscribe i just followed the tutorial putting in the terminal: rosrun my_pcl_tutorial example input:=/narrow_stereo_textured/points2
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.
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.