Behavior:Exercise2-Wall Following
Contents |
Setup
This exercise requires a setup similar to Reactive:Exercise2-Wall Following. This exercise is geared to the same goal as the reactive version of the exercise. However, in this exercise, we will work to split up the various aspects of this class into distinct behaviors, like in Behavior:Exercise1-Obstacle Avoidance.
Behaviors
One way to approach wall-following (there is far more than one way to approach this problem) is to split are the controller into three behaviors. The first behavior will turn the robot toward a wall when a wall is in view. The second behavior will turn the robot away from a wall when the robot is turned too close to the wall. Finally, a behavior to turn a corner when there is a wall to the front, and to the side.
Wall Attraction Behavior
This one is easy, when there is a wall to one side or to the other, turn the robot to face the wall. Also, set the robot to move forward.
Wall Alignment Behavior
For this, two sensors are required. When the front sensors on a side show the wall further away from the robot than the rear sensors, then the robot is turned away from the wall, and the robot should be turned toward the wall. When the reverse is true, the robot needs to be turned away from the wall.
Corner Turning Behavior
In this behavior, when the robot sees a wall to the front, then the robot turns to put that wall to its side. The robot should not turn in a direction where there is already a wall.
![[LOGO]](/workbook/skins/workbook/create_small2.png)



