0
$\begingroup$

Rosanswers logo

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})

Originally posted by mary on ROS Answers with karma: 43 on 2013-08-07

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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)".


Originally posted by sudhanshu_mittal with karma: 311 on 2013-10-29

This answer was ACCEPTED on the original site

Post score: 1

$\endgroup$

Your Answer

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