I'm sharing with this community about my project's experiments which has for an objective to write (i.e. set = modify) a parameter (i.e. parameters we can see in the full parameters list in mission planner) using Mavlink.

You're now thinking : what a stupid objective, just use a GCS like mission planner to write your @#{{ parameter!

Well, no, I want to build an excel pre-flight checklist; within this checklist I'd like to see a list of all of the failsafe parameters of my multirotor AND be able to change their values (for example by clicking on a write button on this Excel checklist). Indeed none of the available GCS software is practical to do just that : you have to click and navigate through dozens of screens to get to all of these parameters I want in my checklist. Just unusable. Therefore I decided to try to build this in a typical DIY way.... It would also be a good Mavlink learning experience.


You may think: so what ? just use available libs or APIs and it's done. Yeah right, so I thought too naively in the beginning....

What I found is that Mavlink is the most complex contraption I have rarely met. Not only is  the standard awfully complex, but there is absolutely no material available on the web that would qualify seriously enough as "documentation" (developers tend to think that documentation consists in their comments within the source code, and that is only valid when they write comments in their source code...). The complexity of this standard comes from the fact their inventor(s) wanted something totally generic, for any kind of UAV and for any kind of parameters and any kind of control messages (it even cares for creating your own set of parameters/messages). Another reason for the complexity of Mavlink is the choice they made to partition the information in hundreds of different small compartments/files/scripts. So it makes it very very hard to get an bird's eye view on it and to understand what links what.

About documentation, the only data I found  (I did visit dozens of web pages and various  links about Mavproxy, about drone api, about Mavlink, about pymavlink, etc) were parcellar, very short pieces of information. Impossible to find a synthesized, clear overview of how to program concretely with Mavlink. Not even a single code example to show how to write a parameter via Mavlink from A to Z, not a single example ! However you will find tons of much more complex code examples such as fully functional GCS software. I did do a thorough information collection searching for similar topics on this forum and posting some help requests... without joy.

The least undocumented I found was Mavproxy, on a few web pages written by Tridge. However Mavproxy is a GCS software that is meant to be used with a human-machine prompt interface, on which you type in commands. You can't use it (or I did not find how, which prove how bad documentation is) for programming commands to be executed automatically (without a human typing something on the Mavproxy prompt). That is thus not usable for my project; however I decided to start from MavProxy to see if I could reverse engineer it, decrypt it  (I felt like Champollion and his Roseta stone) and reduce it to the bare minimum needed to just "set a parameter value" via Mavlink.


Not being a developer, not knowing even the python programming language (I had to look up wikipedia to know what a "class" means), I did what an engineer does best : a logical analysis on the Mavproxy source code and all of its dependencies (libs, modules) and lots of trials and errors. This allowed me to identify how the libraries and modules were linked to each other , via which classes and functions and variables to write a parameter to Pixhawk via Mavlink.  Disclaimer : it is probably very much incomplete or even incorrect but I reached my wished result.

The result is the scheme above which attempts to provide a synthesized overview of how the different python libs/modules/functions interact to simply write a parameter to Pixhawk via Mavlink. An immediate conclusion of this is how ridiculously complex Mavproxy & Mavlink are (the base from which I derived a modified python program that does what I want). It even more so ridiculous when you think that all of this boils down to just writing a few bytes to a COM port ! (I'm afraid that some guy(s) in ETH Zurich university did make things complex to justify their PHD)

My practical test bench was a pixhawk connected via USB on a COM port of my windows laptop. I installed Win python, pymavlink, Mavproxy. For testing the thing, I chose to change the value of the CIRCLE_RADIUS parameter. AND IT WORKED ! Alleluia. (<= this is a joy manifestation of succeeding doing something stupidly simple starting from an insanely complex contraption, i.e. Mavlink/Mavproxy).

I provide my modified python script ( in annex for those who want to join me in the simplification fight for programming Mavlink !

Please, developers, be kind in your eventual reactions...I'm certainly a very bad developer but you're as bad documenters;)

Hope this will also help eventual other DIY'ers playing with Mavlink.



File attached :

E-mail me when people leave their comments –

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

Join diydrones


  • Same here Hugues - I have come across methodologies and software like this before and am currently struggling with documentation now.  This is almost 4 years later and there are actually a few examples that look like they work out there but still nothing definitive in doing a SET_PARAM, especially a compound one like DISTANCE_SENSOR.

    My favourite part about you writing the python - which I haven't tested - after saying "you're as bad documenters;)" is the scant documentation you yourself employ to taunt the original MAVLINK developer(s).  Kudos and LOL.

    Cheers,  and continue to have fun.

  • MR60

    Thx Jethro; no I did not try that. Python language is not so much the issue. The issue is that the people who developed the pymavlink, mavproxy,droneapi did not document a high level overview of how the different modules and layers interconnect. So it is a guess game or trial and error to find out how to do such simple things as writing or reading a parameter via mavlink...

    It would help a lot if someone had a working python code example that writes and read a parameter (showing all the steps from connecting to a com port to closing the connection), stripped to the bare minimum required to do this (I guess such a code example would only use pymavlink).

  • Wow Hugues! I admire your courage in tackling this task. Have you tried the Python course over at Codecademy?

  • MR60

    @Chris, Hein, Simonl thank you for your kind words. Glad it helps.

    I will know attack my Excel checklist project... (still need to find a way to link excel visula basic buttons and python scripts, lol).

  • Well done Hughes :-) I've also been thinking of a project that would need to talk to Pixhawk via Mavlink. I also looked through the mavlink "documentation" and found myself going round in circles! Kudos to you.

  • 100KM
    Thank you! I'm going to have to do this myself soon and you've given me a head start. I'll post anything useful I produce.
  • 3D Robotics

    Impressive! And welcome to Python (I had to look up "class" not so long ago, too ;-) It's the best language for non-developers like us)

This reply was deleted.