LegOS HOWTO

Luis Villa

luge@users.sourceforge.net

Revision History
Revision 0.2.4October 22nd, 2000

About LegOS

To quote the official LegOS homepage, maintained by the author, Markus L. Noga, LegOS is an

independent LEGO Mindstorms OS. Offers preemptive multitasking, energy saving, dynamic memory management, POSIX semaphores, native access to display, buttons, IR communication, motors and sensors.

In contrast to the standard Lego Group software, LegOS offers serious programmers the ability to write programs for the Lego Mindstorms in C and C++, with few significant limitations. Among the benefits cited by Markus (in comparison to the standard software):

  • "User tasks are executed as native code, not interpreted."

  • "More memory. Forget 32 variables. Think 32k."

  • "Full-featured language. Use the same gcc that compiles Linux." The standard software uses graphical building blocks instead of a text-based language.

  • "Priority-based preemptive multitasking."

  • "Real process synchronization with POSIX semaphores."

  • "Fine-grained hardware control: complete LCD control, raw mode IR."

I'll add:

  • Random number generation. Real unpredictability.

  • Floating point math- use doubles and floats without problems.

  • Multiple programs. You can now store up to eight programs on your RCX at once, and choose between them.

However, there are certain limitations (which is why this is a programmer's tool for the Mindstorms!):

  • "System is unstable - this is beta." I'll add that 0.2.4 is the most stable release of legOS yet- some small but persistent bugs have finally been eliminated.

  • "GCC and binutils required."

  • "C programming knowledge required."

About this LegOS HOWTO

This is the second major revision of the legOS HOWTO. When I started playing with LegOS, I had no experience with LegOS, and was very rusty with what rudimentary C I had. At that time, there was no documenation for legOS, other than the API docs. As a result, it took me a while to get up to speed, particularly since I was learning both LegOS and the RCX at the same time. With that experience in mind, I wrote the HOWTO as an intro to legOS and the RCX.

This is not intended to be a full technical manual. The API documentation at http://legOS.sourceforge.net/API/ fills that role. In cases where the API documentation is lacking (it is auto-generated, and sometimes it shows), the code itself is very well documented for those who are more technically inclined. Rather, the HOWTO is directed squarely at an audience with no RCX experience, and only barely above intro-level C or C++ experience- i.e., a grasp of most programming concepts and data structures, but not necessarily more advanced topics like threading and semaphores. This pretty much describes a class of intermediate level CS students who have just had an RCX plopped in their lap for a class, or someone who is interested in the RCX but doesn't have access to a Windows machine to run the Lego Group software. I am a member of the Windows free group myself, and I hope that CPS 196 was not the last class of its type. My goal for this HOWTO is to serve as a "quick start" guide for these (and similar) groups, or a companion to the source for anyone who is more advanced.

Just because I've focused on beginners for now does not mean that I don't want the HOWTO to cover advanced topics. I'm very open to this, since I hope anyone who gets a start from this will use the time I've saved them to do more than just simple projects. Unfortunately, however, what little progress I had made was basically clobbered by the switch to 0.2.x. At the moment, my most glaring area of ignorance is the legOS Network Protocol, but there are other areas as well. Anyone who has done these things and wants to contribute for the more advanced reader (as well as my own edification) is welcome to.

About the Author

The author is a college student with not as much time on his hands to play with Lego as he would like :) He can be contacted at , except during college basketball season, when he can usually be found on or around ESPN.

I try to respond to all emails; however, this is not always possible. If you have a general legOS question (as opposed to one specifically about the HOWTO) then you are much better off asking the fine people at . I'm usually one of them, so you'll get me plus lots of other developers at the same time.

Document Source

This document is now maintained in the DocBook format. The DocBook source is available here. If you want to do serious work on the HOWTO, I suggest sending me patches against this source. To find out more about DocBook, I suggest reading DocBook: The Definitive Guide or (more concisely) the LDP Author's Guide.

Acknowledgements

  • Markus L. Noga, for writing LegOS.

  • Kekoa Proudfoot, for doing much of the early internals workthat allowed LegOS to be written. (Check out his RCX Internals Page.)

  • Dave Baum. Dave gave me the opportunity to spend a summer working mainly on legOS, which gave me the time to re-write the HOWTO and assume maintainership of the program. The outcome of this opportunity was the book Extreme Mindstorms, which you can now buy from Amazon. This is a pretty shameless plug, but I'm very proud of the book and it offers some serious insight into the kinds of things you can do with legOS.

  • Dr. Michael Littman (formerly of Duke, now at AT&T), who allowed me to fulfill a childhood dream by getting paid to play with Lego.

  • The entire community at lugnet.com, without whom there would have been only the smallest of audiences (and the most minimal of advice) on the writing of this HOWTO.

  • VA Linux, who sponsor sourceforge.net, which makes it possible for all legOS work to be housed (for free!) under one roof. If you run a Free Software project of your own, I strongly recommend looking into Sourceforge, especially if you want to distribute large binaries or data files and face charges for bandwidth use on your normal ISP.