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

Range sensor does not detect objects in gazebo

asked 2018-05-20 14:11:10 -0500

Joep gravatar image


I am new to ROS and try to create an urdf file to represent my robot in rviz and gazebo, but I can't get the range sensor to detect objects in the simulator. The message at /arduino/sensor/ir_left always reports 3.75 as range, which is the maximum. For test, I added a gpu_ray scanner and that shows the object just fine in rviz. Spinning the robot in place doesn't help either, so it's doesn't seem to be the sensor angle.

What's wrong? Or any suggestion on how to debug this further?

The sensor definition is below.


<gazebo reference="ir_left">        
   <sensor type="ray" name="ir_leftabc">
      <pose>0 0 0 0 0 0</pose>
      <plugin filename="" name="gazebo_ros_range">
edit retag flag offensive close merge delete


If you want to use GPU laser plugin the filename of this plugin is called IMO instead of The library should be saved in /opt/ros/kinetic/lib location. Try to run gazebo in verbose mode to see if the plugin is loaded or not.

l4ncelot gravatar image l4ncelot  ( 2018-05-21 04:06:44 -0500 )edit

Btw this is ROS related forum. For the future post Gazebo related questions here.

l4ncelot gravatar image l4ncelot  ( 2018-05-21 04:07:48 -0500 )edit

Also the type of sensor should be gpu_ray instead of ray.

l4ncelot gravatar image l4ncelot  ( 2018-05-21 04:10:29 -0500 )edit

@i4ncelot - thanks for your reply! I'm trying to create a sensor_msgs/Range topic, not laserscan. Laserscan works okay. Tried to check the gazebo log at the location shown in the launch window. There are a few logfiles there, but none with gazebo in the name or with 'laser' or 'ray' in it.

Joep gravatar image Joep  ( 2018-05-21 09:26:08 -0500 )edit

My bad, I thought you wanted to use the gpu_ray sensor. I've tried your model and it works for me just fine when I subscribe to /arduino/sensor/ir_left topic. Can you edit your question with the launch file you use? Have you tried to launch gazebo with verbose option?

l4ncelot gravatar image l4ncelot  ( 2018-05-22 02:43:58 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2018-05-22 02:36:30 -0500

R. Tellez gravatar image

Hi Joep, I think I found what happens to your range ray. The configuration is correct but it is very likely that due to the way that you have created your robot, the range is colliding against itself. Either it is colliding against the collision mesh of the sensor itself or either against the body of the robot. I cannot say which one because you did not publish the whole URDF.

Anyway, I created a video about how to detect that. Check it out here:

edit flag offensive delete link more


Wouldn't the sensor report something like ~0.05 range when colliding with itself as shown in your video?

l4ncelot gravatar image l4ncelot  ( 2018-05-22 02:59:38 -0500 )edit

Oh... if he has the collision box around the sensor greater than the max range it will return exactly the max range. I see it now.

l4ncelot gravatar image l4ncelot  ( 2018-05-22 03:03:45 -0500 )edit

Yes l4ncelot. You can see at minute 6:24 of the video how the rostopic echo is providing exactly that value, reporting the collision with itself

R. Tellez gravatar image R. Tellez  ( 2018-05-22 05:41:18 -0500 )edit

Hi Ricardo, thank you so much for your video. Very informative. Add it shows my code could work! However this is not the same issue. My sensor always reports 3.75 as range, which is the maximum. Is your robot model available for download? Would love to find out the differences with mine.

Joep gravatar image Joep  ( 2018-05-22 12:52:52 -0500 )edit

The simulation is of the ROS Live Class that we do every Tuesday 18:00CEST online (open to anyone ). In order to get it, create a free account at and afterwards, click this link: That will copy my project to your RDS account.

R. Tellez gravatar image R. Tellez  ( 2018-05-22 13:53:58 -0500 )edit

answered 2018-08-09 21:28:28 -0500

FerdeLance gravatar image

Just adjust the minimum value of the range sensor to match the collision box. In this example I changed the min range to 0.1.

edit flag offensive delete link more

Question Tools



Asked: 2018-05-20 14:11:10 -0500

Seen: 3,811 times

Last updated: Aug 09 '18