Servers by jDrones

Mission Planner and Antenna Tracker

(Aleksandar Tsankov) #1

Hi there!
This is my first topic here so excuse me if I’m doing a mistake or something.
It is mostly directed to Mr. Obourne - I tried to send a PM but it’s not possible to do this, at least at the moment, that’s why I’m opening this topic.

Recently we (I and my friends) decided to create an Antenna tracker guided by MP. Since I wasn’t able to find enough information about protocols used for communication between MP and different boards used for commanding the servos for antenna direction, I downloaded the MP source code and started to learn it.
Well, I’m not a C# coder at all but the syntax is similar to those of some other languages and I thought I would find what I needed.
In the file Maestro.cs I found the subroutines for communication with Maestro boards and in ArduTracker.cs I found the format for communication with APM Antenna Tracker.

However, no matter how hard I looked at, I couldn’t find the subroutine for conversion from cartesian to polar coordinates (which I think is crucial for antenna direction).

OTOH, in the file Tracker.cs I found a subroutine called tm1_Tick which deals with finding the best value of local radio’s SNR and corresponding angles. Directing antenna based on maximum of digital radio’s SNR is not the best approach according to me.
And since the antenna direction is flawless according to our tests with recorded flights I’m even more puzzled where is located the “secret” ^^ code for its commanding.

And some more things - during the lurk at the source code I stumbled upon the following lines:

in file Maestro.cs:

    void getCenterPWs()
    {
        byte[] buffer;
        // set all to home (center)
        SendCompactMaestroCommand(GoHome);

        //HERE!!!!!!!!!!!!!!!
        while (SendCompactMaestroCommand(GetState, 1)[0] == 0x01)
        {
        }

        // get center position -- pan
        buffer = SendCompactMaestroCommand(GetPos, 2, PanAddress);
        this.PanPWMCenter = (int) ((buffer[1] << 8) | buffer[0]);

        // get center position -- tilt
        buffer = SendCompactMaestroCommand(GetPos, 2, TiltAddress);
        this.TiltPWMCenter = (int) ((buffer[1] << 8) | buffer[0]);
    }

byte[] SendCompactMaestroCommand(byte cmd, int respByteCount = 0, byte addr = 0xFF, int data = -1)
{
byte[] buffer;
if (addr == 0xFF)
buffer = new byte[] {cmd};
else if (data < 0)
buffer = new byte[] {cmd, addr};
else
buffer = new byte[] {cmd, addr, (byte) (data & 0x7F), (byte) ((data >> 7) & 0x7F)};
ComPort.DiscardInBuffer();
ComPort.Write(buffer, 0, buffer.Length);
if (respByteCount > 0)
{
buffer = new byte[respByteCount];
//HERE!!!
while (ComPort.BytesToRead < respByteCount)
{
}
ComPort.Read(buffer, 0, respByteCount);

        }
        return buffer;
    }

As I already declared, I’m not a C# coder but these lines look strange to me.
So I’ll be thankful if Mr. Obourne or someone else answer to my questions.

Regards
Alex

(Michael Oborne) #2

here is the code that gets the AZ and tilt to send to the tracker

code to get the AZ to the mav

and code to the the tilt to the mav

(Aleksandar Tsankov) #3

Hi Michael,
Now it’s clear, thank you. I assumed that the code for conversion from cartesian to polar coordinates should be in Tracker.cs and was puzzled why it is missing.
BTW, what is the purpose of tm1_Tick function (in file Tracker.cs)?