# Coordinate transformation for antenna pointing

I may have bitten off more than I can chew with some coordinate transformation math. As a background, I'm working on a project where we need to mechanically point an antenna to a receiving tower. The goal is for the antenna "structure" to be placed at any location in the terrain, and we have enough sensors and servos to point to the receiving tower. We have GPS positions of both locations, so we can generate a North-East-Up coordinate system centered at the structure and flat to the ground. The structure is installed with roll and pitch sensors, and we have a turn-table motor for control over yaw. Here's my attempt at a picture:

On top of the turn-table is a mounting arm that is positioned at a 22 degree angle relative to the flat part of the turn-table. Installed on this arm is an El-Over-Az mechanical servo that controls the antenna angle relative to the mounting arm (I think it's considered el-over-az since moving the elevation motor does not affect the azimuth angle)

So the ultimate goal is to use all the information given to decide how much to steer the servo azimuth and servo elevation in order to have the antenna pointed directly at the receiving tower. Even though we have the turn-table yaw motor, I won't have direct control over this: I can only use the information about the yaw position.

The convention for all rotations is that clockwise is positive and counter-clockwise is negative.

Since it sounds like order matters when doing 3D rotations, I asked the manufacturer of the roll/pitch sensor what the order should be, and they responded with: "the basic sensing principle for the MEMS is that of a pendulum. The outputs (x,y, and z) of the individual elements will follow g x sin phi, where g is the acceleration of gravity and phi is the tilt angle with respect to the horizontal. Internal to the device is the arc-sine function which converts the tilt angle directly to degrees as the output. Since the sensor is responding to the orientation with respect to the gravity vector, order shouldn't matter. Roll and pitch are completely independent of each other."

I tried to draw a picture of this too:

Would someone be able to lend a helping hand and figure out the correct sequence of coordinate transformations?

Here is my progress: So I think the first rotation needs to be pitch and roll, simultaneously. I think simultaneously because the manufacturer described the sensor as "independent" and "order doesn't matter". So to do this, I derived the rotation matrix using unit vectors. Starting with the North unit vector and rotating in the pitch direction (p = "pitch" and r = "roll") :

I take this result and rotate in the roll direction:

I get my first column of the rotation matrix. I repeat these steps for the East unit vector:

And finally the U unit vector:

I get the rotation matrix that transforms from a flat earth reference frame to a rolled/pitched reference frame (adding the extra row/column in anticipation of needing translation matricies later) :

So the application would be:

Since the turn-table rides on top of the rolled/pitched platform, the next rotation will be to rotate in yaw. I can create a separate rotation matrix for this because the rotation is relative to the newly rolled/pitch reference frame (not the original flat earth frame). I just look up a u-axis rotation matrix (y = "yaw"), polarity slightly adjusted for positive-clockwise convention:

So multiplying the two rotation matricies will transform from the flat-earth reference plane, to the rolled/pitched/yawed reference plane:

So now I need to translate along the U'' axis to account for the height between the ground and the mounting arm (height of 'h'). This is a translation matrix. I believe I need to translate by the negative of h to make the tower coordinates appear closer to the new origin.

So now I need to rotate about the E'' axis to account for the 22 degree angle between the holding arm and the turn table. I want to rotate until the U'' axis is parallel with the arm which will also make the N'' axis become the "normal" line drawn in the image. This would mean I need to rotate counter-clockwise by 90-22 degrees = 68 degrees = 1.18682 radians

The application up to this point will be:

So I can now use the coordinates in the new reference plane and do some 3d trig to calculate the azimuth and elevation from this point (cartesian to spherical). I stick to the positive-clockwise convention for azimuth, but switch positive elevation being counter-clockwise, as this seems more intuitive for "up" being a more positive elevation.

And it is at this point I get stuck. I think the problem is that the servo az/el axis are dependent: One rides along the other. How do I figure out the appropriate amount of servo az and el?

• While GIS could certainly be used to solve this problem (known as the Inverse (or Reverse) Geodetic Problem), you don't seem to be using it. If you are, please edit the question to explain what you have tried and what difficulty you encountered. Commented Jun 12, 2020 at 13:14
• Could you define exactly on which rotations you are going to act, and these rotations are around which axes? In the last image it seems that you mention the roll as if it were on the Up axis. And also I suppose that you are going to act only on two rotations, that's why the question. Commented Jun 12, 2020 at 18:40
• Sorry. I updated the last image to just use "phi" as the manufacturer described it. I'm just trying to visualize how the sensor works. I think roll is derived from phi, so that is what was confusing about the original image. I am working on organizing my notes to show my attempt at a solution Commented Jun 12, 2020 at 18:55
• @SittinHawk, I think you're getting complicated. The variables you are looking to determine are azimuth and elevation? The only transformation you need to do is from Cartesian to 3D polar coordinates. Commented Jun 12, 2020 at 21:55
• It's not just azimuth and elevation from the ground, it's azimuth and elevation of servo motors at the top of a tilted structure, with an angled mounting arm. Commented Jun 12, 2020 at 21:59