Getting strange width, height and size from the grabber callback
Hi there
I'm trying to get the simple OpenNI grabber tutorial (http://pointclouds.org/documentation/tutorials/openni_grabber.php#openni-grabber) to work within ros, but somehow the cloud I receive from the callback is garbage. The cloud claims to have the following properties:
- width 0, height 0, size 18446744009285042156
But when I compile it without ros the tutorial works just fine. Does ros set some compile options which could cause that?
(Running on Ubuntu 10.04 64Bit)
Source code:
class SimpleOpenNIViewer
{
public:
SimpleOpenNIViewer () : viewer ("PCL OpenNI Viewer") {}
void cloud_cb_ (const pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr &cloud) {
static unsigned count = 0;
static double last = pcl::getTime ();
std::cout << "1 -> width " << cloud->width << ", height " << cloud->height << ", size " << cloud->points.size() << std::endl;
if (!viewer.wasStopped()) {
viewer.showCloud (cloud);
}
}
void run () {
pcl::Grabber* interface = new pcl::OpenNIGrabber();
boost::function<void (const pcl::PointCloud<pcl::PointXYZRGB>::ConstPtr&)> f =
boost::bind (&SimpleOpenNIViewer::cloud_cb_, this, _1);
interface->registerCallback (f);
interface->start ();
while (!viewer.wasStopped()) {
sleep (1);
}
interface->stop ();
}
pcl::visualization::CloudViewer viewer;
};
int main (int argc, char** argv) {
ros::init(argc, argv, "openni_grabber");
ros::NodeHandle n;
SimpleOpenNIViewer v;
v.run ();
return 0;
}
CMakeLists.txt
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)
rosbuild_init()
find_package(PCL 1.2 REQUIRED)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
rosbuild_add_executable(openni_grabber src/openni_grabber.cpp)
target_link_libraries(openni_grabber ${PCL_LIBRARIES})
Asked by plpatric on 2011-11-06 20:59:37 UTC
Comments
For PCL questions please ask on the pcl-users mailing list.
Asked by tfoote on 2012-06-09 10:41:22 UTC
I really wonder the answer though. Could you find an answer?
Asked by mary on 2013-08-08 01:47:45 UTC