Do you know what's cool? LEGO Mindstorms, that's what
Saturday, August 23, 2008
I've been meaning to get a LEGO Mindstorms set for sometime now, but every time I have looked for one it has been around X-mass time; and as we all know, it's close to impossible to find anything you really want during the end of year festivities.
Yesterday, after dinner, we strolled to the local Toys-R-Us to buy model magic for Gabriel (he likes to sculpt things and whatever this putty is made of, it kind disappears on you; I'm not sure where it goes, but we keep buying the stuff). Out of curiosity I asked if they had Mindstorms on stock. The sales clerk said they did and I immediately asked to see one (I didn't believe it). Since they did have them, I got one for Gabriel.
The toy is more for me, really, because he hasn't figured out the programming part of it. I found it interesting, however, that he immediately wanted me to make it do things independently. In other words, he wanted me to make "him" feel things and become like a person. And I call it a him, because we named the little guy Metal Head
. Ironic, I think, because the thing has not a piece of metal on the outside that can I see. I have to admit that 8 year logic trumps my jaded, cynic view of the world, so Metal Head it is.
What a great experience and opportunity these toys are. On the one hand, this toy is well made and well engineered. And it's no surprise, since LEGO actually paid a few of the heavy users of the first Mindstorms generation to help
design the NXT version. The money was well spent. On the other hand, it is an amazing opportunity to reel in kids to scientific and engineering careers. The next generation of engineers will already know how program remote explorers and how integrate hardware with software to engineer explorer robots to go places where no human can ever survive. Sure, you can't compare play time in the safety of a living room to Jupiter's unforgiving surface, but it's easy to extrapolate.
The Mindstorms is quite a marvelous, yet simple, set of technologies put together. With only 7 input and output ports, the possibilities are endless. It's an amazing toy.
I haven't played with LEGOs in a while, but I figured that writing software is similar to building things with LEGO, so I tried building the first robot. After all, I'm an OO proponent to the point of evangelism. LEGOs are built with components, software system are also built with components. The major difference, of course, is the scope and amount of time it takes to build each. The first project, LEGO promises, is to take 30 minutes. Sure enough, I can write a "Hello, World!" program in less time than that--give me any computer language, and I can have that baby outputting platitudes in no time.
Again, I haven't built anything with LEGOs in a long time, so the 30 minutes project became a 90 minutes project for me. After sweating profusely and debilitating lower back pain (I was sitting on the floor just like Gabriel was), Metal Head turned out all right: the robot is a 3 wheeled small machine that moves around, if programmed correctly.
The next step was to make it look like what the box promises. I couldn't disappoint my son, so there goes another 90 minutes to build claws into the thing and then make it pick up balls on command. The funny part here was that I crisscrossed the wiring of the motors. So once I turned Metal Head on to check that the it still worked, it started jumping around. This gave it a more real experience of becoming alive and it gave me a feel of panic once I realized that all the jumping, although funny at the time, made the pieces start falling off (I couldn't afford another 90 minutes of putting it back together).
The programming is visual and somewhat limited. However, for the target audience (kids 10+), the visual building of logic is a perfect introduction to the craft of software creation.
Each square represents a unit of work. Each unit of work has attributes and behaviors that tell the computer what to do. For example, you can make the robot look around and stop as soon as it feels an obstacle; you can then clap your hands to close the claws, the robot says thank you, pick whatever it's in front of it, turn around, and, finally, drop it off whenever it finds a black finish line. It took me two minutes to program all that. Well, it would have taken anyone two minutes to program all that.
Without the genius of the whole package (the NXT computer, components, and programming environment), doing only one of those things would have taken years of research and PHd dissertations--the light sensing stuff is easy now.
Of course, being a software tinkerer, I know there is much more that you can do with a toy like Metal Head. For that, however, you need to go beyond LEGO's visual programming environment and move onto more familiar territory: a programming language with APIs and real lines of codes (you know, something with curly braces and semi colons at the end of each statement).
You have many choices here, but I'll go with LeJOS
for my further experimentation. I haven't done anything with it yet, but I already have a couple of requests from Gabriel. I doubt any of my programs will make Metal Head behave like Wall-E, as he's envisioning; nevertheless, I hope the whole experience of pushing the orange button to make it do things will instill in him the same curiosity I have for anything that can be engineered, programmed, or both.