I can't understand pointcloud2 data [closed]

asked 2022-05-21 06:34:50 -0500

hnb gravatar image

updated 2022-05-21 07:48:10 -0500

Mike Scheutzow gravatar image

Ubuntu 18.04 Ros Melodic


rostopic echo /os_cloud_node/points

header: 
  seq: 57363
  stamp: 
    secs: 6366
    nsecs: 847305660
  frame_id: "os_sensor"
height: 16
width: 1024
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: "intensity"
    offset: 16
    datatype: 7
    count: 1
  - 
    name: "t"
    offset: 20
    datatype: 6
    count: 1
  - 
    name: "reflectivity"
    offset: 24
    datatype: 4
    count: 1
  - 
    name: "ring"
    offset: 26
    datatype: 2
    count: 1
  - 
 name: "ambient"
    offset: 28
    datatype: 4
    count: 1
  - 
    name: "range"
    offset: 32
    datatype: 6
    count: 1
is_bigendian: False
point_step: 48
row_step: 49152
data: [198, 131, 166, 191, 109, 184, 151, 189, 79, 129, 194, 62, 0, 0, 128, 63, 0, 0, 185, 67, 0, 0, 0, 0, 104, 0, 0, 0, 38, 1, 0, 0, 68, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 101, 251, 131, 191, 96, 237, 85, 189, 78, 158, 157, 62, 0, 0, 128, 63, 0, 0, 57, 67, 222, 127, 1, 0, 53, 0, 0, 0, 17, 1, 0, 0, 44, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 0, 0, 0, 128, 0, 0, 0, 0, 0, 0, 128, 63, 0, 0, 0, 0, 72, 0, 3, 0, 0, 0, 0, 0, 219,

def func(veri):
   ldrdata=veri.data

   print(type(ldrdata)) #string

 print(ldrdata)

the output: image description

image

If there is an obstacle 3 meters ahead, I want to get this number 3. How should I use pointcloud2 data for this?

Thanks in advance

edit retag flag offensive reopen merge delete

Closed for the following reason duplicate question by gvdhoorn
close date 2022-05-21 10:35:41.266170

Comments

The data[] is a serialized form of the original data, and you are not expected to read the values directly. There are pre-existing methods to convert it back into useful format. For example, see the "walle" answer to #q202787.

Mike Scheutzow gravatar image Mike Scheutzow  ( 2022-05-21 07:43:21 -0500 )edit

I've closed this as a duplicate, as there are a number of previously asked (and answered) Q&As which seem to discuss the same topic: see #q273182, #q373094, #q300906, #q349814, #q319350 and #q294913 for instance. And #q399882, which was asked only three weeks ago.

There are many more. A google search with site:answers.ros.org should return them.

gvdhoorn gravatar image gvdhoorn  ( 2022-05-21 10:35:31 -0500 )edit