-
Notifications
You must be signed in to change notification settings - Fork 285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Off-by-one error in constructing/populating LaserScan message ? #14
Comments
Thanks, this is interesting and I'll try to investigate sometime soon. If you have a suggested fix, a PR would be very welcome! |
Reading your RA question, I think |
I think this is not so straight-forward, as you are dealing with some sort of histogram here (non-zero width bins), instead of actual rays. Obviously you could just add one to the calculated size. But then you'd have a mostly useless top bin, when you have Also you'd probably want to perform the check whether or not to skip a point based on the calculated bin index, instead of the actual angle, to take into account the non-zero bin width. For the same reason it might make sense to "correct" the angles that are assigned to the message after using them to set up the bin ranges from the user configuration. On the one hand to fix the case where the angle range is not divisible by the bin width, but also to let the "rays" point to the center of each bin (e.g., In conclusion, this seems not so straight-forward and unfortunately I don't have a PR I could submit right now.
|
I added a PR to address this issue. |
I've turned this every which way and I'm not sure I've come up with a consistently good answer to this problem. The current behaviour of pointcloud_to_laserscan is definitely naive when it comes to range and bucket assignments. I think we have to fallback to how the LaserScan is defined in relation to a 'real' LIDAR sensor. If the FOV of a hardware LIDAR is 2pi, I would expect [min, max] angle to be [-pi, pi], and I would expect there to be a ray return at [min, max] inclusive. So that means we have Now, how should pointcloud_to_laserscan translate a pointcloud into this format? The tricky thing is that for a hardware LIDAR, each return has a negligible FOV, and therefore a small obstacle could actually 'slip' through the cracks between rays. This is not what we try to do here, since I believe users generally want to capture all information in a pointcloud regardless of size. In the practical case, this probably leads to all sorts of questionable behaviour when this 'laserscan' is then used in say, the navigation stack. A user probably wants to make sure that If we assume each bucket captures an equal angle_increment, the min and max bucket will capture obstacles So this brings us to:
|
The way I addressed this in my PR, is by maintaining separately the valid angle range (currently with an exclusive upper bound: For example, when we configure an angle range of So far, I did not add an option to directly configure the output angles and the increment that will appear in the Also, as already indicated, in my implementation, the upper bound of the angle range is currently exclusive, for not having to check that edge case in the index calculation here. While this shouldn't make a difference for a 360° scan, this might become a problem when an entire column of the input cloud is ignored because the user specified the exact maximum angle of their sensor as an upper bound in the value range. Not sure how floating point accuracy (transforming spherical to Cartesian to polar coordinates) will mess up this exact boundary anyways though. |
It seems that either you should also skip angles that equal the value of
angle_max
here:Or make the number of range readings one item larger here:
Otherwise you'll have an out-of-bounds array element access when one day there is an angle of the value
angle_max
.Note that I have posted a question here about how many values the sensor_msgs::LaserScan should actually contain, because I'm not sure if
angle_max
really is supposed to be excluded from the range of values.The text was updated successfully, but these errors were encountered: