Instrument panel written in Python.


hey guys,
this might be of use to some of you:
i've scripted a set of basic instruments in Python that might be of use to some of you.
the Youtube clip shows it attached to my UAV project.

for anyone who hasn't used it, Python is a particularly easy to use programming language that is used for all sorts of applications.
there are loads of add on libraries to do much of the hard work for you which makes it particularly useful for this sort of rapid development.

the Python code can be downloaded here under the name "cockpit.zip":
http://sites.google.com/site/mrdunk/Home/downloads

more detail on my UAV work here:
https://sites.google.com/site/mrdunk/Home


dunk.

Views: 6235

Tags: FPV, Python, RC, UAV, instrument

Comment by Rana on November 18, 2010 at 8:58pm
Hey Dunk, you seems to be quite a talented person, so would suggest you to put your talent in the the streamlined DIY race of Ardupilot Mega or MatrixPilot based on UDB.

Best Regards

Rana

Developer
Comment by Pete Hollands on November 19, 2010 at 1:45am
Dunk, that is super work, thanks for sharing the python code.
Comment by Simon Wood on November 19, 2010 at 1:09pm
Great work... and GPL'ed. Cool.

You might want to consider looking at py2exe to bundle up it up into a Windows execute for all those lacking python installs/experience.

Cheers,
Simon.

Developer
Comment by Pete Hollands on November 19, 2010 at 2:28pm
I have run the code under Windows, and although it runs, the instruments are not displaying correctly when run with: "dial.py test". I have installed pygame and serial, and the window displays the instruments, but they do not update correctly and the images overwrite and go wrong. The code reads very nicely.
Comment by dunk on November 19, 2010 at 4:26pm
thanks everyone for the interest.

hi Rana,
hehe, that would kind of defeat the purpose of doing it my self though...


Simon,
hmm, not a bad idea. i think i have a windows virtual machine somewhere.
how does py2exe work?
anyone who uses my code will have to modify it to some extent to calibrate inputs, dial position on screen, etc.
is it possible to edit the python script in an executable made with py2exe or will it need re-compiled afterwards?
(i'm guessing not.)


hey Pete,
that's disappointing...
i don't run windows so it will take me a while to dig out a windows virtual machine to test it.

any chance of a screen shot?


dunk.

Developer
Comment by Pete Hollands on November 19, 2010 at 4:48pm
Dunk, here is a link to a screencast in which I test out the program on windows.
Comment by dunk on November 19, 2010 at 5:22pm
hi Pete,
that appears to be a problem with transparencies.
the yellow area should be transparent.

i suspect it's an issue with pyGame...
any idea what version of pyGame you are using?
i'm using '1.9.1release' on Linux.

you can find out by running the python interpreter then entering
pygame.__version__


dunk.

Developer
Comment by Pete Hollands on November 19, 2010 at 5:26pm
Here are my python and pygame revision:-

Python 2.6.2 (r262:71605, Apr 14 2009, 22:40:02) [MSC v.1500 32 bit (Intel)] on win32
IDLE 2.6.2 ==== No Subprocess ====
>>> import pygame
>>> pygame.__version__
'1.9.1release-svn2575'
>>>
Comment by dunk on November 19, 2010 at 5:38pm
hmm. that should be similar enough.
odd.

it's late here but i'll have a dig about tomorrow and see if i can find any information on transparencies working differently on Linux and windows.
they *should* work the same but it is possible we've run into a bug.
Comment by dunk on November 21, 2010 at 7:24am
hi Pete,
on a windows VM i can't reproduce your findings.
it's a clean XP install running Python 2.6.6 and pyGame 1.9.1release-svn2575 .
it works fine for me.


is there anything unusual about the machine you are running?
i'm wondering if this is an issue between pyGame and your graphics card...
the Surface.set_colorkey call inpyGame that handles transparencies does have a flag for non accelerated displays.
http://www.pygame.org/docs/ref/surface.html#Surface.set_colorkey


dunk.

Comment

You need to be a member of DIY Drones to add comments!

Join DIY Drones

Social Networking

Contests

Season Two of the Trust Time Trial (T3) Contest has now begun. The fourth round is an accuracy round for multicopters, which requires contestants to fly a cube. The deadline is April 14th.

A list of all T3 contests is here

Advertisement

© 2013   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service