Page 152 - Introduction to AI Robotics
P. 152
135
4.4 Potential Fields Methodologies
multiple range sensors? Bigger obstacles will be detected by multiple sensors
at the same time. The common way is to have a RUNAWAY behavior for each
sensor. This called multiple instantiations of the same behavior. Below is
a code fragment showing multiple instantiations; all that had to be done is
add a for loop to poll each sensor. This takes advantage of two properties
of vector addition: it is associative (a+b+c+d can be performed as (( a + b) +
c) d), and it is commutative (doesn’t matter what order the vectors are
+
summed).
while (robot==ON) {
vector.mag=vector.dir=0.0; //initialize to 0
for (i=0; i<=numberIR; i++) {
vectorCurrent=Runaway(i); // accept a sensor number
vectorOutput = VectorSum(tempVector,vectorCurrent);
}
turn(vector.direction);
forward(vector.magnitude*MAX-VELOCITY);
}
As seen in Fig. 4.19, the robot is able to get out of the cave-like trap called
BOX CANYON a box canyon without building a model of the wall. Each instance contributes
a vector, some of which have a X or Y component that cancels out.
From an ethological perspective, the above program is elegant because it
is equivalent to behavioral instantiations in animals. Recall from Ch. 3 the
model of rana computrix and its real-life toad counterpart where each eye
sees and responds to a fly independently of the other eye. In this case, the
program is treating the robot as if it had 8 independent eyes!
From a robotics standpoint, the example illustrates two important points.
First, the direct coupling of sensing to action works. Second, behavioral
programming is consistent with good software engineering practices. The
FUNCTIONAL RUNAWAY function exhibits functional cohesion, where the function does one
COHESION thing well and every statement in the function has something directly to do
with the function’s purpose. 122 Functional cohesion is desirable, because it
means the function is unlikely to introduce side effects into the main program
DATA COUPLING or be dependent on another function. The overall organization shows data
coupling, where each function call takes a simple argument. 122 Data coupling
is good, because it means all the functions are independent; for example, the
program can be easily changed to accommodate more IRs sensors.