Decoding mavlink messages

Hello all,

I wanted to have the APM 2.5 board connected wirelessly to the ground station laptop, whilst having an on-board beaglebone intercept the telemetry data being sent, for use in gps location estimation.

Currently the apm connects wirelessly via xbee to the ground station, and i have found i can tap away the serial data being sent to the ground station (connected the gnd and tx pins of uart0 to my gnd and rx pins on arduino)

My problem is decoding the mavlink messages being sent. I have searched quite a lot on google and have found various things such as pymavlink and others, but my question is whether or not there is an easy way to decode these messages? The code examples i have seen are not at all simple, as they connect to both send and receive mavlink messages, whereas i just want to tap away what gets sent and deode it. 

I found an example which can read in the byte stream and seperate it into the various mavlink messages, but i still need to deocde this. Would it be worth trawling through the code of the mavlink examples out there to find the decode functions? Do you know anywhere i can find an example of decoding the byte messages?

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

Join diydrones

Email me when people reply –

Replies

  • I have a similar project and was able to find a solution by coding my own VBA.  I wanted to capture both the pitch,roll, yaw data and GPS as well and feed to a separate terminal window. I can see the stream data from APM in various terminal programs and they only decode the Unicode character equivalent of each byte octet.

    My solution was to feed the data stream directly into Excel and then use VBA to decode. I transformed Excel into a rudimentary ground control station and then use the Excel features to further process and graph the APM data.  I used the common.xml file from MavLink to find the appropriate data stream ID for GPS and Attitude(with Roll, Pitch and Yaw). Hex 21 and 33 respectively.

    The data stream ID you want to capture is ID 33 decimal from the common.xml file or 21 hexadecimal.  Flag and filter out "FE" and "21" from the octet stream. FE is the header and 21 is the message ID for the GPS stream. The format of the data is in the fields as described in the common.xml file.  The data (payload bytes) usually comes in IEEE 754 float expression in 32 bytes or integer data in Uint8,16 or 32. The data type for each message field is described in the common.xml.  Also, the payload data comes in "little endian" format so the byte order is reversed. If you know C or VBA this is a fairly easy project. Just remember the payload data is stored backwards.

    Here is an example of a GPS data stream packet, first 10 bytes or so. FE is the header, 16 the # of bytes in the payload (the data you want to intercept). 61 is packet #, which resets after 255, 01 x 2 is the system components, 21 is the message ID in hex for the GPS data. The next bytes are the payload.

    "FE 16 61 01 01 21 E9 A2 01 E3 ..........."  payload sequence  "E9 A2 01 E3" should look like this "E3 01 A2 E9" before decoding.

    There is also a wealth of other data in the APM data stream that you can capture and use. Such as temperature, ground speed, voltage, current, waypoint data, etc.

  • Developer

    I'd recommend looking at the code used in the jdrones io board or the minimOSD.  Both of those read the stream and decode some messages from it.

    jD-IOBoard v1.0, MCU controlled IO Board for driving LEDs, Relays, Servos
    R/C UAV and ArduCopter manufacturer and one stop shop. We make your FPV come true.
  • I'm a little unsure of how mavlink exactly works, would using the mavlink generator to get the c++ code provide enough to decode the stream?

This reply was deleted.

Activity