ros-perception / depthimage_to_laserscan

Converts a depth image to a laser scan for use with navigation and localization.
243 stars 163 forks source link

Out of range become nan instead of inf. #61

Closed TeerapongPoom closed 2 years ago

TeerapongPoom commented 2 years ago

I read in the wiki https://wiki.ros.org/depthimage_to_laserscan and it says ranges less than range_min will be output as -Inf and +Inf for range_max. When I try with range_min=0.3 and range_max=4.0, all values not in range become nan. Here is message from rostopic echo https://drive.google.com/file/d/1YSh61ATBp4Xuy6y_YcDfNicW1LBbvW1E/view?usp=sharing

But this is the result after I increase range_max to range_max=10.0 https://drive.google.com/file/d/1Vnczgholi2ksoAOVkHGeTYrr4JSMgLlA/view?usp=sharing

My sensor is realsense d455 and depth image encoding is 16UC1. ROS distro in noetic. This is how i call node in launch file.

TeerapongPoom commented 2 years ago

nvm. I just add

if(r > scan_msg->range_max){
  scan_msg->ranges[index] = std::numeric_limits<float>::infinity();
}

to line 208 in DepthImageToLaserScan.h and it works now.

nakai-omer commented 1 year ago

@TeerapongPoom This is an important bug, that breaks costmaps in nav2. I think it should be reopened so it will be fixed for everyone.