You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I encountered a ValueError in using point_cloud2.pointcloud2_to_xyz_array(). It has been figured out due to the disorder of offest among the PointFields.
The origin message(sensor_msgs/PointCloud2) has 'field' attriubte as below:
Note that attribute "intensity" with offset 32 is arranged at the front of other attributes with larger offsets. As a result, in pointcloud2_to_array() in point_cloud2.py:
# construct a numpy record type equivalent to the point type of this clouddtype_list=fields_to_dtype(cloud_msg.fields, cloud_msg.point_step)
# parse the cloud into an arraycloud_arr=np.frombuffer(cloud_msg.data, dtype_list)
Then it leads to mismatch in data structure and memory space and Error occurs in np.frombuffer()
Traceback (most recent call last):
File "/opt/ros/noetic/lib/python3/dist-packages/rospy/topics.py", line 750, in _invoke_callback
cb(msg)
File "/home/carto/lio_ws/src/faster-lio/src/map_builder.py", line 31, in pc_callback
self.point_cloud = ros_numpy.point_cloud2.pointcloud2_to_xyz_array(msg)
File "/home/carto/lio_ws/src/ros_numpy/src/ros_numpy/point_cloud2.py", line 244, in pointcloud2_to_xyz_array
return get_xyz_points(pointcloud2_to_array(cloud_msg), remove_nans=remove_nans)
File "/home/carto/lio_ws/src/ros_numpy/src/ros_numpy/point_cloud2.py", line 123, in pointcloud2_to_array
cloud_arr = np.frombuffer(cloud_msg.data, dtype_list)
ValueError: buffer size must be a multiple of element size
So I wonder whether we can sort the fields in advance in function fields_to_dtype or any other fix to avoid bugs dealing with msg with disorder field.
The text was updated successfully, but these errors were encountered:
@zymouse: Yes, it worked well for me as well. The pull request is open and can be merged. Their is also an open issue in PCL to fix it on the sender site, they seem to be happy about a fix, but I didn't have time to get to it yet.
I encountered a ValueError in using point_cloud2.pointcloud2_to_xyz_array(). It has been figured out due to the disorder of offest among the PointFields.
The origin message(sensor_msgs/PointCloud2) has 'field' attriubte as below:
Note that attribute "intensity" with offset 32 is arranged at the front of other attributes with larger offsets. As a result, in
pointcloud2_to_array()
inpoint_cloud2.py
:I got
dtype_list
in such a strange form:Then it leads to mismatch in data structure and memory space and Error occurs in
np.frombuffer()
So I wonder whether we can sort the fields in advance in function
fields_to_dtype
or any other fix to avoid bugs dealing with msg with disorder field.The text was updated successfully, but these errors were encountered: