Thursday, March 22, 2012

Some small Python scripts

So ... that's not quite the "picture of a robot" I was intending to lead this post off with :-)

Strictly speaking, the 'R' in the image above represents a "robot" in the very simple mobile robot simulator that I just developed. RoboSim is written in Python and allows a developer to include a very rudimentary 2D simulator in their project - for instance to test a neural network or genetic algorithm. The robot can rotate on the spot in 45° increments as well as move forward and backwards. Maps are defined as simple nested lists, with internal "walls" defined for areas that cannot be traversed. The robot is fitted with two front bumper switches that are triggered depending on what the robot is pressed against. RoboSim is available on GitHub, and may receive the odd tweak here and there in the future although it has served its purpose in another project already.

My other project is probably going to keep me going for a little while longer, at least until my Raspberry Pi(s) arrive... The project was born out of a hope to combine a couple of them together for a seriously powerful mobile robot. I really wanted to use one for nothing but OpenCV video processing and another for navigation planning etc. What I really didn't want to do was to be constantly swapping between each Pi to upload new code as I tried out different ideas.

Then it occurred to me: wouldn't it be nice if I could just get one or more Pis to act as a "dumb" nodes to run arbitrary Python code provided it to it by a "master" Pi...

A couple of days programming later and the newly Github'd project, DisPy, does this. The README explains it better but essentially, instead of instantiating classes normally, I use a wrapper class to perform the instantiation. Behind the scenes the class' source code is copied over the network to a "node" machine, the class is instantiated on that node and all the local copy's methods and members are replaced by stubs that perform XML-RPC calls back to the "node".

The result is that method calls and member access happens transparently over XML-RPC, allowing for the runtime offloading of arbitrary code to one or many Pis (or anything else that can run Python).

The code is all contained in one module and has minimal dependencies, hopefully it works on other OS' but I haven't tested it on anything other than Ubuntu 11.10 yet. Please fork it, break it and have a play, I'd love your feedback on this one!


  1. I write a bash script if it gets beyond 10 or so lines or if I need a function. Bash doesn't scale well in my hands (I explicitly do not blame this on bash, per se since there may be very good Bash programmers out there) and I find Python (moreso Go nowadays though) fits the niche between small script and fully fledged program. To see more info please visit

  2. This outstanding glimmer of which many women of all ages including can be gucci replica in addition to soft over time. Patent leatherette in this particular value may very well be deemed as an increasingly enjoyment version or maybe type on the everyday household leather. Patent leatherette purses and handbags are definitely more pretty much cost. This can be a popular expertise of which objects crafted from authentic or maybe true household leather usually are of course costly. That is certainly mainly because household leather incorporates authentic creature skin tone, that's also been by natural means in addition to tediously ready-made for being louis vuitton replica uk intended for purses and handbags. In contrast, patent household leather is usually synthetically intended to appear like nearly all this traits connected with authentic household leather. Normally, it would be tricky to distinguish just one on the different. Patent leatherette carriers may very well be seeing that hip and since chanel outlet seeing that household leather purses and handbags, although usually are considerably more realistic with regard to costs. Usually are household leather patent purses and handbags clutches seeing that sturdy in addition to trusted seeing that household leather carriers? They are often. Although it's not necessarily shocking of which in this particular value, excellent is usually better with true household leather chanel outlet. Even so, there are various tactics you could potentially monitor in addition to complete to be certain ones patent leatherette designer purse could likewise past very long in addition to functional importance may very well be looked after with the best time period. Patent leatherette may very well be louis vuitton outlet uk without difficulty, including household leather carriers.