Python Mindstorms RCX
Asked Answered
E

2

13

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?

Elbrus answered 8/4, 2010 at 1:5 Comment(4)
@jathanism He's using RCX, so I don't see how NXT_Python will help him.Ozone
python mindstormin in school? How can I join your class (and loose some years in the process)?Mozzetta
@Don Johe - Hopefully mindstorms with Python. I did it with Java a few years back, and that might be my backup plan. If I can find the time, I might try Jython with Lejos, though that might prove impractical for teaching to an entire class.Elbrus
@Ori Pessach - High School age, 14-18Elbrus
R
3

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).

Rowenarowland answered 9/4, 2010 at 17:18 Comment(2)
Apparently Perl or Forth could be an option too: see faqs.org/docs/Linux-mini/Lego.htmlRowenarowland
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.Elbrus
B
2

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.

Brockbrocken answered 8/4, 2010 at 15:9 Comment(5)
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.Elbrus
I've seen posts from people trying to run Jython on lejos and running into all sorts of problems: osdir.com/ml/java.lejos/2005-07/msg00013.html 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.Brockbrocken
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.Elbrus
Bummer. If it's just the arraycopy() method, it can probably be added to lejos...Brockbrocken
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.Brockbrocken

© 2022 - 2024 — McMap. All rights reserved.