Rosanswers logo

I'm doing a project on motion detection and and gesture recognition and I have to extract and subscribe to the PointCloud2 sensor messages on the Kinect device using openni but I am new to ROS and have no idea how to do it. I've been reading: Here

However, whenever I try to run the examples, I get the following:

fatal error: pcl/point_cloud.h: No such file or directory but I have installed the PCL library, so, might it have something to do with my CMake file not including something?

Could someone please link me or try to explain how I would possibly Subscribe to the PointCloud and have a callback function which publishes the data that is being extracted on my own topic?



I have tried to implement the following:

#include <ros/ros.h>
#include <pcl_ros/point_cloud.h>
#include <pcl/point_types.h>
#include <boost/foreach.hpp>

typedef pcl::PointCloud<pcl::PointXYZ> PointCloud;

void callback(const PointCloud::ConstPtr& msg)
  printf ("Cloud: width = %d, height = %d\n", msg->width, msg->height);
  BOOST_FOREACH (const pcl::PointXYZ& pt, msg->points)
  printf ("\t(%f, %f, %f)\n", pt.x, pt.y, pt.z);

int main(int argc, char** argv)
   ros::init(argc, argv, "sub_pcl");
   ros::NodeHandle nh;
   ros::Subscriber sub = nh.subscribe<PointCloud>("points2", 1, callback);

Originally posted by Phorce on ROS Answers with karma: 97 on 2013-12-06

Post score: 0


1 Answer 1


Rosanswers logo

If you are using the command:

roslaunch openni_launch openni.launch

to bring up the kinect, then you should subscribe to one of the "points" topic using a sensor_msgs/PointCloud2 message. So you have to include in your code:

#include <sensor_msgs/PointCloud2.h>

Then if you want to use this point cloud with PCL you have to convert it using the pcl_conversions package. I suggest you yo look at this link!

Originally posted by Tirjen with karma: 808 on 2013-12-06

This answer was ACCEPTED on the original site

Post score: 0

Original comments

Comment by Phorce on 2013-12-06:
@Tirjen Hey. If I did not want to use the PCL, can I just subscribe to the sensor_msgs/PointCloud.h and then extract the data from this?

Comment by Tirjen on 2013-12-08:
Yes of course!! But the message is sensor_msgs/PointCloud2.h!


Your Answer

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