Initially, I had intended to research IR communication and then demonstrate complex behaviors that could only be the result of mutual communication. Specifically, I wanted to make two robots dance together -- one would have a sound sensor and detect the beat, and both would spin around and do interesting things in some vaguely coordinated fashion. This didn't work out, though, for several reasons.
First of all, detecting sound turned out to be tricky for my programming background. Home-made Lego sensors can be a bit challenging, and not entirely responsive. While I could make something that detected a peak noise, like a hand-clap, trying to figure out the beat of a song is just plain hard.
No matter; perhaps I could get one robot to follow a line, and the other to follow along side. So I started trying just to get two robots to drive in a straight line (and thus at the same speed) next to each other, with one telling the other its encoder values. Out of these attempts came the diff-drive model and the first communication library (comm.nqh). That's when I stumbled onto a sad truth: Legos are simply not capable of such fine-tuned movement.
You've probably noticed that you can set the power level of a standard Lego motor to any value between 0 and 7. That is, there are only eight distinct power levels for a motor, ranging from stopped to a maximum of about 350RPM (no load). Unless you gear down the motors to the point that the robot's wheels barely turn at full power, you simply cannot fine-tune the robot's speed. Certainly, it is still possible to make one robot drive in a relatively straight line, as long as you are constantly adjusting the power levels. What you will find, though, is that no two motors are exactly alike -- chances are, one motor will require power levels of 5-7 and the other 1-3 to travel at about the same speed.
Now, imagine trying to get four motors to all turn at exactly (or even approximately) the same rate -- and two of them must wait for a message over IR to know how fast to turn. Again, if your robots moved painfully slowly, you might be able to pull it off. But what fun are robots that take a minute to drive a foot?
That's not all, unfortunately. Now that we're trying to do both rapid adjustments to motor speed and some complex IR communication, processor speed becomes an issue. The RCX has a 16MHz processor (your computer is probably between 10 and 150 times that speed). Still, that sounds like it should be more than enough, until you realize that your code is not the only thing running -- the firmware that's actually causing your code to run is doing all sorts of other things, like monitoring rotation sensors so that you don't miss any ticks. According to one report, it takes about 2 milliseconds for a single op-code (instruction) to execute -- about 500 instructions per second. Now realize that there are probably about 50 instructions in a single loop of motor control, between reading rotation sensor values, comparing them, determining by how much each motor power needs to be adjusted, checking the sonar readings so you don't crash, and setting the actual motor values. So, chances are, the motor power is only being adjusted about 10 times a second -- which really isn't all that much, if you consider that you might want your robot moving at, say, 10 centimeters per second. Now cut the number of instructions executed in half so that IR communication can be received and processed as well. See where this leads?
In the end, Legos are simply not suited to complex multi-robot interaction. If you want to go that route, I recommend getting some decent motors and a better microcontroller (I highly recommend the cerebellum, which will soon be available commercially).
That's not to say, of course, that you can't do anything fun or interesting with Legos. They're still the best around for building something quickly and inexpensively, playing for a while, and then tearing down and building something new. And as I have shown elsewhere in this web site, having two RCX bricks communicate and do interesting things together is still possible.
Return to Project Ideas
LEGO, LEGO Mindstorms, Robotics Invention System, and RCX are registered trademarks of the LEGO Group, Inc.
This project is funded by Carnegie Mellon's Undergraduate Research Initiative. These results represent the views of the author and not those of Carnegie Mellon University.
All material contained within this site is
© 2003 Rachel Gockley
except where otherwise noted.