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

How to get the minimun ditsance from an obstacle

asked 2011-09-07 22:13:22 -0500

erpa gravatar image

updated 2014-01-28 17:10:21 -0500

ngrennan gravatar image

Hello, I'm working with gazebo and I would like to detect the minimum distance between my robot and an obstacle. The model of the robot is an urdf file. What is the best sensor to use? How do I "attach" it to the robot and how do I get the data? Thanks.

edit retag flag offensive close merge delete


Do you need 2D range data or 3D? What's the application?
ben gravatar imageben ( 2011-09-07 22:24:35 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2011-09-07 23:13:21 -0500

The first thing you need is to segment out the obstacle from the other objects in the environment. This might or might not be tricky, depending on the environment and the sensors you want to use.

You can either use a laser or a generic pointcloud (coming from a stereo/range camera or a tilting laser). The latter is the most generic and you can always convert a laser message to a pointcloud. However if you are interested in a gazebo simulation only, then a laser will be easier.

Then for every point in the pointcloud, you can transform it to the coordinate system you prefer (e.g. for the PR2 it would be baselink) and a simple euclidean distance will give you the answer.

If you are using the laser only, then the minimum in the range field of the laser message will give you the closest point.

edit flag offensive delete link more


Hello. Im trying to do the same with a laser. I wont to know how to work with straight lines in laser scan massages. Because the points on the longest straight lines is likely the wall and point not on the longest straight line the msg are likely on the other object. Any help??

Astronaut gravatar imageAstronaut ( 2013-06-30 18:59:26 -0500 )edit

@Astronaut you should post this as a new question, and check if somebody has not asked the same before. Your problem is very common, I bet you'll find a solution.

Lorenzo Riano gravatar imageLorenzo Riano ( 2013-07-09 13:17:45 -0500 )edit

answered 2011-09-08 22:58:30 -0500

SAK gravatar image

As you havent provided details of your robot, i will tell you about adding a sensor in pr2. The physical sensor can be added in pr2 by using xacro file. In pr2 you can add sensors in head, torso and base.

But if you want to add a new sensor, (IR and Sonar) which are currently not available, you need to create them from scratch.

The process of creating a new sensor is not simple, i am working on it and finished it, it will be soon made public after testing repeatedly.

Now the available sensors are bumper (Contact sensors) and laserScan.

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


Asked: 2011-09-07 22:13:22 -0500

Seen: 499 times

Last updated: Sep 08 '11