pymavlink confusion

707 views
Skip to first unread message

dr.g.owen

unread,
Aug 18, 2013, 10:08:04 AM8/18/13
to mav...@googlegroups.com
Hi folks

I've been trying to get pymavlink working for ages now but having no luck.

I clone the repository:

git clone git://github.com/mavlink/mavlink.git

Now the website says to run mavgen.py, which appears to be in mavlink/pymavlink/generator.

So I change to that directory, and run:

python mavgen.py -o mavlinkv10.py ~/mavlink/message_definitions/v1.0/ardupilotmega.xml

which generates the mavlinkv10.py file  ... but where does this go.  If I copy it alone to another folder, it won't import, if I try and import it from there it wont work, if I copy it to the pymavlink folder it wont work.  If I change back to pymavlink and run python setup.py build, it builds a build directory, but I still can't import mavlinkv10.  In any case setup seems to rebuild the msg defs which I don't want.

At a complete loss here as to how to do it?  Any tips?  How do I get to the stage where I can run:

from pymavlink import mavlinkv10 as mavlink

Best
Gareth

dr.g.owen

unread,
Aug 18, 2013, 10:10:27 AM8/18/13
to mav...@googlegroups.com
PS.

If I setup build it, then chage to the build directory, copy the mavlinkv10 from the generator directory to the main directory and then edit as follows:

At the top of mavlinkv10 it has:

import struct, array, time, json
from ...generator.mavcrc import x25crc

and if I ignore the warnings about editing, and delete the three dots, it then imports.  But this can't be right?

PIXHAWK

unread,
Aug 18, 2013, 10:21:06 AM8/18/13
to mav...@googlegroups.com
Hi,

Thank you for pointing out this slightly outdated documentation. I'm assuming you're referring to this page:

The page is now updated.

Please just run

python generate.py

To start the Python GUI, the inputs to it should be pretty much self-explanatory.

-Lorenz


--
Sie haben diese Nachricht erhalten, weil Sie der Google Groups-Gruppe MAVLink beigetreten sind.
Um Ihr Abonnement für diese Gruppe zu beenden und keine E-Mails mehr von dieser Gruppe zu erhalten, senden Sie eine Email an mavlink+u...@googlegroups.com.
Weitere Optionen: https://groups.google.com/groups/opt_out

dr.g.owen

unread,
Aug 18, 2013, 10:41:35 AM8/18/13
to mav...@googlegroups.com, pix...@switched.com
Lorenz

Thanks for the quick reply, no I was looking here:


I have followed your instructions (I assumed you mean mavgenerate.py).  It asks me for an output _directory_, which I supply, say /root/tmp/, and it then outputs /root/tmp.py instead.  It appears this is the mavlinkv10 - where do I put this file?

If I specify pymavlink as the output directory, it writes a file called pymavlink.py one directory up (in /mavlink/).  If I try to import mavlinkv10 from that file it fails too.

Sorry if I'm being obtuse but it doesn't seem obvious to me.

Best
Gareth

Scott Yantek

unread,
Sep 19, 2013, 2:40:54 PM9/19/13
to mav...@googlegroups.com, pix...@switched.com
Gareth,

I'm having exactly the same issues. For the output I think you should ignore the instructions and also specify a file name after you choose your directory, but that doesn't make it work any better. It appears that the documentation for this feature hasn't been updated in a long time (the program doesn't even have the same name as in the directions). It's frustrating that it seems like no one knows how to do this correctly even though it's a pretty important feature. I'll post here if/when I figure it out.

-Scott

Gareth Owen

unread,
Sep 19, 2013, 2:43:17 PM9/19/13
to mav...@googlegroups.com, pix...@switched.com

Scott

Do you want me to zip my copy up and mail it to you?

I got it working after many hours .. pretty sure I've done it wrong but it works. (Unless hacking the code was intended)

Best
Gareth

Gareth Owen

unread,
Sep 19, 2013, 2:46:05 PM9/19/13
to mav...@googlegroups.com, pix...@switched.com

Ps.  Here's the link to my version:

https://github.com/drgowen/ardupilot-sdk-python

You can just git clone it.

Best
Gareth

PIXHAWK

unread,
Sep 19, 2013, 3:56:37 PM9/19/13
to Scott Yantek, mavlink@googlegroups.com <mavlink@googlegroups.com>, Andrew Tridgell
Hi Scott,

For the Python versions you should check with Andrew Tridgell, who is mostly using them. I know the C generator works fine.

-Lorenz
Reply all
Reply to author
Forward
0 new messages