Page 112 - Hacking Roomba
P. 112

Chapter 5 — Driving Roomba               93



                             Radius

                             The second parameter is the turn radius value, which is specified in millimeters. This radius
                             describes a circle upon whose circumference the Roomba will drive. Driving in arcs enables
                             Roomba to make easy and efficient turns around many things like wall corners, table legs, and
                             so on.
                             Positive radius values turn the Roomba toward the left, and negative radius values turn it
                             toward the right. Postive velocity values turn Roomba in a forward direction, and negative
                             velocity values have it back up as it turns. Depending on the sign of the velocity and radius
                             values, there are four different ways the Roomba can move in a curve (see Figure 5-4).









                             -velocity              status                       +velocity
                             +radius                  power   clean              +radius








                             -velocity                max   spot                 +velocity
                             -radius                 detect   dirt               -radius







                             FIGURE 5-4: Types of turns depending on the sign of radius and velocity


                             The turn radius always makes the Roomba travel along a circle. The only exceptions to this are
                             the three special case radius values of: straight (32768, which is also known in hexadecimal as
                             0x8000), spin left (1, which is also known as 0x0001), spin right (-1, which is also known as
                             0xffff). If you’ve done a little homebrew robotics where you directly control each wheel, this
                             method of dealing with driving two motors in a robot seems a little strange. A common first
                             task in homebrew robotics is to have direct control of each wheel, allowing you to drive only
                             one wheel at a time. How is it possible to drive the Roomba in this way using the velocity and
                             radius values of the DRIVE command?
   107   108   109   110   111   112   113   114   115   116   117