Page 117 - The Unofficial Guide to Lego Mindstorms Robots
P. 117
106
Now she wants to turn around and return to her starting point. To turn around, she simply reverses the direction of output C for
the duration given by TURNAROUND_TIME:
OnRev(OUT_C);
Wait(TURNAROUND_TIME);
Now she drives back to her starting point, using the returnTime value, which was saved earlier:
OnFwd(OUT_C);
ClearTimer(0);
until (Timer(0) >= returnTime);
Off(OUT_C);
Finally, the retrieve() subroutine drops the object that Minerva's carrying and turns around again:
release();
OnRev(OUT_C);
Wait(TURNAROUND_TIME);
T he main task configures Minerva's inputs and then calls retrieve() five times in a row. If everything works perfectly,
which it probably won't, Minerva finds five dark objects and brings them back to her starting point. In the next section, I'll
explore some of the things that can confuse Minerva.
Try It Out!
To take Minerva out for a spin, I suggest using the back of the Test Pa d that comes with RIS. It acts as a mostly uniform bright
surface. Put the Test Pad on a hard, flat surface. Different surfaces will give you different r esults. In particular, you may need
to adjust the TURNAROUND_TIME constant to make Minerva spin around 180°. Scatter some black blocks on the back of the
Test Pad and start Minerva running. If you're lucky, she'll go pick up some blocks and bring them back to her starting point.
There are quite a few things that can go wrong:
1 . Minerva may not ''see" the dark blocks to pick them up. I found that I got better results after the RCX was on for a minute or
two—the sensor values depend on the battery power, which stabilizes after the RCX is on for a while.
2. Minerva's wheels may stumble on the blocks, throwing her off course. Instead of driving and returning on a straight line,
Minerva will now be pointing in a different direction. She probably won't bring blocks back to her original starting point.
3. The grabber doesn't always pick up the block Minerva is aiming for.