Gazebo | Ignition | Community
Ask Your Question

Is there a library or function for calculating distance/angles between models?

asked 2015-12-15 14:01:36 -0500

lucas gravatar image

I need to calculate the real, not estimated, distance and angles between two models in Gazebo. I need to know what angle the second model is in the z and y direction from the first model, using the first models orientation.

To better explain with an example of what I'm doing, if I have a quadcopter with a camera facing in any direction, and there is another model in the camera, what is the real angle between where the quadcopter is currently facing and the object in the left/right direction of the camera and what is the real angle between where the quadcopter is currently facing and the object in the up/down direction of the camera.

This is for comparison purposes to angles estimated from the image taken from the camera. I need them to be as close to exact as possible.

I was hoping there was already some package or functions for this. I looked at the gazebo/math directory, and I see some functions there to help with the calculations, but not one that does the complete calculation of angles/distances between two given positions/orientations.

So, are there any packages/functions that do that? Or, will I need to figure out the calculations from scratch?


edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2015-12-16 10:56:40 -0500

nkoenig gravatar image

The angle between angle between two 3D positions around a specific axis can be found with:

For yaw(about Z-axis) atan2(dx, dy)

For pitch(about Y-axis) atan2(dz, dx)

where dx, dy, and dz are the distances between the two models along the respective axis.

You should check that math.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2015-12-15 14:01:36 -0500

Seen: 248 times

Last updated: Dec 16 '15