Page 306 - Lego Mindstorms
P. 306

Robot 10 • RIS Turtle

                             The Logo Turtle used precise servo motors driving both wheels. This allowed
                             the speed of the wheels to be accurately controlled so the robot drove straight.
                             With LEGO, the speed of the motors cannot be controlled quite so accurately, so
                             a LEGO robot tends to drive in a wavy line. Our solution to this problem is
                             mechanical: Both wheels on the RIS Turtle are driven from the same motor, so
                             they always drive at the same speed. The way the robot turns is by shifting
                             gears on the right wheel to reverse its direction. When turning, the wheels both
                             turn at the same speed, but in opposite directions.
                                The second important feature a turtle robot must have is that it must be
                             able to measure distances when driving straight, and measure angles when
                             turning. The Logo Turtle most likely used an optical encoder (rotation sensor)
                             to accomplish this. Because you may not have a LEGO rotation sensor (the RIS
                             does not include one), we will improvise and use the light sensor pointed at a
                             rotating disk to measure distances and angles.
                                The third feature that a turtle robot must have is the ability to raise and
                             lower its pen. It is fairly straightforward to create a motorized penholder, but it
                             is important to remember that the RIS only includes two motors. One of the
                             motors must be used for driving the robot, and the second motor must be used
                             for shifting the gears to allow turning, so we need a third motor for the pen-
                             holder! Here is where some mechanical ingenuity comes in. You can use one
                             motor to do two different things with some special gearing involving the differ-
                             ential. Basically, the motor performs one function when driving forward and
                             performs the other function when reversing. We use this mechanism to allow
                             the second motor to control both the gear shifter and the penholder. All of this
                             should become apparent when you build the robot.
                                Once the robot is built, it certainly needs a program to control it. We wrote
                             a NQC (Not Quite C) program that allows users to program the RIS Turtle in a
                             way very similar to the Logo Turtle. The robot will understand commands such
                             as the following:

                             pendown();
                             forward(30);
                             right(90);
                             reverse(10);

                             You can even make the turtle robot “smart” by writing your own function such
                             as box(x), which could draw a box of any desired size:
                             void box(int x)
                             {
                                pendown();
                                repeat(4)
                                {
                                    forward(x);
                                    right(90);

                                                                291
   301   302   303   304   305   306   307   308   309   310   311