- 转载自:http://www.mlees-robotronics.in/home/robotics/wall-following-algorithm
- What is wall following?
A robot needs a reference for its movement from one location to another. One way of doing this is by following a line. The other way is to use the existing walls around us to guide the robot to move from one location to another.A robot uses the obstacle/range sensor to do this job.A robot can be designed to either follow a wall on the left side or on the right side. This is useful for solving a maze, which is similar to following the wall.
- How to follow the wall?
The simplest and efficient way for a robot to follow the wall is to use three IR obstacle sensors s1,s2 and s3 on either side of the robot. S1 and S3 is used to follow the wall, while S2 is used to maintain a safe distance from the wall at all time. A micro controller reads the IR sensor output and makes decision in the manner explained below.It is necessary to make sure at all the time, that the robot is neither far away(robot will loose its path) from the wall or too close to the wall(avoid collision).
Note: It is also possible to use a single IR/Ultrasonic range finder mounted on servo to scan the distance over a range.This is slightly a complicated design involving expensive components. We will cover this topic in the later section.
The algorithm for following the wall is explained in detail below:
For a Bot to follow and move along the wall, it is always necessary to keep its position parallel to the wall.
When a robot is parallel to the wall at a safe distance from the wall, sensor S1 and S3 are both activated. This state can be read by the micro controller and move the motors in both forward direction. This results in the robot following the wall.
When a robot starts to move away from the wall either because of the wall, or because of the change in direction of the robot, the sensor S1 is deactivated as its distance from the wall is now increased.
But the sensor S3 is still active which means , the robot is not too far off from the wall. Its just directed away from the wall. To make the robot align parallel to the wall, the robot has to move close to the wall. To achieve this Motor M2 is stopped and M1 is in forward direction.
The bot should continue in this direction till the sensor S1 is activated but not S2.
When a robot starts to move towards the wall either because of the wall, or because of the change in direction of the robot, the sensor S3 is deactivated as its distance from the wall is now increased.
But the sensor S1 is still active which means , the robot is just directed towards the wall. To make the robot align parallel to the wall, the robot has to move away from the wall. To achieve this Motor M1 is stopped and M2 is in forward direction.
The bot should continue in this direction till the sensor S3 is activated but not S2.
As mentioned earlier it is always necessary for a robot to keep a safe distance from the wall. When a robot moves too close to the wall, all the sensors S1, S2 and S3 are all activated. Now the robot has to be moved away from the wall. This is done by moving the motor M2 in forward direction and M1 being stopped.
Note:
1.The position of all the sensors need not be placed as described in the pic. The range of the sensor S2 has to be set low if all the sensors are in a straight line. If the range cannot be adjusted, then the sensor S2 can be placed at a longer distance as in the pictures.
2.Keep a low speed for better results when following the wall.