ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

LaserScan gives nan data to close round or sharp cornered objects

asked 2021-07-12 09:59:04 -0500

Yokai- gravatar image

Quite new to this was toying with Turtlebot GMapping on ROS Kinetic when I encountered this error.

According to the topic description, any distance above 10 m will be referred to as nan. But while simulating, the msg.ranges[300], which refers to the front , gives nan value, especially if the object is round or has cylindrical surface.

I changed the logic, so that on such occurrence, it keeps rotating. But the RViz map gets severely distorted, as it estimates the value at infinity or very far. How do I fix that?

RViz map distortion: Node:

edit retag flag offensive close merge delete


On I see parameters ~maxRange and ~maxUrange. Have you set them to reasonable values?

Mike Scheutzow gravatar image Mike Scheutzow  ( 2021-07-12 18:53:48 -0500 )edit

Also, could you please clarify if this is an issue with gmapping or if those are the actual values that get reported by your laserscanner? If yes, which laserscanner are you using (model, simulated)?

mgruhler gravatar image mgruhler  ( 2021-07-13 04:07:14 -0500 )edit

@Mike Scheutzow, I'm using the gmapping_demo provided by the turtlebot tutorial, which has a max range set to 80 m by default. But the issue is with LaserScan which gives the distance of very close round objects as nan (>10 m). Even if I'm not using the turtlebot_gazebo gmapping_demo.launch file, the LaserScan alone gives faulty results

Yokai- gravatar image Yokai-  ( 2021-07-13 05:22:53 -0500 )edit

@mgruhler, I see no issue with GMapping, the LaserScan is providing faulty nan values. As for the laserscanner sensor used by the model is "360 Laser Distance Sensor LDS-01", according to

Yokai- gravatar image Yokai-  ( 2021-07-13 05:27:28 -0500 )edit

I'm confused. Are you running in simulation (gazebo) or a real robot with a real sensor?

mgruhler gravatar image mgruhler  ( 2021-07-13 06:11:23 -0500 )edit

@mgruhler , sorry for not understanding earlier. It is a simulation.

Yokai- gravatar image Yokai-  ( 2021-07-13 06:25:29 -0500 )edit

I have not run this particular simulation, but why are you surprised that a nan clears out the map up to 80 meters? You have told gmapping that the laser data is reliable out to that distance. Also, be aware that you can get nan in the real world because not every surface cleanly reflects the laser beam back to the lidar.

Mike Scheutzow gravatar image Mike Scheutzow  ( 2021-07-13 06:57:56 -0500 )edit

@Mike Scheutzow , I have no issues with nan clearing out the map. My issue is that the laserscan gives nan data for objects as close as 1 m from the robot, which is incorrect. This happens especially if the object is cylindrical. Maybe I failed to clarify my question. Sorry for that.

You can find the snap shot here :

Yokai- gravatar image Yokai-  ( 2021-07-13 07:05:44 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2021-07-13 07:16:38 -0500

Mike Scheutzow gravatar image

updated 2021-07-13 08:09:40 -0500

All lidars have a minimum range. Objects closer than this distance usually return either 0 or NotANumber (nan).

To get optimal results, you must properly configure gmapping for the sensors you are using. Getting a nan sample from a lidar is normal and means "no light bounced back." gmapping will interpret this value as "no obstacles out to maximum range" for that ray.

If you move the robot to a new pose, it may then see an object that was previously not visible.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2021-07-12 09:59:04 -0500

Seen: 2,452 times

Last updated: Jul 13 '21