Velodyne lidars publish PointCloud2 messages with the fields containing :
However, I need to add distance field(output points with distance) because I needed this field as a research purpose.
Is it possible to write a node or adapt the velodyne driver to output points with that field? If so, could you possibly tell me how to achieve that?
Any help is much appreciated. Thanks:)
The best solution is not to change the velodyne driver, but since you're using ros, to leverage all the ecosystem tools built in. For example, the velodyne publishes a sensor_msgs/PointCloud2 topic. Then internally, using C++, ROS treats any PointCloud2 msg into any PCL pointcloud type. If you're doing serious processing of pointclouds, don't re-invent the wheel (but worse), try solving the problem with tools from PCL. Use it's pre-built filters (ex ground plane filter) and prebuilt segmentation tools (ex could Euclidean Cluster Extraction solve your problem?). Additionally, some of these PCL tools are pre-wrapped in ros, to use from the launch file if you want!
Otherwise you could use PCL to add a distance parameter, by choosing the pointcloud type in ros as of type pcl::PointWithRange
or pcl::PointWithViewpoint
. I don't think it'll autocompute that variable, but you can iterate through the points and compute it yourself, and the memory for it will already be allocated and localized.