Newsletter sign-up
View all newsletters

Sign up for our technology specific newsletters.

Enterprise Java
Email Address:

Imaginations run wild with Java Lego robots

Learn to program the ultimate geek toy -- Lego Mindstorms -- in Java

  • Digg
  • Reddit
  • SlashDot
  • Stumble
  • del.icio.us
  • Technorati
  • dzone
The Lego Mindstorms Robotics Invention System (RIS) is a kit for building Lego robots. It includes two motors, two touch sensors, one light sensor, more than 700 Lego bricks, and a robot brain called the RCX. It's Lego's bid for the 11-and-up age group; the company hit this market better than it might have anticipated, seducing a lot of amateur roboticists in their 20s, 30s, and beyond. Although the 00 price tag sounds steep, it's an excellent value, considering what's contained in the set.

RIS also includes software for programming robots, a graphical environment called RCX Code. Using RCX Code, you can create robot programs by snapping together functional blocks, just like snapping together Lego bricks. You can download and store completed programs on the RCX via an infrared link (the same way your remote and your television set talk to each other). RCX Code is great for people who have never programmed, but it's limiting for experienced programmers.

RCX architecture

The RCX, the robotic brain, is a large brick that contains a microcontroller. You can attach three motors and three sensors simply by snapping special "wire bricks" on the RCX. An infrared port is used to communicate with your desktop computer.

Internally, the RCX contains 16KB of ROM and 32KB of RAM. The ROM contains low-level routines for the motors and sensors. You must load the RAM with firmware, which is also provided by Lego. This firmware (which I'll call the default firmware) contains a byte-code interpreter, which can run programs downloaded from RCX Code.

There are two categories of alternate programming environments for the RCX. The first uses the default firmware on the RCX and provides alternate programming environments on the desktop PC. A good example of this is NQC, a popular environment that lets you write robot programs using C-like source files. Those files are compiled and downloaded to the RCX, but it's still the default RCX firmware that runs the programs.

The second class of alternate programming environment uses replacement firmware and also provides a set of PC-side tools for programming. LeJOS falls into this category. LeJOS was created by Jose Solorzano, a developer and Lego robot enthusiast. LeJOS is the sophisticated cousin of TinyVM, Solorzano's first run at a Java environment for the RCX.

LeJOS provides replacement firmware that knows how to run leJOS programs. It also provides PC-side tools for compiling Java source code and downloading leJOS programs to the RCX.

LeJOS Java implementation

Only a small subset of the Java Virtual Machine and APIs can be implemented on a small device like the RCX. LeJOS includes just a few Java classes from java.lang, java.io, and java.util -- many of which will be familiar to Java programmers. That's one of the great things about leJOS; if you already know Java, you're a few steps up on the learning curve.

LeJOS installation

You can download the entire leJOS package from the leJOS homepage, http://lejos.sourceforge.net/. The page also contains links to installation instructions for both Linux and Windows. I'll be using the Windows version, but it will be much the same process for Linux users.

  • Digg
  • Reddit
  • SlashDot
  • Stumble
  • del.icio.us
  • Technorati
  • dzone
Comment
Login
Forgot your account info?
Add comment
Anonymous comments subject to approval. Register here for member benefits.
Have a JavaWorld account? Log in here. Register now for a free account.
Resources