A few years ago, I was given the Lego Mindstorms robotics kit. For those of you who don't know, this is a kit for building programmable robots, based on hardware originally developed for teaching at MIT. You get a bunch of Lego pieces including motors, touch and light sensors, gears and the bricks we know and love from when we used to get them stuck in improbable orifices as children. The centerpiece of the kit is the RCX, which contains a microprocessor with a small amount of memory, outputs for driving the motors and inputs for connecting to the sensors. You program it by writing programs on a PC and sending them over an infrared link.
I didn't do very much with the kit when I first got it, partly because there were some faulty pieces (particularly the cable that links the PC to the infrared "tower" used to transmit to the RCX), and partly because I didn't like the visual programming environment that comes with it. I also found the mechanical design of robots very hard. The instructions with the kit do include some examples, but not much guidance on learning how to go about coming up with a design. Maybe it's difficult to teach this.
I recently decided to take another look at it. In the intervening time, someone had written a Java virtual machine for the RCX and created a class library. It's called LeJos. There is even a plugin for my favourite Java IDE, Eclipse. I still haven't found a good source on mechanical design. An O'Reilly book gives some example constructions, though with limited discussion of how to come up with a design. They are at least better than Lego's own rather flimsy designs.
I'm planning to post examples of the code I develop and of the robots themselves over the next few days and weeks. But first, here's a couple of gotchas that I found which held me up.
I use Windows 2000 on an IBM Thinkpad, and at first couldn't get the PC to communicate with the IR tower via the serial port. The first thing to look for is that the serial port (COM1 for me) is enabled in the BIOS. It was, but something else was using it. This turned out to be ActiveSync, the program for connecting to PDAs. ActiveSync starts some kind of service, and this claims any communication devices you've selected for it. As I don't usually use the serial connection to my PDA, I went to the options for ActiveSync and told it not to use COM1. This made the communication to the tower work (you can tell because a green light comes on when data is being sent to it), but the communication from the tower to the RCX still failed. I tracked this down to interference from the Thinkpad's own IR port. Placing something opaque over the port fixed it.
After this, everything worked fine. The Eclipse plugin allows you to download the firmware (the JVM), the write the Java code and download it.
Next time, I'll give an example...
No comments:
Post a Comment