Page 56 - Hacking Roomba
P. 56

Chapter 2 — Interfacing Basics            37



                             The remote control codes are undocumented in the ROI specification, but Table 2-4
                             shows the remote codes for the standard remote. There are 255 possible codes, allowing
                             for many different possible commands. The more powerful Scheduler remote likely uses
                             some of them. The RoombaComm code, introduced below and available for download at
                             http://roombahacking.com/, contains the most comprehensive list of remote codes.



                              Table 2-4  Remote Control Codes
                              Value    Hexadecimal values  Description
                              255      0xff              No button pressed
                              138      0x8a              Power button pressed
                              137      0x89              Pause button pressed
                              136      0x88              Clean button pressed
                              133      0x85              Max button pressed
                              132      0x84              Spot button pressed
                              131      0x83              Spin left button pressed
                              130      0x82              Forward button pressed
                              129      0x81              Spin left button pressed



                             Distance and Angle
                             Roomba computes the distance and angle values by watching its wheels move. This doesn’t
                             always correspond to actual motion. The two-byte values are combined into a single 16-bit
                             signed number through the standard method of:
                             value = (high_byte << 8) | low_byte
                             Or in plain English: Take the high byte, shift it up 8 bits and overlay (OR) it with the low byte.

                             Both the distance and angle are cumulative values and are cleared after they are read. This
                             means that in order to get accurate readings, they must be read often enough that they don’t
                             overflow. In practice this isn’t that much of a problem. A larger problem with not reading often
                             enough is the loss of awareness of the true motion. Distance and angle give a single vector
                             direction from point A to point B. In actuality, Roomba may have moved in a multi-point
                             zigzag motion (or any other path) between points A and B. In Chapter 6 you’ll delve into the
                             details of dealing with these issues.
                             Power Sensors
                             Figure 2-7 shows the details of the 10 bytes that make up the power systems sensor packet
                             group. Roomba spends a lot of time thinking about power, and that is reflected in this ROI
   51   52   53   54   55   56   57   58   59   60   61