Ask Your Question

Calculate azimuth and elevation angles

asked 2016-03-21 19:09:39 -0500

tn0432 gravatar image

If I have two frames: /parent and /child. I can use tf:lookuptransform to find the transformation between two frames. Now, I want to find the azimuth and elevation angles in spherical coordinate between two frames. Do ROS have any available function to do something like that?


edit retag flag offensive close merge delete


How would you define the azimuth and elevation angles "between two frames"? They give you 2DOF and a generic 3D transformation would need 6DOF...

al-dev gravatar image al-dev  ( 2016-03-21 19:55:52 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2016-03-23 08:14:38 -0500

kramer gravatar image

No, to my knowledge ROS doesn't make those methods available.

You need to better define what between two frames means, though. Assuming you can treat Frame1 as the origin (that is, position (x,y,z)=(0,0,0) and orientation (x,y,z,w)=(0,0,0,1)), calculating the azimuth/elevation to another frame can be accomplished using only Frame2's relative-to-Frame1 (x2,y2,z2) location:

magnitude = sqrt((x2*x2) + (y2*y2) + (z2*z2));
azimuth   = atan2(y2, x2);
elevation = asin(z2 / magnitude);

Note that angles should be normalized to -M_PI <= val < M_PI.

If you're going to be working with spherical coordinates, two sites I've found invaluable are Aviation Formulary and Calculate distance, bearing and more between Latitude/Longitude points.

edit flag offensive delete link more

answered 2016-03-22 04:55:52 -0500

Hi There,

You are trying to convert a quaternion representation used internally by ROS into Euler angle representation. I'm assuming you don't care about the translation element or the roll element of the transformation. Azimuth and Elevation are often used to describe the 'direction' to something, this can also be achieved with a TF albeit with a fair amount of redundancy.

The tricky thing about Euler angles is that they can be applied in different orders to get different results. For example rotating 10 degrees around X then Y then Z results in a different effect than 10 degrees about Y then X then Z.

You'll need to work out which order of rotations will give you the Azimuth and Elevation you require.

The KDL Library can convert quaternions into various different Euler angle representations. If you don't want to get stuck in and work it out from scratch.

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: 2016-03-21 19:09:39 -0500

Seen: 3,178 times

Last updated: Mar 23 '16