Imaginations run wild with Java Lego robots
Learn to program the ultimate geek toy -- Lego Mindstorms -- in Java
By Jonathan Knudsen, JavaWorld.com, 02/09/01
- 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
Resources
- The leJOS homepage is the official source of information about leJOS. Follow the links to the TinyVM page to really dig into
the implementation details
http://lejos.sourceforge.net
- The leJOS API reference contains all the javadoc documentation for the leJOS APIs
http://lejos.sourceforge.net/apidocs
- Andy Gombos has written a visual interface to leJOS. Essentially, it's a pint-sized IDE for leJOS
http://www.geocities.com/gombos_2000
- The Unofficial Guide to Lego Mindstorms Robots (O'Reilly & Associates, 1999) is filled with robot projects and tutorials on alternate programming environments
http://www.oreilly.com/catalog/lmstorms
- Building instructions for the robot projects in The Unofficial Guide to Lego Mindstorms Robots are online
http://www.oreilly.com/catalog/lmstorms/building
- The Unofficial Guide to Lego Mindstorms Robots contains URLs for various online resources. The URLs themselves are also online
http://www.oreilly.com/catalog/lmstorms/resources
- LUGNET is the undisputed center of the online Lego universe. It's a fan-created site with numerous discussion forums covering
all aspects of Lego. Some other interesting parts of LUGNET are the set and part references
http://www.lugnet.com
- Lego has an official Mindstorms site. You can find building instructions, tips, early releases of upcoming software, discussion
forums, and all sorts of other stuff
http://mindstorms.lego.com
- Jonathan Knudsen has written a series of articles for the O'Reilly Network. The topics include a tutorial on NQC, the link
between MIT and Mindstorms, the use of Mindstorms in education, driving a robot in a straight line, and creating computer-rendered
drawings of Lego models
http://www.oreillynet.com/pub/q/lego_mindstorms
- Kekoa Proudfoot's page contains all kinds of useful information about the RCX and its internals. Kekoa did most of the reverse
engineering on the RCX that enabled the subsequent outpouring of alternate programming environments
http://graphics.stanford.edu/~kekoa/rcx
- Russell Nelson maintains another page packed with useful information about Mindstorms
http://www.crynwr.com/lego-robotics
- Go get the Java 2 SDK from http://java.sun.com/j2se
- Read also "Java Is Child's Play with Lego Mindstorms," Tony Sintes (JavaWorld, June 2000)
http://www.javaworld.com/javaworld/javaone00/j1-00-lego.html
- For more Intro Level articles, visit JavaWorld's Topical Index
http://www.javaworld.com/javaworld/topicalindex/jw-ti-introlevel.html
- Learn Java from the ground up in JavaWorld's Java 101 column
http://www.javaworld.com/javaworld/topicalindex/jw-ti-java101.html
- Sign up for the JavaWorld This Week free weekly email newsletter and keep up with what's new at JavaWorld
http://www.idg.net/jw-subscribe