Oct 19, 2011

A Change

2011 has been an interesting year. Between the stupid earthquakes and the pressure of finishing my PhD, I have been silent because I have had nothing interesting to talk about (cf. twitter...).

But there is a light at the end, I'm on track to complete my thesis, 'Biologically Inspired Visual Control of Flying Robots', in December/January.

Christchurch, demolished, the old...

I'm excited to say that I have accepted a job at the Institute of Molecular pathology, in a research group studying the mechanisms of visual flight control in insects. Technology wise, it is a perfect fit; the experimental apparatus involves a multi-camera real-time flight tracking system and estimator for multiple targets in an augmented reality flight arena. It is open-source (ish), and python/numpy. Research wise, it allows me to investigate some of the assumptions and unknowns in the biomimetic control systems I implemented during my PhD. And it is in Vienna, 1st Feb, 2012!

Vienna, the new...

This is a career change for me. In the last few years it became increasingly clear that I was morally uncomfortable with the use of UAVs as weapons (drones). Previously I had consoled myself with there existing an ethical and philosophical difference between 'the application of research' and 'the action of research'. When It came to looking for work, and considering who to work for, this difference was often eroded.

It has also been particularly frustrating being in New Zealand for the last 12 months and watching our flaccid national response to the three recent challenges here (world cupearthquakerena oil spill).

Technology Tidbits

This post has been brought to you by procrastination.

Jul 15, 2011

Interfacing Python + C + OpenCV via ctypes

I was recently asked to help a colleague access his image processing C-library from python; quite a common task. As those of you who are familiar with Python might realise, there are a whole bag of ways that this can be accomplished;

In this case the colleague only needed to access a single function from the library returning image data, and then hand this result onto OpenCV. One happy side effect of the new (> v2.1) python-opencv bindings is that they do no validation on CvImage.SetData, which means you can pass an arbitrary string/pointer. Because of this I advised him I thought using something like SWIG was overkill, and he could just write a wrapper to his library using ctypes, or a thin python extension directly.

Image data contains embedded NULLs, and I could not find a concise example of dealing with non null-terminated, non-string char * arrays via ctypes so I wrote one.

# char *test_get_data_nulls(int *len);

func = lib.test_get_data_nulls
func.restype = POINTER(c_char)
func.argtypes = [POINTER(c_int)]

l = c_int()
data = func(byref(l))

print data,l,data.contents

and, another approach

# void test_get_data_nulls_out(char **data, int *len);

func_out = lib.test_get_data_nulls_out
func_out.argtypes = [POINTER(POINTER(c_char)), POINTER(c_int)]
func.restype = None

l2 = c_int()
data2 = POINTER(c_char)()
func_out(byref(data2), byref(l2))

print data2,l2,data2.contents

The full code can be found here and contains examples showing how to deal with data of this type using ctypes, and by writing a simple python extension linking with the library in question.

Oct 5, 2008

One Month In France


Hi Everyone, Its been a long time between blogging but I have an excuse. I have moved from Christchurch New Zealand, to ENAC, Toulouse, France. I have now been here for a month, working with the UAV team here.

Screen Envy?

The work has been really challenging, and I have settled into my routine, working towards some things I would like to demonstrate before I leave. I have spent a few weeks doing a lot of electronics design,  updating the paparazzi autopilot board, the IMU, and the GPS boards. Nothing revolutionary, just some evolutionary improvements over the previous hardware.

  • Consolidation of the interfaces between the main board, and the IMU+GPS+Radio+Motors. IMU interface is now SPI only, GPS interface is I2C only / UART only.

  • Addition of a 24bit ADC on the main board to directly measure the pressure sensor, no more op-amp+calibrate the offset at startup.

  • Physically smaller stackable board design.

A lot of this work has been done with an eye towards moving some of the off-board vision processing I am currently doing onto the flying aircraft. I have been experimenting with the beagleboard, and one of the goals of the hardware refactoring above is to free up an interface to push data between the beagleboard and the flight controller. Probably I2C or UART, I am not sure yet.

Can anyone get hold of a Gumstix Overo for me?

I am hoping to be able to demonstrate some biomimetic control responses from my onboard vision system, using image motion information. I also hope to demonstrate hybrid external position estimation system using an off aircraft 3d vision system aided (kalman estimator) by on-board IMU .

Plenty of work for me ahead.


I finally managed to upgrade to the Ubuntu Intrepid beta. I was pleased to see that it contained all sorts of productivity improvements;

  • I used to waste about an hour a day keeping up with the US election news on Youtube, watching Sarah Palin insult the intelligence of all mammals on the planet with her existence. Intrepid fixed this for me by removing the feature where sound embedded in flash videos was played through the soundcard of my computer. Phew, thats a relief. I guess I will just need to go and watch Fargo instead.

  • Keeping in contact with my family via Skype was also a PITA, luckily Intrepid removed the ability for me to do that too, no sound to hear my parents nag me, and no video which would let them see me all hung over and tired.

Im sure everyone reading this is aware of that feeling when you go and use a friends brand new $2000 Windows Vista computer. The way it runs so slowly with 2GHz of processing power at its disposal, crashes all the time and takes 6 minutes to turn on. It is brand new FFS. When I am in that situation it makes me feel like the entire engineering profession has failed me.

I got that feeling with Ubuntu this week.


Unfortunately I have not been able to work on Conduit very much over the last month, and it appears that no one else seems to have had the time to either. This upgrade pain has destroyed my motivation, and I only just recovered from the previous month, where approximately 14,000 people reminded me that the Conduit GUI made them vomit in their mouth. Some positive re-inforcement (and some help hacking) would be a welcome change about now.

May 21, 2008


Frantic would be how I described my last two weeks. I have had very little free time to work on Conduit. Everything seems to have come at once!


  • I have been playing with barpanel, a very functional GNOME panel replacement.

  • Grape is certainly an interesting UI/desktop mock up. If I had infinite spare time I migh have a hack on it, as an excuse to play with Clutter.

  • Props to Jan Bodnar for his excellent Gtk+ and Cairo tutorials.

  • My (bad) experiences with Ubuntu 8.04 can be best described by the following picture.. Firefox crashing

Openstreetmap GPS Mapping Widget

Somewhat tangentially related to my PhD, I have been hacking on a simple Openstreetmap GPS mapping/display widget. Basically because after investigating all the existing mapping programs on linux, none of them supported openstreetmap/openaerialmap and were able to be easily embedded.

OSM GPS map widget

It's basically a port of tangoGPS (by Marcus Bauer) to libsoup and considerable clean-up. The whole thing is now hidden behind a derived GtkDrawingArea with a nice simple 4 function api (other parameters such as zoom, lat, lon, are accessible as gobject properties)

  1. set_map_center(double lat, double lon, int zoom)

  2. add_gps_point(double lat, double lon)

  3. add_roi(double lat, double lon, GdkPixbuf *pixbuf)

  4. get_bouding_box()

Things like double click, map dragging, scroll to zoom, etc are all handled automatically as you would expect. It caches downloaded tiles and it's pretty much complete at this point. I hope to be able to post code soon.

Mar 28, 2008

Why Engineering and FOSS is Satisfying

I recently came across the post; why student programmers rant about business students with ideas. Putting my ideological belief in FOSS aside, I think it eloquently describes why I chose to return and pursue a PhD after a year spent studying engineering management (like an MBA - for those North American folks).

I also think it is highly applicable to FOSS. Many successful FOSS projects are born from engineers, the 'decision to execute' has already been made. As the article mentions, 'leadership and the ability to make decisions _is _valuable, but only in groups with realizable ability to execute'. As a FOSS project evolves, the (normal?) combination of a BFDL and the constant freedom to fork keep the project relatively free of the ownership style disputes described in the post.

In reading the post and its comments, its also refreshing to see a discussion on the internet so free of rudeness.

[1] The terms engineer and programmer can be used interchangeably, in this context. They are both highly skilled, creative professions, commonly only recognized as such by their respective peers. [2] Im obviously not so naive as to rule out the influence of money on all of this. I just consider it a baseline, and a gross generalization, that monetary incentives are less important to creative professions than to those who pursue an MBA.