views:

285

answers:

2

I've got 30 unopened Lego Mindstorms kits that I'd love to use in my intro programming class to do some simple robotics stuff at the end of the year. We're using Python in the class, so I'd prefer there to be a way for the kids to write the programs in Python. Unfortunately, these are old kits with RCX bricks - not the newer NXT ones, so most of the projects like NXT_Python can't help me. Is there any way to make that happen?

+2  A: 

I doubt it.

The RCX bricks used an 8 bit microcontroller. While it might be possible to run some sort of a Python interpreter on it, I haven't seen one ported to it.

The closest you can get is Java:

http://lejos.sourceforge.net/

So theoretically, you could look at Jython and try to run class files compiled with it on the lejos JVM... Sounds like a long shot, though. The microcontroller in an RCX brick just doesn't have a whole lot of room for a big runtime.

Ori Pessach
I had the same thought while you left your answer. I'll try to check this out today, but like you said, I'm not terribly optimistic. I'm also not sure if there isn't so much work involved that the kids wouldn't get bogged down in making their code work on the JVM, and lose sight of writing Python.
Kyle Schmidt
I've seen posts from people trying to run Jython on lejos and running into all sorts of problems: http://osdir.com/ml/java.lejos/2005-07/msg00013.html http://osdir.com/ml/java.lejos/2005-07/msg00014.html. It seems like the runtime library provided with lejos isn't up to snuff. It might be fixed since then, or easily fixable.
Ori Pessach
After a couple of hours getting the most recent copy of LeJOS working with Java 1.5, and finally getting LeJOS installed on the RCX, Jython chocked on compiling with the provided LeJOS compiler - from the look of it, perhaps from a lack of an arraycopy method. Using javac didn't help - provides a wrong magic number when I try to lejosdl the class onto the brick. So I'm going to call it quits on this project, since as much fun as Mindstorms are, for the amount of work involved in doing things that aren't programming, I'm going to find a different end of year project.
Kyle Schmidt
Bummer. If it's just the arraycopy() method, it can probably be added to lejos...
Ori Pessach
More specifically, lejos does provide System.arraycopy(), but it has a different signature than the method as documented by Sun. Specifically, it only deals with char[] source and destination arguments. It should be pretty easy to add an overloaded method to support String src and dst, which is what Jython is trying to use. I'd do it myself if I had any way of testing it.
Ori Pessach
+3  A: 

Running Python on the brick itself is probably hard (for the reason others already stated - size of the interpreter, available RAM on the brick for example) but this might be of interest:

According to this thread you should be able to use pylnp (remote) combined with BrickOS (on the brick; formerly legOS).

ChristopheD
Apparently Perl or Forth could be an option too: see http://www.faqs.org/docs/Linux-mini/Lego.html
ChristopheD
Forth aside, these are remote control libraries. Awesome stuff, but the IR link would need to be hooked up to the brick all the time. Due to constraints beyond my control, I can't get IR towers hooked up to our Windows machines - only to the Linux machine I don't officially have. I can use it to flash the bricks and transfer programs, so if I do this, the students need to be able to run programs on the brick without an IR tower. Forth is a little too different from Python for me to use it for just a few weeks - same with C.
Kyle Schmidt