ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

PCL openni_grabber to ROS fuerte

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

this post is marked as community wiki

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

Hello,

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
 {
   public:
     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;
   v.run ();
   return 0;
 }

and this is the cmake file

cmake_minimum_required(VERSION 2.8 FATAL_ERROR)

project(openni_grabber)

find_package(PCL 1.2 REQUIRED)

include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})

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
1

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

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:

1.roscore

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

Question Tools

1 follower

Stats

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

Seen: 517 times

Last updated: Oct 29 '13