Read an Excerpt
Chapter 1: Extreme MINDSTORMSIN 1949, GoDTFRED KIRK CHRISTIANSEN began producing the early forerunners of LEGO bricks-Automatic Binding Bricks. A few years later they became known as "LEGO bricks," and in 1958 they took on the stud-and-tube design that has remained to this day. Throughout the 1960s and 1970s the bricks started appearing in new sizes and shapes, along with some decidedly non-bricklike pieces, such as hinges and wheels.
In 1977, LEGO launched the Expert Builder series of sets (later renamed to TECHNIC). Featuring gears, axles, beams, bushings, and even universal joints, these sets could create models that actually worked. Helicopters had adjustable rotors, cars had rack-and-pinion steering, and engines had pistons that moved. These sets brought a new level of engineering sophistication to the LEGO universe. Over the years, new elements continued to be introduced: spring-loaded shock absorbers, pneumatic pistons and valves, and numerous structural and connector pieces. All of these pieces interlocked with one another making LEGO the most versatile construction system in the world. In the fall of 1998, LEGO released the first MINDSTORMS set-the Robotics Invention System (RIS 1.0). To some, this was just another step in a journey that had started nearly 50 years earlier. To others, however, this was a revolution. There were still all of those familiar beams, bricks, and gears. But there was also the RCXLEGO's programmable brick that allowed models not just to move, but to sense and respond to their environment. RIS 1.0 became an instant hit and was one of the hottest selling toys for the 1998 Christmas season. More surprisingly, a significant portion of the"kids" playing with MINDSTORMS were adults.
It seemed to be a long-overdue merging of construction toy and computer. Actually, the idea of merging LEGO with computers wasn't new. For years, researchers at the MIT Media Lab (htt p : / /www. med ia. m it . ed a /) , sponsored in part by LEGO, had been experimenting with programmable toys and the educational opportunities they presented. In the course of this work, several different programmable bricks were developed. LEGO decided to make a commercial product based on the research and the RCX was redesigned from the ground up. Even so, the early programmable bricks from MIT could certainly be considered ancestors of today's MINDSTORMS sets.
The Hackers Step In
LEGO's software was intended to provide an intuitive introduction to programming. However, many of the MINDSTORMS users were experienced programmers who felt that LEGO's simple drag-and-drop environment was too limiting. LEGO was tight-lipped about the details of the RCX, but that didn't prevent me and others from taking matters into our own hands.
Several of us endeavored to unravel the secrets of the RCX and expand its capabilities. Our independent efforts may never have amounted to much if Russell Nelson had not created the LEGO-robotics mailing list. Russell also culled through all of the postings and collected the most interesting tidbits into his LEGO MINDSTORMS Intemals Web site (http: //www. crynwr. com/lego-robotics/). These two resources, the mailing list and the Web site, greatly facilitated our sharing of knowledge and allowed newcomers to also join in the adventure. Eventually, the LEGO-robotics mailing list was merged with the robotics forum at LUGNET (http: //www.lugnet. com/robotics/), run by Todd Lehman. LUGNET is the unofficial repository for all things LEGO and the robotics discussions can be particularly valuable to MINDSTORMS users. Kekoa Proudfoot was the first pioneer into RCX hacking and did a substantial amount of reverse engineering. He revealed many details about the hardware, published a list of bytecodes for the interpreter, and documented the System ROM (see Chapter 2 for more information). His RCX Internals Web site (http:// graphics . stanford. edu/-kekoa/rcx/) contains a wealth of valuable information about the inner workings of the RCX.
At about the same time, I was working towards creating a more "traditional" way of programming the RCX. Starting with old source code to a C preprocessor and a rudimentary understanding of the RCX bytecodes, NQC-the first unofficial programming language for MINDSTORMS-was born. Looking back, it was pretty crude. No local variables. No expressions. No functions. Just a preprocessor, tons of macros, and some code to send the resulting bytecodes over to the RCX. It was, however, a way to write an RCX program with text rather than with graphics; furthermore, it had a very C-like syntax. What started life as an interesting little hack so I could program the RCX from my PowerBook became a popular way for "advanced" users to play with MINDSTORMS. Features were gradually added to NQC to make it more powerful. However, since it relied on LEGO's standard firmware, there were always some fundamental limitations, such as a very small amount of storage for variables and no recursive functions. Other people were striving to break through those limitations by replacing the standard firmware. Starting with Kekoa's documentation for the inner workings of the RCX, Markus L. Noga created legOS (http: //www. noga. de/legOS/), the first replacement firmware for the RCX. This was no small task-writing embedded software is always a difficult business, and writing an operating system without complete documentation of the hardware or System ROM borders on masochism...