From cfd9dbc9861ceb61b97d65547f3874ccc5a93af6 Mon Sep 17 00:00:00 2001 From: Simon Waterer Date: Mon, 4 Jul 2022 12:08:54 +1200 Subject: [PATCH 1/2] Fix import of numpy_pc2 --- pypcd/pypcd.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pypcd/pypcd.py b/pypcd/pypcd.py index 68d199d..9459238 100644 --- a/pypcd/pypcd.py +++ b/pypcd/pypcd.py @@ -24,7 +24,7 @@ HAS_SENSOR_MSGS = True try: from sensor_msgs.msg import PointField - import numpy_pc2 # needs sensor_msgs + from . import numpy_pc2 # needs sensor_msgs except ImportError: HAS_SENSOR_MSGS = False From 5a35f6c93303c4d138dfe32aaec45f644fb2c121 Mon Sep 17 00:00:00 2001 From: Simon Waterer Date: Mon, 4 Jul 2022 12:09:44 +1200 Subject: [PATCH 2/2] Fix for ROS2 - convert the PointCloud2 msg data to bytes object for call to np.fromstring --- pypcd/numpy_pc2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pypcd/numpy_pc2.py b/pypcd/numpy_pc2.py index 7b5ba97..00140e7 100644 --- a/pypcd/numpy_pc2.py +++ b/pypcd/numpy_pc2.py @@ -131,7 +131,7 @@ def pointcloud2_to_array(cloud_msg, split_rgb=False, remove_padding=True): dtype_list = pointcloud2_to_dtype(cloud_msg) # parse the cloud into an array - cloud_arr = np.fromstring(cloud_msg.data, dtype_list) + cloud_arr = np.fromstring(cloud_msg.data.tobytes(), dtype_list) # remove the dummy fields that were added if remove_padding: