The Unofficial Guide to Lego Mindstorms Robots
Last year, Lego released their Mindstorms Robotics Invention System. Using this, children and adults can build simple robots whose behavior can be programmed. The Mindstorms system is a major contender for Coolest Toy on the Planet.
The system contains a RCX programmable brick containing an H8/300 microcontroller, some pushbuttons, a little LCD display, and connectors for motors and sensors (light and physical contact). The user writes a program using a graphical programming language on his Windows box, and downloads it to the RCX via infrared.
Not surprisingly, substantial reverse engineering (1, 2) has been done by hobbyists, and it is possible to develop Mindstorms programs on a Linux box and to download the RCX brick from Linux.
Now O'Reilly has joined the Mindstorms fray, with a book full of fun and useful information about how to build and program Mindstorms robots. The book describes four different robots: Hank is a bumper car robot, Trusty uses light sensors to follow a line along the floor, Minerva has a movable arm, and two identical robots play a game called RoboTag. Along the way, the author discusses the physics and mechanics of robots, programming issues, and the available development environments for Mindstorms.
What's Good? There are detailed building instructions for each of the robots, showing photos at various stages of construction. The designs are simple and appear mechanically sound. There are discussion of the physics and mechanics of tank treads, steering, gears, and other things.
The book's chapters sequentially step through several different software development environments. The first chapter starts with the Windows-based RIS environment that comes on the Mindstorms CDROM. Later chapters give programming examples for NQC (Not Quite C), pbFORTH, Visual Basic, and the legOS operating system, which uses an EGCS cross-compiler to target the H8/300. There are more development platforms available, but these give a good sense of what's possible in Mindstorms programming.
The book has dozens of useful URLs, for both official Mindstorm sites and unofficial hobbyist sites. I particularly liked the fact that the author was aware of some of the recent research in robotics. For instance there is some discussion of Rodney Brooks' subsumption architecture, which is used for the RoboTag robots.
Later chapters of the book often expand on designs from earlier chapters, building more sophistocated robots in an accessible, incremental fashion. For the more adventurous hobbyist, the final chapter talks about building your own sensors and actuators, and how to connect them to the RCX.
What's Bad? Some of the photos are too dark and lack contrast. It would also have been nice if the photography had been in color, but black-and-white photos kept the book more affordable.This book is for the casual weekend robot-building tinkerer, and it never promised to discuss real-time embedded issues in depth. Still, a few topics might have merited at least brief mention. Systems with real-time multitasking must frequently arrange for synchronization and communication between tasks, using mutexes and mailboxes and the like, which brings the possibility of deadlocked processes. Another danger is that an aggressively efficient compiler will sometimes optimize away reads and writes to hardware registers. The fix is to declare such registers with the volatile keyword.
Review by Kurt DeMaagd
While Lego Mindstorms were officially released for a teenage crowd, they have become popular with a wide variety of technically competent people in many age groups. This widespread fascination has opened up a whole new world of opportunities for using Mindstorms. At the same time, the documentation and tutorial included with the Lego kits provide very little information about how to get the most out of the sets. This book fills the void by providing several start-to-finish robot designs, software to run them, and a wealth of other tips and tricks.
After a brief introduction to robotics and how Legos fit in, the author discusses the basics of using Mindstorms to create them. Both chapters present a problem, provide step by step building instructions, provide the necessary information to program the solution, and finally go into greater detail about the Lego features used to solve the particular problem.
While the chapters did an excellent job of presenting this information in general, they fell victim to a problem that would plague the entire book: some of the building diagrams were nigh unto unreadable. Attempting to build a robot based on fuzzy black and white photographs can be quite a chore. Fortunately, none of the robots were so complex that they robots were completely unbuildable.
The first few chapters presented robots programmed with the default RIS programming environment. In chapter four and following, he shows how to program using languages such as Not Quite C, Forth, Sprit.ocx for Visual Basic--or optionally Visual C++ or another ActiveX-aware language--and legOS. Since much of these sections was documenting API's, it was certainly not the most exciting read, but it does provide concise, easily to reference documentation.
Not Quite C, as the name implies, is a C-like language that can be used to program Mindstorms robots. It overcomes many of the limitations of the default RIS programming environment, most notably the lack of variables. One of its biggest advantages is that it does not require the user to install a new version of the firmware on their RCX unit. In general, it provides an excellent balance between power and usability.
The remaining three means of programming presented in the book are fairly mediocre options. PbForth requires the user to download a new firmware version, and the language itself is very archaic in modern software development terms. Using Sprit.ocx is a viable option for people used to programming in Visual Basic or Visual C++, but the control structures are very clunky and non-intuitive. legOS, while it is probably the most powerful option, takes a significant amount of time to set up and develop applications with.
Two of the projects referenced while discussing the various programming languages were particularly interesting, both of which outlined infrared communication. The first program creates a simple remote control for controlling a robot via the IR port on the RCX. The other example, perhaps the most interesting in the book, was creating two robots who played tag with each other. These two robots also communicated with each other via their IR ports.
The last chapter, targetted toward the hard core Mindstorms users outlined how to create additional sensors for Mindstorms. It sketched out such possibilities as a passive light sensor, a Hall effect sensor (magnetic fields), and a touch multiplexor (allowing you to have more touch sensors than normally allowed on the RCS unit).
In general, the book provides a vast array building and programming tips, tricks, and methods. He gives basic information for the person who is just starting, and introduces the advanced user to the vast network of people and product that have made Mindstorms far more than a child's toy.
Purchase this book at fatbrain.
Table of Contents
- Preface
- 1. Welcome to MINDSTORMS
- What is a Robot?
- Mobile Robots
- What is MINDSTORMS?
- What Now?
- Online Resources
- 2. Hank, the Bumper Tank
- About the Building Instructions
- Building Instructions
- A Simple Program
- Wheels
- Bumpers and Feelers
- Gears
- Multitasking
- Online Resources
- 3. Trusty, a Line Follower
- Building Instructions
- Some Tricky Programming
- The Light Sensor
- Idler Wheels
- Using Two Light Sensors
- Online Resources
- 4. Not Quite C
- A Quick Start
- RCX Software Architecture
- NQC Overview
- Trusty Revisited
- Online Resources
- 5. Minverva, a Robot with an Arms
- Building Instructions
- Programming
- Directional Transmission
- Pulleys
- Mechanical Design
- Two Sensors, One Input
- Where am I?
- Online Resources
- 6. PbFORTH
- Replacement Firmware
- pbForth Overview
- About Forth
- pbFORTH Words
- An Expensive Thermometer
- Minerva Revisited
- Debugging
- Online Resources
- 7. A Remote Control for Minerva
- Two Heads are Better Than One
- The Allure of Telerobotics
- Building Instructions
- Programming the Remote Control
- Programming Minerva
- Online Resources
- 8. Using Sprit.ocx with Visual Basic
- You May Already Have Visual Basic
- About Spirit.ocx
- Calling Spirit.ocx
- Immediate and Delayed Gratification
- Programs, Tasks, and Subroutines
- Tips
- Retrieveing the Datalog
- Online Resources
- 9. RoboTag, a Game for Two Robots
- Building Instructions
- Subsumption Architecture
- Online Resources
- 10. LegOS
- About legOS
- Development Tools
- Hello, legOS
- Function Reference
- New Brains for Hank
- Development Tips
- Online Resources
- 11. Make Your Own Sensors
- Mounting
- Passive Sensors
- Powered Sensors
- Touch Multiplexer
- Other Neat Ideas
- What About Actuators?
- Online Resources
- A. Finding Parts and Programming Environments
- B. A pbFORTH Downloader
- C. Future Directions
- Index
I'd like to second the idea that this book is an introduction to Mindstorms. It does have a lot of useful references, and serves as an overview of What You Can Do with Your Mindstorms. There's not a lot of time spent on any one topic.
It would be nice to have another couple of chapters on more advanced topics ("Common Traps and How To Avoid Them", "Cool Hacks You'd Never Think Of", "a Beowulf Cluster of Mindstorms"). It's a good introduction, but don't expect a LEGO Camel.
--
how to invest, a novice's guide
There are several kits available from The LEGO Company (TLC) which let you build Mindstorms-style robots; the Robotics Invention System (RIS, the Mindstorms 'basic' set) the Robotics Discovery Set (which has the 'Scout' microcomputer instead of the RCX that comes in the RIS; the Scout doesn't require a PC for you to program it) and the Droid Developer Kit (which has yet another 'Scout'-style programmable brick). These are the three robotics kits available from The Lego Company .
Available from Pitsco/DACTA is the RoboLab, a LEGO robotics kit aimed more towards the Educational sector, primarily as a teaching tool for educators looking to teach scientific-minded youths the joys of programming and the wonderment that is robotry. It's available from PITSCO/Dacta. I've ordered stuff from them online without having to prove if I'm an educator, but YMMV.
I've had the Unofficial Guide to LEGO Mindstorms for a month now, and my cats are starting to think I like my robots (Clumsy Pike and Hovis) better than them (Hydrox and Pork Chop, so they don't get jealous)(I think they've got FELUX running on my PC).
I hope that this is of some use to someone looking for the perfect gift for that geek on their Christmas list.
-The Cheese, who's next plan is to RULE THE WORLD!
PS; LEGO also sells a wireless IR remote for controlling the RCX.
PPS; Check out the online resources at LUGNET .
The Scout has only two inputs and two outputs (compared to the RCX's three apiece) but doesn't require a PC or IR tower (the IR tower is part of the RIS) to be programmed. The RCX requires that you compile your software on your PC or Mac (the RIS only provides cabling for connecting the IR tower to an 8-pin serial or [using the provided adapter] a 25-pin parallel port, but Mac adapter cables are available from PITSCO/Dacta) before downloading it to the RCX. The Scout can be programmed using the on-screen display and menus.
I would recommend the RIS with the RCX for anyone who wants to get into the guts of the matter, as this will allow you to choose your programming environment, rather than be locked into the built-in environment of the Scout.
-Cheese, who really does have a real job.