Brian Slesinsky's Weblog

Saturday, 27 Jan 2007

Lego Mindstorms NXT: First Impressions


I just got the new Lego Mindstorms and built the Tribot, after an impatient two weeks of waiting for it to arrive from Here are some observations after a couple days of tinkering.

The out-of-the-box experience would have been improved if I had remembered to buy batteries on the way home. (Isn't everything rechargeable these days?) Also, six AA's is rather inconvenient because I have a recharger for my camera that takes four.

The box itself is much less useful than the old Lego boxes. The old ones were divided up bento-box style and had a nice lid, so they were pretty useful for sorting and storing Legos. This one has a non-functional marketing lid and everything is in baggies. I'll have to figure out a better way to store Lego parts rather sooner than I thought.

It's strange to be working with physical parts after so much time programming. I got to know the living room floor much better after losing a couple of pieces. I probably should have vacuumed before opening the box!

Odd Parts
Odd Parts

The parts are weird. There are no bricks at all. The only parts that are the same since when I was a kid (using the old Expert Builder sets) are some of the gears, axles, and pegs. Everything else is made out of girders and odd pipe fittings. I wasn't really sure what most of the parts were good for until after building the model.

The visual programming language used to program the robot is reasonably convenient for getting started, and it's neat that it's multithreaded. However, the development environment is clearly a bad port running under some kind of emulation. The user interface has no native Mac widgets or even reasonable approximations. On my Intel iMac, it runs under Rosetta, so it's an emulator on top of an emulator. There are slow repaints and stopwatches, and it takes about 20 seconds to compile a program whenever sending it to the robot. Also, Bluetooth support doesn't work on Intel iMacs due to Rosetta.

Learning how to control the claw is a little tricky. You need to set the power really low or it snaps like an alligator and the model tears itself apart. (Luckily the claw is kind of wimpy on the Tribot.) I thought my robot should at least know enough to stop moving its claw when it hits an obstacle, so I wrote a program that detects when the motor position stops changing and stops the motor, and that made the robot seem a little more animal-like.

To do that, I wrote my first "custom block", which is how you write methods in Mindstorm's language. (The block's purpose was to wait until a motor's position stops changing.) This was rather annoying to construct because I had to wire several blocks together, and drawing wires between blocks is rather finicky, especially with the slow screen refreshes. The way you create a block is essentially the "extract method" refactoring, but unfortunately that's the only tool you have and you can't edit a custom block's inputs once you've created it. It seems a bit much to write a simple loop. Maybe it's time to start exploring the other programming environments.