Wall Following

Wall following is a major topic of Tabletop Robotics. Wall following is the act of having a robot follow a wall without turning into it, or getting too far from it. Many methods exist in wall following, and involves both hardware and software solutions. The simplest design can be based on bump sensors, with more complex and correct solutions involving PID Controllers. This topic is involved with Maze Solving.

Placement


Range Finders can accurately detect the distance between a wall and the robot. Most range finding sensors do come with a minimum and maximum range, so be aware that the location of the sensor on the robot is important. The club recommends to place the sensor on the oposite side of the robot from the side you want to detect walls on. Thus, the distance between the sensor and the edge of the robot should be large enough such that the minimum reading distance is not an issue.

The angle placement of sensors is also critical. In most implementations, you will place your sensors parallel to the ground surface, and either perpendicular to the wall (for wall detection) or in front of the vehicle (for obstacle detection). In other implementations, to avoid certain issues discussed in the article, you may want to point your sensors slightly forward to the wall, instead of perpendicular. In other cases, you may even want to create a 90 degree angle between two sensors pointing at the wall!

Single-Sensor Design


The logic with a single range finder sensor is simple: If the robot is too far from the wall, turn towards it. If the robot is too close to the wall, turn away from it. If the sensor is within a "good" range of values, go straight. Though this might sound simple and elegant, club experience has shown this to be hard to get to correctly work. The two reasons are 1. false data interpretation and 2. incorrect vehicle turn rates.

The incorrect data interpretation means that when the robot is angled 30 degrees to the left or to the right from a wall, the distance read does not change, and thus the program has no real idea if the robot is turning into or away from the wall. The second issue, vehicle turn rates, means that you don't want a robot to keep turning into a wall if it is too far away. Having the conditional statement "if too far, turn" in your code means that your robot will continue turning until it is close enough to the wall, as though it is making a big circular turn. This is because not only will it turn faster and faster into the wall, but the sensor ranges will also get larger and larger (see graphic).



Multi-Sensor Design
To resolve this, there are two options: better sensor placement, or multi-sensor use. The first option is to place a range finding sensor such that it reads from an angle to the wall. This means that while the robot is perfectly parallel with the wall, it should be reading it at a 45 degree angle from the robot. This is done so that when you are turning into the wall, you are guaranteed to read a smaller distance, but if you are turning away, you are also guaranteed to be reading a larger distance. The only way your robot can read incorrect data is if it turns greater than 45 degrees towards the wall, which is a rare occurance.

The second solution is to use two sensors, placed in parallel, pointing to the wall. Doing this allows you to check which sensor is reading a larger distance, compare the two, and find not only the direction the vehicle is traveling, but also what kind of ratio you need to turn into / away from the walls.

PID Controllers
PID Controllers stand for proportional–integral–derivative controllers, a general-use family of controller systems. In terms of wall following, they are best at very smoothly following a wall at a set distance, intelligently making up for variable or incorrect data. They are good with a combination of the above approaches, but are not a stand-alone approach.

Source(s): PID Controllers solutions

Bump Sensors
Another wall-following technique is to wall follow using a touch or bump sensor against a wall. By having the robot "scrape" against a wall, it has its button pressed, and knows it is following a wall. If it gets too far, the button is released, and thus the robot knows to turn back into the wall. Higher-level functionality, such as making a turn on a corner, should be controlled by a Maze Solving algorithm.

This approach can be very disadvantageous for several reasons. Many robotics competitions do not allow, or severally mark down your score, for touching objects in an arena, including walls. Your robot's physical design may also be a problem with a bump-sensor approach: a box-like chassis may clip the corner of a turn and incorrectly position itself. A circular chassis may sometimes turn on itself as it rolls against the wall during an error.

For the above mentioned reasons, this is why the club does not recommend using bump sensors. On the other hand, bump sensors are very helpful for front-vehicle collisions or for checking objects on the ground.

Examples
Twitcher - Twitcher 2.0 was a robot submitted to the Trinity Firefighting Competition that did a good job wall following. The design included a front and side sensor. The side sensor was angled directly perpendicular to the left wall. The algorithm, as described in Twitcher’s article, was that it had six "turning" states for wall-following: Two for being too far or too close from the wall, two for being slightly too close or slightly too far from the wall. The final sixth state was when the robot was perfectly far enough. When the robot was only slightly too close or slightly too far, it would pulse the correct wheel to "twitch" it into the correct direction. After this quick "twitch", the system would drive straight again. This was to correct for small deviances. After any of these two state changes, the robot would ignore sensor readings for a second or two to let the new data be acquired and not to incorrectly read the distances and the robot approaches (or gets further away) from the wall. In the extreme cases of being too far or too close, the wheels would simply rotate at different speeds, until the robot thought it was "close enough".

External References

 * Simple examples of wall following algorithms and discussion