ros-drivers / ros2_ouster_drivers

ROS2 Drivers for the Ouster OS-0, OS-1, and OS-2 Lidars
https://ouster.com/
Apache License 2.0
134 stars 79 forks source link

Possible mismatch in angle_min, angle_max, angle_increment and number of data points in LaserScan message #138

Open nielsvd opened 1 year ago

nielsvd commented 1 year ago

In attempting to combine the ouster_driver with a SLAM algorithm, it came to my attention that, in the /scan topic, there may be a mismatch between:

The SLAM algorithm in question asserts the following condition (up to floating-point precision): msg.angle_max == msg.angle_min + msg.angle_increment * (msg.ranges.size() - 1) I.e., by (msg.ranges.size() - 1) the number of "gaps" between data points determines the angle increment, and not the number of data points itself. I suppose that makes sense, in particular if you would generalize to non-360 degree scans. As can be seen in https://github.com/ros-drivers/ros2_ouster_drivers/blob/d3cd586e2548f9989b68ebc33b03a5d99b816ea8/ros2_ouster/include/ros2_ouster/conversions.hpp#L230 ... in the driver the "number of data points" is used to compute the angle increment, and the lines above are equivalent to msg.angle_increment = (msg.angle_max - msg.angle_min) / msg.ranges.size().

Say there is indeed a mismatch, there could be an error in at least three of the data fields mentioned above. Currently, I'm not familiar enough with the device and the driver to determine which one should be fixed: