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

113


          This might be useful, for example, in a robot with a "skirt" touch sensor that runs around the entire robot. Different parts of the
          sk irt might trigger different touch sensors. By putting all the skirt sensors on one input, you could easily detect any collision
          with the skirt, anywhere around the robot.

          The downside, of course, is that you don't know which touch sensor is being pressed. There's a way around this problem, of
          course, but it involves using a soldering iron. I'll explain how it works in Chapter 11, Make Your Own Sensors.

          L ight and Touch

          M inerva uses a light sensor and a touch sensor on one input. The input is configured for a light sensor. When the touch sensor
          is not pressed, it has no eff ect on the light sensor reading. When the touch sensor is pressed, the input gives a value of 100; the
          c urrent value of the light sensor becomes irrelevant.

          Usually the light sensor shows  values in the range of 30 to  70, roughly speaking; the readings depend on the lighting
          co nditions around the  sensor. You'll rarely see a real light sensor reading  of  100  unless you  point  some very bright light
          directly into the sensor . In general, it's safe to assume that readings of 100 correspond to the touch sensor being pressed.

          Minerva's program must account for  the two sensors being attached to one input. In particular, the touch sensor must normally
          be  not pressed. In the  grab()  and  release()  subroutines, for  example,  the  grabber  arm  motor is run forward or in
          reverse until the touch sensor is triggered. Then the motor must be run the other w ay briefly so the touch sensor is no longer
          p ressed. This allows Minerva to observe values from the light sensor.

          W here Am I?

          You've probably discovered that Minerva gets lost easily. If she drives over anything, or if her wheels slip in any way, she can't
          find her way back to her starting point. Minerva, basically, is trying to answer the question "Where am I?" Unfortunately, she
          can't answer it very well.

          Timing

          Minerva  uses  a fairly unreliable technique, called  timing,  to determine her current position. She moves forward for some
          amount of time until she finds something to pick up. Then she turns around by spinning in place for a length of time defined in
          TURNAROUND_TIME. Then she drives back to her starting point by moving forward for as much time as she moved forward
          before. If Minerva drives forward for
   119   120   121   122   123   124   125   126   127   128   129