GNU Development Tools for the Renesas H8/300[HS] Series - Documentation on how to build a cross-compiler for the RCX
Lego-Mindstorms Simulator - Simulation of LeJOS programmed RCXs in Java
The problem with the rcxcomm stuff under 10.2 is that the headers from the JNI under 10.2 have incorrect links and therefore don't work. To fix it, you simply need to add to the line in lejos_2_1_0/rcxcomm/src/Makefile where CCOPT is defined:
CCOPT = -g -O ${JNILIB_TYPE} -framework IOKit -framework CoreFoundation -I/System/Library/Frameworks/JavaVM.framework/Headers -I/System/Library/Frameworks/JavaVM.framework/Versions/1.3.1/Headers
The latter part is the new one - I simply added the correct include path and then it finds jni.h. And it can compile. However, I haven't tested yet whether the whole thing actually works.
Anyone who wants to see what's possible with LeJOS can have it demonstrated in this tutorial. Since the LeJOS documentation itself is limited to the API, this tutorial is all the more important. After all, the demo robots supplied with LeJOS are also quite sparse ...
Here's the original article.
I've installed LeJOS. Cool stuff - the first time I can actually use Java for something. The only thing that doesn't work on OS X 10.2 is direct communication between the host computer (OS X machine) and the target computer (RCX brick) via the IR tower - so you can't build distributed applications between these two systems. The reason appears to be an incompatibility with the JNI (Java Native Interface) used to integrate the communication routines (written in C) into the Java classes. Otherwise everything works quite well - even exotic sensors (I have the IR proximity sensor and the ultrasonic distance sensor from HiTechnicStuff) work flawlessly. And the VM is small enough at 16 KB that you still have plenty of space for your own Java programs.
There's also an emulator included with which you can test your RCX programs on the host computer. Very practical for debugging - the RCX is a bit too primitive for that anyway. Even though the emulator is very primitive - it just spits out traces of what happened. No graphical display, no sensor simulation, etc. But still better than nothing.
Important constraints of the Java VM:
- no garbage collection. So you have to make sure you don't constantly instantiate new objects and that memory is allocated statically if possible - otherwise the RCX will eventually run out of memory (does that sound familiar from the Mars robots?)
- some language restrictions like no switch, no long data types, arrays with a maximum of 511 elements, no interface safety (you can put objects into wrong slots without getting exceptions - some of Java's type safety is lost)
- no introspection (so you can't look at your own classes). In a robot that's probably acceptable anyway - it should look at the world, not at itself
- the entire JDK isn't there - logically, the whole thing is an extremely restricted environment. The RCX only has 32K of memory...
- a very primitive toolchain - everything command line and so on. Maybe you could get a graphical Java environment to integrate everything correctly, because basically LeJOS uses the normal Java compiler. Something like Eclipse would probably be overkill in my opinion for programming a small RCX
I think I'll refresh my Java skills a bit during my pre-Christmas vacation and see if I can finally get my ideal freely moving robot working - one that doesn't bump into everything and at least builds up a rudimentary memory of its surroundings. After all, I have two RCX bricks - maybe I can finally realize my envisioned Lego truck with two brains (one for locomotion and basic collision avoidance sensing and one for spatial orientation). And as usual with Lego planning, you first realize that you simply don't have enough Lego bricks. I think that could go down in history as Hugo's first law: You never have enough Lego bricks.
Cool - a complete Lisp that runs directly on the RCX. Perfect for the holiday season.
Unfortunately no OS X version, only something for Windows or Linux - and the latter only for the serial tower. Let me see if I can get something working for OS X with the USB tower. I also stumbled upon TinySOAR, a complete AI Agent Runtime for the Mindstorms RCX brick. Also very interesting - and hopefully also runnable on OS X through its embedding in TCL. And also new to me is the Java VM for the RCX: LeJOS. I don't like Java much, but it's definitely interesting for the RCX. And the oldy-but-goldy: LegOS, the complete operating system for the RCX written in C. However, due to its rather hefty toolchain (a complete GCC configured as a cross-compiler), it's somewhat tricky to install. Besides, it's now called BrickOS and is incidentally also under the Lisp as runtime. Here's the original article.