Robot updated

by Kevin on January 21, 2009
in Robot Army

Just a quick post to say that my robot code has been updated to communicate with my arduino. Learned some more about Python as well, mostly relating to how badly I suck at it. Can’t get object orientation to work with modules but objects are not necessary for this. Straight procedural code is all that is required, for the moment.

Download robot code

Download arduino code

PyInvaders

by Kevin on August 22, 2008
in Journal

I made a game! Well, copied from a magazine (Linux Format 110) but it still counts. It is a stripped down version of space invaders which is coded in python. Needs the pygame software installed to work as well as an install of python (duh).

No idea what the liscence is with the code, I’m assuming some version of the GPL. I’m putting it up anyway. It is pretty hard, goes quite fast. Have fun!

Python

by Kevin on May 20, 2008
in Journal

Python on XKCD

I love Python. So clean and elegant. Loops are simple:

for i in range (0, 10):

print i

There is no hassle with curly braces either, though I do think they make things look prettier (but that is just syntactic sugar)

Been working on my robot code, split it up into modules. Was piss easy with Python. I need to get my hands on some form of chassis and an interface between it and my portable deck (which will run the code).

Weee code!

by Kevin on April 21, 2008
in Robot Army

After reading the latest XKCD comic, showing it to my mates and then squeeing like a crazed fangirl I decided to make one. The current plans are to borrow a chassis that a mate may have, interface it with my eeepc via an arduino, somehow work out how to get the webcam working and then mount an airsoft gun to the whole thing.

<scientist type=”mad”>MUAHAHAHAHAHAHAHAH!!!!</scientist>

Ahem…

I have a first attempt at some sort of code to drive the robot. It is coded in Python (which I am falling in love with). Feel free to try it ou yourself (Disclaimer: if the code breaks something you agree to not hld me responsible. If it does any good, give credit)

#!/usr/bin/env python

def forward():
print “moving forward”

def reverse():
print “moving backwards”

def left():
print “turning left”

def right():
print “turning right”

while 1 == 1:
objectlocation = raw_input(“please enter the object location: “)
if not objectlocation == “front”:
forward()
else:
reverse()
if objectlocation == “left”:
right()
if objectlocation == “right”:
left()

Not very spectacular but it is a start. To use, run the script somehow on your system and type in stuff at the prompt. It only responds to front, left and right. Anything else is ignored.