ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

Understanding Pointcloud2 data

asked 2021-03-02 05:36:10 -0500

SurajJadhav gravatar image

updated 2021-03-03 08:37:36 -0500

tryan gravatar image

I'm trying to understand the pointcloud2 data extracted from a bag file. The contents of one sample message is as follows:

header: 
  seq: 0
  stamp: 
    secs: 1317022486
    nsecs: 689719915
  frame_id: "velo_link"
height: 1
width: 119597
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: "i"
    offset: 12
    datatype: 7
    count: 1
is_bigendian: False
point_step: 16
row_step: 1913552
data: [131, 64, 23, 66, 223, 79, 141, 61, 201, 118, 190, 63, 236, 81, 184, 62, 31, 133, 25, 66, 184, 30, 5, 62, 96, 229, 192, 63, 61, 10, 87, 62, 74, 140, 26, 66, 55, 137, 129, 62, 74, 12, 194, 63, 61, 10, 87, 62, 45, 178, 26, 66, 0, 0, 192, 62, 14, 45, 194, 63, 82, 184, 158, 62, 240, 39, 27, 66, 219, 249, 254, 62, 33, 176, 194, 63, 236, 81, 56, 62, 100, 59, 32, 66, 147, 24, 36, 63, 39, 49, 200, 63, 143, 194, 117, 62, 166, 155, 32, 66, 47, 221, 68, 63, 117, 147, 200, 63, 0, 0, 0, 0, 190, 31, 35, 66, 57, 180, 104, 63, 150, 67, 203, 63, 143, 194, 245, 61, 213, 248, 40, 66, 14, 45, 146, 63, 252, 169, ...................................]

I m just trying to match the numbers here.

data [ ] has 1913552 number of elements in it.

row_step says there is 1913552 bytes data in data array.

There are 4 elements per point: x, y, z, i. Each of 1 byte.

Thus the total number of point clouds in this captured message is: 1913552/4 = 478388.

But according to explanation given here, "If the cloud is unordered, height is 1 and width is the length of the point cloud.". That is width denotes the total number of point clouds in the message. But above calculated total number of point clouds (478388) is not matching with width(119597) given in message information. Please explain this mismatch/misunderstanding.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2021-03-02 10:49:42 -0500

tryan gravatar image

There are 4 elements per point: x, y, z, i. Each of 1 byte.

I think this is where you're getting confused. The data elements are not x, y, z coordinates; they are bytes of data. The other parameters indicate how to read them. In this case point_step = 16 indicates each point is 16 bytes, so each of its 4 components (fields) would be 4 bytes, which makes sense as they are 32-bit floats (datatype: 7; see sensor_msgs/PointField).

width: 119597

As you said, this indicates that you have 119597 points in your cloud. row_step * height is the length of data in bytes (1913552 as you noted), but each point is 16 bytes long. Therefore, the number of points in data is 1913552 / 16 = 119597 as previously indicated.

edit flag offensive delete link more

Comments

1

Thanks Tryan for pointing out the misunderstanding. After this I went on to search ros_numpy.point_cloud2.pointcloud2_to_array(msg) method which provided me the required point cloud data.

SurajJadhav gravatar image SurajJadhav  ( 2021-03-03 05:42:03 -0500 )edit

@tryan can you tell me in relation to the question of @SurajJadhav what does it mean when data is: [0,0,0,0]. Means this, that der laser light do not hit a object and can return x,y,z and intensity for it?

Petros ADLATUS gravatar image Petros ADLATUS  ( 2022-05-20 00:50:41 -0500 )edit

@Petros ADLATUS This should really be a separate question, but the short answer is: it depends... REP-117 says it should be: * below min range: -Inf * above max range: +Inf (likely no object) * error: NaN However, Ouster for example, seems to use 0 as out of range. My best advice is to find a user guide for your particular lidar.

tryan gravatar image tryan  ( 2022-05-21 14:09:04 -0500 )edit

@tryan thank you for explanation, thats the point the LIDAR leaflet hasn't these information :/

Petros ADLATUS gravatar image Petros ADLATUS  ( 2022-05-23 00:24:04 -0500 )edit

Question Tools

2 followers

Stats

Asked: 2021-03-02 05:21:25 -0500

Seen: 3,338 times

Last updated: Mar 03 '21