Robotics StackExchange | Archived questions

Filtering laser scan data - Remove NaN

Hi,

Does anyone know how to filter out /scan topic data to remove NaN?

Thanks!

Asked by musiqsoulchild on 2015-03-22 15:31:51 UTC

Comments

I know it's an old topic, but did you find an answer to this?

Asked by vbs on 2018-07-26 08:32:10 UTC

Did anyone find an answer?

Asked by cantolini on 2022-08-23 11:20:47 UTC

Remove NaN should not be difficult. Would you please share a sample message by executing rostopic echo /scan on terminal? Ideally, if you are on Python, NumPy can be used.

Asked by ravijoshi on 2022-08-24 01:20:01 UTC

Answers

For my work, I ended up filtering the values offline, during data pre-processing after recording with rosbag.

If you are using python and numpy, this is as simple as scan[np.isnan(scan)] = max_range.

For altering the values online, an option would be to use the InterpolationFilter of laser_filters.

Asked by vbs on 2022-08-23 11:41:17 UTC

Comments

Hi, vbs. As far as I know, nan values could mean max_range (clean view) or min_range (obstacle two close). So, I think you need something else for your solution.

Asked by fandrade on 2022-10-20 12:54:52 UTC

Hi fandrade. It was a valid assumption for my problem. Due to the high density of the laser-scans compared to the size of the obstacles I was dealing with, if an object got closer to the robot than min_distance it would be picked up by neighbouring readings of the scan anyway, thus not affecting my path planning algorithm. So it was safe to keep it simple and map the invalid reading to max_distance. More robust solutions would be to use an interpolation filter, as I mentioned in my answer, or a "valid average", where you just replace the invalid readings with the average value of their neighbouring readings that are not-NaN (or should I say aN? :).

Asked by vbs on 2022-10-22 11:54:22 UTC

Hi vbs, I think you found a nice solution. I am still dealing with this problem because I am only using 5 laser beams as the input of a deep neural network, where I am doing reinforcement learning, so when beams come with NaN, I cant figure out a way to interpolate o set a min/max value.

Asked by fandrade on 2022-10-26 08:53:43 UTC