Ask Your Question
0

How to interpret pointcloud topic "/kinect/depth/points" from openni_kinect library?

asked 2022-01-20 08:06:29 -0500

jvj00 gravatar image

I search for a long time on wikis/forums... but i found nothing which fits to me. I still don't know how to get coordinates x y z from every point in this topic, how many points they are and, possibly, RGB values.

This is the content of a message in this topic:

header: seq: 19 stamp: secs: 124 nsecs: 110000000 frame_id: "camera_depth_optical_frame" height: 480 width: 640 fields: - name: "x" offset: 0 datatype: 7 count: 1 - name: "y" offset: 4 datatype: 7 count: 1 - name: "z" offset: 8 datatype: 7 count: 1 - name: "rgb" offset: 16 datatype: 7 count: 1 is_bigendian: False point_step: 32 row_step: 20480 data: [0, 0, 192, 127, 0, 0, 192, 127, 0, 0, 192, 127, 0, 0, 0, 0, 178, 178, 178, 0, 0, 0, 0, 0, 0, 0, 0, ...] is_dense: False

edit retag flag offensive close merge delete

Comments

If message is type sensor_msgs/PointCloud2.msg my advice would be to look pcl library. The pcl library has a lot of implemented things for pointclouds.

dembele123 gravatar image dembele123  ( 2022-01-20 13:27:54 -0500 )edit

Are you using roscpp or rospy?

Mike Scheutzow gravatar image Mike Scheutzow  ( 2022-01-22 10:20:29 -0500 )edit

I'm using roscpp

jvj00 gravatar image jvj00  ( 2022-01-24 07:52:34 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-01-20 12:54:14 -0500

osilva gravatar image

updated 2022-01-20 12:59:01 -0500

Hi @jvj00:

What you have here is a message of type" sensor_msgs/PointCloud2.msg: Reference: http://docs.ros.org/en/noetic/api/sen...

# This message holds a collection of N-dimensional points, which may
# contain additional information such as normals, intensity, etc. The
# point data is stored as a binary blob, its layout described by the
# contents of the "fields" array.

# The point cloud data may be organized 2d (image-like) or 1d
# (unordered). Point clouds organized as 2d images may be produced by
# camera depth sensors such as stereo or time-of-flight.

# Time of sensor data acquisition, and the coordinate frame ID (for 3d
# points).
Header header

# 2D structure of the point cloud. If the cloud is unordered, height is
# 1 and width is the length of the point cloud.
uint32 height
uint32 width

# Describes the channels and their layout in the binary data blob.
PointField[] fields

bool    is_bigendian # Is this data bigendian?
uint32  point_step   # Length of a point in bytes
uint32  row_step     # Length of a row in bytes
uint8[] data         # Actual point data, size is (row_step*height)

bool is_dense        # True if there are no invalid points

Let's break it a little further: The header message is of type std_msgs/Header.msg

uint32 seq
time stamp
string frame_id

In your case: header: seq: 19 stamp: secs: 124 nsecs: 110000000

uint32 height
uint32 width

frame_id: "camera_depth_optical_frame" height: 480 width: 640

Then comes

PointField[] fields

PointField[] fields is of type sensor_msgs/PointField.msg

The sensor_msgs/PointField.msg is composed of:

# This message holds the description of one point entry in the
# PointCloud2 message format.
uint8 INT8    = 1
uint8 UINT8   = 2
uint8 INT16   = 3
uint8 UINT16  = 4
uint8 INT32   = 5
uint8 UINT32  = 6
uint8 FLOAT32 = 7
uint8 FLOAT64 = 8

string name      # Name of field
uint32 offset    # Offset from start of point struct
uint8  datatype  # Datatype enumeration, see above
uint32 count     # How many elements in the field

In your case: fields: - name: "x" offset: 0 datatype: 7 count: 1 - name: "y" offset: 4 datatype: 7 count: 1 - name: "z" offset: 8 datatype: 7 count: 1

is_bigendian, point_step and row_step and is_dense are straight forward to understand.

Finally,

uint8[] data

data contains the Actual point data, size is (row_step*height) In your case: data: [0, 0, 192, 127, 0, 0, 192, 127, 0, 0, 192, 127, 0, 0, 0, 0, 178, 178, 178, 0, 0, 0, 0, 0, 0, 0, 0, ...]

If you like to learn how to read this point with code, refer to this tutorial: http://wiki.ros.org/pcl/Tutorials

edit flag offensive delete link more

Comments

Thanks a lot! I'll try to write a program with this information that you give to me

jvj00 gravatar image jvj00  ( 2022-01-21 10:25:19 -0500 )edit

Glad it helped. Kindly accept the answer by clicking on the check mark. Thank you.

osilva gravatar image osilva  ( 2022-01-21 10:36:37 -0500 )edit

@jvj00 You do not need to convert this PointCloud2 msg to "useful" form yourself, there is already standard code in pcl_rosto do it (although I feel it is documented poorly.) See Section 3.1 on this page: http://wiki.ros.org/pcl_ros?distro=no...

Mike Scheutzow gravatar image Mike Scheutzow  ( 2022-01-22 10:07:56 -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: 2022-01-20 08:06:29 -0500

Seen: 41 times

Last updated: Jan 20