ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Filtering laser scan data - Remove NaN

asked 2015-03-22 15:31:51 -0600

musiqsoulchild gravatar image

Hi,

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

Thanks!

edit retag flag offensive close merge delete

Comments

1

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

vbs gravatar image vbs  ( 2018-07-26 08:32:10 -0600 )edit

Did anyone find an answer?

cantolini gravatar image cantolini  ( 2022-08-23 11:20:47 -0600 )edit

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.

ravijoshi gravatar image ravijoshi  ( 2022-08-24 01:20:01 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-08-23 11:41:17 -0600

vbs gravatar image

updated 2022-10-22 11:35:28 -0600

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.

edit flag offensive delete link more

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.

fandrade gravatar image fandrade  ( 2022-10-20 12:54:52 -0600 )edit
1

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? :).

vbs gravatar image vbs  ( 2022-10-22 11:54:22 -0600 )edit

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.

fandrade gravatar image fandrade  ( 2022-10-26 08:53:43 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2015-03-22 15:31:51 -0600

Seen: 2,740 times

Last updated: Oct 22 '22