diff --git a/src/ros_numpy/point_cloud2.py b/src/ros_numpy/point_cloud2.py index 7c861a9..e4926bd 100755 --- a/src/ros_numpy/point_cloud2.py +++ b/src/ros_numpy/point_cloud2.py @@ -63,7 +63,7 @@ def fields_to_dtype(fields, point_step): ''' offset = 0 np_dtype_list = [] - for f in fields: + for f in sorted(fields, key=lambda _f: _f.offset): while offset < f.offset: # might be extra padding between fields np_dtype_list.append(('%s%d' % (DUMMY_FIELD_PREFIX, offset), np.uint8))