Page 203 - Introduction to AI Robotics
P. 203

186
                                                                          5 Designing a Reactive Implementation
                                       In programming robots, people often like to abbreviate the routine por-
                                     tions of control and concentrate on representing and debugging the impor-
                                     tant sequence of events. Finite state automata force the designer to consider
                                     and enumerate every possible transition, while scripts simplify the specifi-
                           INDEXING  cation. The concepts of indexing and focus-of-attention are extremely valuable
                  FOCUS-OF-ATTENTION  for coordinating behaviors in robots in an efficient and intuitive manner. Ef-
                                     fective implementations require asynchronous processing, so the implemen-
                                     tation is beyond the scope of this book. For example, suppose a Pick Up the
                                     Trash robot boots up. The first action on the causal chain is to look for the
                                     Coke cans. The designer though realizes that this behavior could generate
                                     a random direction and move the robot, missing a can right in front of it.
                                     Therefore, the designer wants the code to permit the robot to skip searching
                                     the arena if it immediately sees a Coke can, and begin to pick up the can
                                     without even calling the wander-for-goal(red) behavior. The designer also
                                     knows that the next releaser after grab-trash exits to look for is blue, because
                                     the cue for moving to the trash can and dropping off trash is blue.
                                       The resulting script for an abstract behavior to accomplish a task is usually
                                     the same as the programming logic derived from an FSA. In the case of Pick
                                     Up the Trash, the script might look like:


                                     for each update...
                                     \\ look for props and cues first: cans, trash cans, gripper
                                     rStatus=extract_color(red, rcx, rSize); \\ ignore rSize
                                     if (rStatus==TRUE)
                                       SEE_RED=TRUE;
                                     else
                                       SEE_RED=FALSE;
                                     bStatus=extract_color(blue, bcx, bSize);
                                     if (bStatus==TRUE){
                                       SEE_BLUE=TRUE; NO_BLUE=FALSE;
                                     } else {
                                       SEE_BLUE=FALSE; NO_BLUE=TRUE;
                                     }
                                     AT_BLUE=looming(size, bSize);
                                     gStatus=gripper_status();
                                     if (gStatus==TRUE) {
                                       FULL=TRUE; EMPTY=FALSE;
                                     } else {
                                       FULL=FALSE; EMPTY=TRUE;
                                     }
   198   199   200   201   202   203   204   205   206   207   208