Ask Your Question
0

PLC PointCloud subscribing

asked 2013-12-06 04:02:37 -0500

Phorce gravatar image

updated 2016-10-24 09:03:00 -0500

ngrennan gravatar image

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?

Thanks

P.S.

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);
   ros::spin();
}
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2013-12-06 05:02:56 -0500

Tirjen gravatar image

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!

edit flag offensive delete link more

Comments

@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?

Phorce gravatar imagePhorce ( 2013-12-06 05:27:41 -0500 )edit

Yes of course!! But the message is sensor_msgs/PointCloud2.h!

Tirjen gravatar imageTirjen ( 2013-12-08 20:21:28 -0500 )edit

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

Stats

Asked: 2013-12-06 04:02:37 -0500

Seen: 2,004 times

Last updated: Dec 06 '13