Page 147 - Introduction to AI Robotics
P. 147

130
                                            outputVector.direction=0.0               4 The Reactive Paradigm
                                            outputVector.magnitude=0.0
                                        }
                                        return outputVector;
                                      }



                                       At this point, it is easy to illustrate how a potential field can be used by a
                                     behavior, runaway, for the robot with a single sensor. The runaway behav-
                                     ior will use the repulsive() function as the motor schema, and a function
                                     readSonar() as the perceptual schema. The output of the behavior is a
                                     vector. runaway is called by the robot on every update cycle.



                                      vector runaway( ){
                                         double reading;
                                         reading=readSonar();//perceptual schema
                                         vector=repulsive (reading, MAX_DISTANCE); //motor schema
                                         return Voutput;
                                      }
                                      while (robot==ON)
                                      {
                                         Vrunaway=runaway(reading); // motor schema
                                         turn(Vrunaway.direction);
                                         forward(Vrunaway.magnitude*MAX_VELOCITY);
                                      }





                              4.4.5  Combination of fields and behaviors

                                     As stated earlier in the chapter, the first attribute of a true potential fields
                                     methodology is that it requires all behaviors to be implemented as potential
                                     fields. The second attribute is that it combines behaviors not by one sub-
                                     suming others, but by vector summation. A robot will generally have forces
                                     acting on it from multiple behaviors, all acting concurrently. This section
                                     provides two examples of how multiple behaviors arise and how they are
                                     implemented and combined.
                                       The first example is simple navigation, where a robot is heading for a goal
                                     (specified as “10.3m in direction  ”) and encounters an obstacle. The motor
   142   143   144   145   146   147   148   149   150   151   152