File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -250,8 +250,10 @@ def create_cloud(
250
250
for each point, with the elements of each iterable being the
251
251
values of the fields for that point (in the same order as
252
252
the fields parameter)
253
- :param point_step: Point step size in bytes. Calculated from the given fields by default.
254
- (Type: optional of integer)
253
+ :param point_step: Point step size in bytes. If not provided, it is calculated
254
+ from the given fields, except when 'points' is a structured
255
+ NumPy array, in which case points.dtype.itemsize is used.
256
+ (Type: optional integer)
255
257
:return: The point cloud as sensor_msgs.msg.PointCloud2
256
258
"""
257
259
# Check if input is numpy array
@@ -266,7 +268,7 @@ def create_cloud(
266
268
points ,
267
269
dtype = dtype_from_fields (fields , point_step ))
268
270
else :
269
- assert points .dtype == dtype_from_fields (fields , point_step ), \
271
+ assert points .dtype == dtype_from_fields (fields , point_step or points . dtype . itemsize ), \
270
272
'PointFields and structured NumPy array dtype do not match for all fields! \
271
273
Check their field order, names and types.'
272
274
else :
Original file line number Diff line number Diff line change @@ -296,10 +296,18 @@ def test_create_cloud(self):
296
296
def test_create_cloud_itemsize (self ):
297
297
298
298
with self .assertRaises (AssertionError ):
299
+ dtype_from_fields = point_cloud2 .dtype_from_fields (fields )
299
300
point_cloud2 .create_cloud (
301
+ Header (frame_id = 'frame' ),
302
+ fields ,
303
+ points_end_padding ,
304
+ dtype_from_fields .itemsize )
305
+
306
+ thispcd = point_cloud2 .create_cloud (
300
307
Header (frame_id = 'frame' ),
301
308
fields ,
302
309
points_end_padding )
310
+ self .assertEqual (thispcd .point_step , itemsize_end_padding )
303
311
304
312
thispcd = point_cloud2 .create_cloud (
305
313
Header (frame_id = 'frame' ),
You can’t perform that action at this time.
0 commit comments