For those of you who prefer a scripting language for your MAVLink needs, you may like to have a look at pymavlink, a Python implementation of the MAVLink protocol.I've just released version 0.2, which fixes some bugs, and adds support for the latest changes in the upstream mavlink git repository.
I initially wrote pymavlink to make it easier to develop MAVProxy, a little command line tool which provides a proxy between a MAVLink master and some number of slaves. I use this for a HIL setup between FlightGear, APM and qgroundcontrol. I'm releasing it more widely as I'm hoping it will be more generally useful to the diydrones community. It can be used to write little scripts that manipulate and display MAVLink messages in interesting ways.
The way pymavlink works is that you generate a custom mavlink python module using mavgen.py, which reads a set of MAVLink message definition files in their XML format, and spits out a ready to use python module that implements all the messages in the XML files.
A good example of what can be done with a short script is mavlogdump.py, which formats a qgroundcontrol MAVLink log file in a human readable manner. This really shows the advantage of using a scripting language for MAVLink, as it can easily display structures without having to write a lot of formatting code for each of the messaging types.
For our UAV project we are planning on using sets of python scripts with pymavlink to do things like mission planning, log analysis, camera control, image processing etc.
If you want to ask questions about pymavlink, it is probably best to join the mavlink mailing list.
Comments
Hi Andrew, I'll have a look into cython. It should be relatively straightforward to wrap any of these backends to be compatible with the traditional pymavlink API.
@Tobias, another possibility is to generate some cython code.
@Tobias, nice work!
Do you think we could use the SWIG backend with a wrapper to give the pymavlink API? There is a lot of code using the pymavlink API already, and it would be really nice to get the speedup without rewriting the apps.
Cheers, Tridge
If anyone wants to generate MAVLink messages on an embedded Linux controller like the Raspberry Pi, this is an alternative implementation using the bare C headers and SWIG for Python: https://github.com/PenguPilot/swig-mavlink
The speedup compared to pymavlink is around 15 on a PC.
I guess that pymavlink can be installed in Raspberry Pi also...right ?
Both mavlink and MAVProxy are in my home /home/amit/ , so should i create a separate folder in home and then try above steps again?
unless your mavlink and MAVProxy folders are *in the same folder*, it won't work. ie /somefolder/mavlink and /somefolder/MAVProxy need to be in the same /somefolder. PATH is not used.
I hate to say the obvious, but it means it couldn't find your pymavlink installation. ( either you don't have one, or its in the wrong place) . do you at least *have* a pymavlink folder somewhere nearby ( it should be inside the mavlink folder).
Hi Andrew,
I am trying to do SITL based on instruction fiven here http://dev.ardupilot.com/wiki/setting-up-sitl-on-linux/.
Everything is fine when finally i execute the command sim_arduplane.sh --console --map --aircraft test , it does open two windows but i get the following error in main window
File "~/MAVProxy/mavproxy.py", line 1775, in <module>
from pymavlink import mavutil, mavwp, mavparm
ImportError: No module named pymavlink
Anyone has faced this issue??
Let me know!!
Thanks in advance.