Java for Lego RCX

Back to Pekka Nikander's home page


News

News! (2000-12-27) The holidays did it! Now the system works as it did in May! That is, you can actually run programs at the RCX. Time to start testing more threading and exceptions...

News! (2000-12-16) I seem to have time to track the compiler changes, but that is all. Nobody has been interested to have a CVS tree; therefore I am not planning to put up one, at least not unless somebody asks for it. The compiler works in the sense that it compiles itself and produces runnable code. However, there seems to be bugs in the runtime; the thing works in emulator, but crashes at the RCX. Probably something has been changed in the way code is generated between now and May 2000, when the runtime worked OK.

News! (2000-05-22) Pre-emptive threads now seem to work, as well as simple exceptions. There is probably some bugs still, especially with if you do not catch all exceptions yourself. See the list of distributions.

Background

In autumn 1999, I managed to convince our lab to fund a student project that developed a prototype for a museum guide robot. The robot was to be partially built using the Lego RCX robotics set, and I was to act as a tutor for the student group. Thus, the university bought me a set of Lego bricks, and I was able to play with Legos for the first time since my childhood.

However, since I had been working with Java for a few years, I went to see if there were any decent Java programming environments for the RCX. The search result was empty. Thus, I decided to write one, but with a twist in mind: The resulting system should be written in Java to maximum extend possible, with minimal amount of code written in any other language. From these pages you can study and download the result.

Basic status (May 2000)

The RCX Java operating system is currently in alpha stage, well, maybe nearly beta. That is, the java.lang package is API complete but not quite code complete. Basically, the system supports objects and classes (but not interfaces), one dimensional arrays (but not multidimensional), pre-emptive threads, and exceptions. Of the data types, non-object integer data types are fully supported (at least I think so), I have no plans to support floating points types, and character and String API has been written, but there is little actual code. ClassLoader and ThreadGroup support may be written in one day, but not in any near future. The Compiler, Process, StringBuffer, and SecurityManager classes are left out, and I have no plans to support them.

The com.rcx package supports access to the underlying RCX hardware, including buttons, display, interrupts, plain hardware ports, motors, sensors, and timer. However, much of the functionality is still in its bare bones stage, and has not been tested. In this package, I assume that both the API can code will still undergo some changes.

There are still some unexplained bugs that seem to come and go with the compiler version. For example, at one time the system crashed until I divided my Main.main into two methods, Main.main and Main.mainX. The code is somewhat full with comments like // XXX gcc bug. Each of these indicate some code that was written to circument a gjc bug that probably has disappeared since. However, I have not tested if these bugs have gone away; most of them probably have, but it just takes too many tests to know for sure.

Right now, you can actually use the system (once you get it compiled). However, getting the compilation environment working is somewhat hard since I am using the -current version of GCC. Once GCC 2.96 (or 3.0) is released, everything should be much easier.

Javadoc

I've also made available partial javadoc API documentation. You can also generate that from the distribution.

Installation

See the installation instructions if you want to experiment with the system. If you do download and install the system, please let me know.

Links