Access pointcloud 3d point using pixel coordinate using ros2 wrapper

Using the zed sdk, it is quite easy. However, i can’t find any resource on how to do this in ros2.

point_cloud = sl.Mat()
zed.retrieve_measure(point_cloud, sl.MEASURE.XYZRGBA)

Get the 3D point cloud values for pixel (i,j)

point3D = point_cloud.get_value(i,j)
x = point3D[0]
y = point3D[1]
z = point3D[2]
color = point3D[3]

Hello and welcome to our forum,

What’s the matter with your code ? Do you get an error somewhere ? It seems right to me.

Antoine

I’m facing the same problem:
The issue is that using ros2 wrapper you get a sensor_msgs.PointCloud2. How can you, from this ros2 type, use .get_value(i,j)?

Using point_cloud2.read_points_numpy(msg, field_names=['x', 'y', 'z'], skip_nans=True) you get a nx3 array of the point cloud coordinates, so you can maybe use it to get X,Y,Z, through I’m not sure cause of missing points.

It would be useful to have an implemented method in ros2 wrapper.