Can somebody please explain MAVlink?

I'm working on a project where I must send commands from a smart phone to the APM. I have been reading about MAVlink commands but I am very confused what the purpose of them are. I read here https://code.google.com/p/ardupilot-mega/wiki/MAVLink that the APM uses this set of MAVlink commands. Can I write code to simply build the command and send it to the APM via serial? Or must I use the MAVlink library to build the commands?

You need to be a member of diydrones to add comments!

Join diydrones

Email me when people reply –

Replies

  • Hi shyam, I have been trying to utilize this code but it does not seem to be working. I am currently using the c_uart_interface_example code . Specifically the mavlink_serial.cpp. I am just getting the heartbeat messages:

    Received message from serial with ID #0 (sys:1|comp:1):
    Received message from serial with ID #0 (sys:1|comp:1):
    Received message from serial with ID #253 (sys:1|comp:1):
    Received message from serial with ID #253 (sys:1|comp:1):
    Received message from serial with ID #0 (sys:1|comp:1):
    Received message from serial with ID #0 (sys:1|comp:1):
    Received message from serial with ID #0 (sys:1|comp:1):
    Received message from serial with ID #0 (sys:1|comp:1):

    I think the reason its doing that is because there was no request stream. So included the following line:

    mavlink_msg_request_data_stream_pack(127, 0, &message, message.sysid, message.compid, MAV_DATA_STREAM_RAW_SENSORS, 1, 1);

    It is still not working. I am new to MAVLink and its difficult to decipher whats going on. Any help is highly appreciated.

    Thanks!

  • Developer
    The wiki article isn't valid for MAVlink 1.0.

    The MAVlink library is a code only library, you can grab the source for the APM from the repository. This will be easier. You can then just call the correct functions to make the packets you want to send.

    What isn't clear to me yet is the heartbeat timer. There is a requirement for the UAV to send the heartbeat packet periodically. On the GCS you can monitor the heartbeat packet sequence number and determine packet loss statistics, the mode the UAV is in. I'm not clear if this packet needs an ack sent to the UAV.

    If the above is true, you will most likely need to create a message loop to process the ACKs that need to be sent on the GCS. If not you will be able to send the correctly formatted sequence of bytes over serial alone.

    I'll post more info as I figure it out

    https://code.google.com/p/ardupilot-mega/source/browse/#git%2Flibra...
  • Hi,

    It takes some time to fully understand MAVLink, that's normal.

    You can use the code generator that is in the official MAVLink distribution: http://qgroundcontrol.org/mavlink/pymavlink .It will generate nice C code that has structs for all messages, and can read and write messages to/from a serial or other stream.

    You don't have to use that code. You can also write your own. But using the C code from the generator will save you potentially a lot of trouble. It just works..

    Regards

    Soren

This reply was deleted.

Activity

Neville Rodrigues liked Neville Rodrigues's profile
Jun 30
Santiago Perez liked Santiago Perez's profile
Jun 21
More…