I'm currently working with a Livox Avia LiDAR and I'm utilising ROS to access its data stream which is in the PointCloud2 format. A LiDAR is mainly use to measure the distance an object in the boresight to the LiDAR.
Does anyone know how to read off a distance from PointCloud2?
Thanks in advance
You need to be a little more specific in what you mean by "read off a distance" since there are multiple distances that could be of use when talking about PC2 data. I'm assuming you're talking about distance from the sensor to a single measured point. If that's the case, you can pull out more usable information from pointcloud data with
the generator function read_points()
to get (x, y, z) and then calculate distance directly. You can grab all points in x, y, z format like this:
from sensor_msgs import point_cloud2
def pc2_callback(msg):
generator = point_cloud2.read_points(msg, skip_nans=True, field_names=("x", "y", "z"))