Ask Your Question
1

Getting PointCloud2 data in Python?

asked 2012-06-04 14:56:44 -0500

Pi Robot gravatar image

updated 2016-10-24 09:01:55 -0500

ngrennan gravatar image

Hello,

I am trying to translate the TurtleBot "follower" program (written in C++) to Python but I'm not sure how to read the (x, y, z) values from the PointCloud2 message returned by the Kinect without using PCL. I know I can use the depth image from the Kinect on /camera/depth/image but I'd rather use the PointCloud2 message type if possible.

I can subscribe to the /camera/depth/points or /camera/rgb/points topic and print back things like the message header and field names, but I'm not sure how to get the actual x, y and z data values so that I can iterate through them and compute average values. Does anyone know the magic incantation?

Thanks!
patrick

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2012-06-04 15:07:03 -0500

arebgun gravatar image

Apparently this functionality is a part of sensor_msgs package, here's a link to relevant file.

edit flag offensive delete link more

Comments

Thanks @arebgun. I'm wondering if this has made it into the Electric debs yet? I grabbed the source for sensor_msgs from trunk and although it compiled fine, I can't seem to use it in my follower package. When doing a rosmake I get "Package sensor_msgs was not found in the pkg-config search path"

Pi Robot gravatar imagePi Robot ( 2012-06-04 15:35:06 -0500 )edit

It doesn't look like this file is in the electric tree. The file is 4 months old, so I doubt that electric will have that functionality at all. 1.7.x and later series of the stack have this python file, so Fuerte should have this, but not Electric (1.6.x. series).

arebgun gravatar imagearebgun ( 2012-06-04 16:03:38 -0500 )edit
0

answered 2012-06-04 17:22:41 -0500

updated 2012-06-04 17:23:40 -0500

I wouldn't recommend using the struct-based point cloud deserialization in python. It's very slow. pr2_python.pointclouds, which is part of the Sushi code from the PR2 Workshop/ICRA challenge does a pretty good job, and is much faster.

edit flag offensive delete link more

Comments

Thanks @Dan Lazewatsky. But I get much faster results (2-4 times faster) with the method pointed to by Anton above.

Pi Robot gravatar imagePi Robot ( 2012-06-05 03:48:06 -0500 )edit

That's surprising. About how many points are in your point clouds?

Dan Lazewatsky gravatar imageDan Lazewatsky ( 2012-06-05 03:50:05 -0500 )edit

76800 points (320x240 image). Also, I had to change the datatype to float64 instead of float32 for ROS Electric and then the values I get back for y and z seem way off (e.g. 1.7EE-41 for average y). So something weird is going on.

Pi Robot gravatar imagePi Robot ( 2012-06-05 04:03:33 -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

2 followers

Stats

Asked: 2012-06-04 14:56:44 -0500

Seen: 3,242 times

Last updated: Jun 04 '12