Ask Your Question

PCL openni_grabber to ROS fuerte

asked 2013-08-07 05:54:08 -0500

this post is marked as community wiki

This post is a wiki. Anyone with karma >75 is welcome to improve it.


I want to ask if anyone has managed to work with PCL openni_grabber tutorial in ROS?

This is the code from PCL tutorial. I really do not know what modification I should do for ROS...

#include <pcl/io/openni_grabber.h>
#include <pcl/visualization/cloud_viewer.h>

 class SimpleOpenNIViewer
     SimpleOpenNIViewer () : viewer ("PCL OpenNI Viewer") {}

     void cloud_cb_ (const pcl::PointCloud<pcl::PointXYZ>::ConstPtr &cloud)
       if (!viewer.wasStopped())
         viewer.showCloud (cloud);

     void run ()
       pcl::Grabber* interface = new pcl::OpenNIGrabber();

       boost::function<void (const pcl::PointCloud<pcl::PointXYZ>::ConstPtr&)> f =
         boost::bind (&SimpleOpenNIViewer::cloud_cb_, this, _1);

       interface->registerCallback (f);

       interface->start ();

       while (!viewer.wasStopped())
         boost::this_thread::sleep (boost::posix_time::seconds (1));

       interface->stop ();

     pcl::visualization::CloudViewer viewer;

 int main ()
   SimpleOpenNIViewer v; ();
   return 0;

and this is the cmake file

cmake_minimum_required(VERSION 2.8 FATAL_ERROR)


find_package(PCL 1.2 REQUIRED)


add_executable (openni_grabber openni_grabber.cpp)
target_link_libraries (openni_grabber ${PCL_LIBRARIES})
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2013-10-29 12:08:50 -0500

sudhanshu_mittal gravatar image

Hi If you are really looking for a way to watch the live point cloud stream in ROS. Then, best and simplest way in ROS is through rviz. Follow the following instructions:


2.roslaunch openni_launch openni.launch (other tab)

3.rosrun rviz rviz (another tab)

Once the rviz is open, change the Fixed Frame topic in Global Options to "/camera_depth_optical_frame" Next Add PointCloud2 from and change the topic to "points (sensor_msgs/PointCloud2)".

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

1 follower


Asked: 2013-08-07 05:54:08 -0500

Seen: 412 times

Last updated: Oct 29 '13