ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A answers.ros.org

# Distance between two robots in gazebo?

Is there an easy way to calculate the distance between two robots in gazebo?

If you have, for instance, the names of both robots, I would then like to be able to have a function which would allow me to easily calculate the minimum euclidean distance plus distance vector between the visual meshes of the two robots.

Is there something like that already implemented?

The distance between a point and a robot would be even better.

I've looked online and was not able to find anything useful, except the pointer to the fcl library. Is that really the only way to go?

edit retag close merge delete

Sort by ยป oldest newest most voted

If you spawned the robots from urdf/xacro files through gazebo_ros_pkgs the two robots should have positions in tf that you can query with standard tf transform lookups, you can get an xyz distance to one robot in the frame of the other robot, and then you can get the L2 norm to get the distance.

An easy way to see if the tfs exist is to launch rviz and start a tf plugin.

If the robots aren't brought up through ros try http://answers.gazebosim.org .

more

I knew about that, but have the problem that I want the minimal distance between the two robot models. Meaning the distance from one visual model to the other. I think I'll ask the question again on the gazebosim site, since I believe that fits the problem better. Thanks for your answer anyway.

( 2016-04-20 12:49:42 -0500 )edit

Like the closest distance between the surface of the meshes? That sounds involved... like you need to get access to the mesh vertices, transform them into a common frame, and then search through them (ideally not brute force) and calculate distances between pairs.

( 2016-04-20 14:13:05 -0500 )edit

And I see that is what https://github.com/flexible-collision... does. So you'd have a node getting the transforms from tf, then feeding that info into fcl which would have independently loaded the meshes. If ode/bullet can do it maybe a gazebo plugin could access that.

( 2016-04-20 14:16:27 -0500 )edit

Yeah that's exactly what I want to do and the idea I had. I just wanted to ask if there is something like that already implemented, so I wouldn't have to deal with that mess. But looks like I'll have to implement it on my own.

( 2016-04-20 14:35:04 -0500 )edit