Message-ID: <19794.73.631585.266200@samba.org> Date: Wed, 9 Feb 2011 13:47:37 +1100 To: qgroundcontrol@googlegroups.com Subject: python implementation of MAVLink In-Reply-To: <8aa98fce-aa19-4b27-a621-486097a6cc29@y3g2000vbh.googlegroups.com> References: <8aa98fce-aa19-4b27-a621-486097a6cc29@y3g2000vbh.googlegroups.com> X-Mailer: VM 8.1.0 under 23.1.1 (x86_64-pc-linux-gnu) Reply-To: tri...@samba.org From: tri...@samba.org I've done an initial implementation of MAVLink in python, available here: git://git.samba.org/tridge/UAV/pymavlink.git or via gitweb here: http://git.samba.org/?p=tridge/UAV/pymavlink.git;a=summary It is still under development (I started on the code late last night), but it is already quite useful for simple tasks. The way I wrote it is to have a program called mavgen.py which reads one or more MAVLink XML protocol definition files, and spits out a python implementation, usually called mavlink.py, which implements the full mavlink functionality for all the messages in those XML files. Here is an example: # create a mavlink instance, which will do IO on file object 'f' mav = mavlink.MAVLink(f) # set the WP_RADIUS parameter on the MAV at the end of the link mav.param_set_send(7, 1, "WP_RADIUS", 101) # alternatively, produce a MAVLing_param_set object # this can be sent via your own transport if you like m = mav.param_set_encode(7, 1, "WP_RADIUS", 101) # get the encoded message as a buffer b = m.msgbuf() # decode an incoming message m2 = mav.decode(b) # show what fields it has print("Got a message with id %u and fields %s" % (m2.msgId(), m2.fieldnames())) # print out the fields print(m2) It also generated doc strings, so "pydoc mavlink" gives you full documentation on all the MAVLink messages available, and descriptions of all of the fields. There are lots of missing features, but I expect to fill in the main ones over the next few days as I start to use this in a real project. Cheers, Tridge
Copyright 2011 https://groups.google.com/forum/#!forum/qgroundcontrol