Page 64 - The Unofficial Guide to Lego Mindstorms Robots
P. 64

53


          4
          Not Quite C


          In  this chapter:


          • A Quick Start


          •  RCX Software Architecture


          •  NQC Overview


          • Trusty Revisite d


          • Online Resources


          O nce you've written a few programs in RCX Code, it feels a little constrictive. For one thing, there aren't any variables. It
          would be nice if your robot could remember things, like how many obstacles it's encountered or what the temperature was
          three minutes ago. In RCX Code, the only thing remotely resemblin g a variable is the counter. Back in Chapter 3, Trusty, a
          Li ne Follower, I used the counter to remember which way to turn. The counter was always a 0 or a 1, indicating whether the
          ro bot should turn left or right. But it's toug h going, and if you try anything more complicated, the counter is not going to get
          the job done.

          The lack of variables is only o ne of the limitations of RCX Code. Two other important limitations are:

          • Although you  can define subroutines (called "My Commands"), y ou can't call one subroutine from another. Likewise, a
          subroutine can't call itself.

          • You can't control the RCX's display very well. It would  be really nice, for debugging purposes, to be able to show values on
          the display.

          The LEGO Group aimed the Robotics Invention System at p eople who had never programmed before. For this group, RCX
          Code is a gentle way to get started with programming mobi le robots. But RIS is exceedingly popular with programmers and
          other technically savvy people, who are frustrated by the limi tations of RCX Code. If you're reading this chapter, this probably
          includes you.

          Since RIS was  released  in  the Fall of  1998, the  MINDSTOR MS community has produced an amazing stream  of clever,
          innovative software designed to overcome the limitations of RCX C ode. Most of this software is available, free of charge, on
          the Internet. In this chapter, I'll describe one of the most popular p ackages: Not Quite C (NQC). NQC allows you to write
          programs for your RCX with a text-based language. I'll descri be the syntax and commands of this language, with copious
   59   60   61   62   63   64   65   66   67   68   69