In this demonstration, the green vehicle shows path following behavior. Its task is to traverse the path in a given direction (entering on the left, exiting on the right) while keeping its center on the gray region. In this case the path is defined by a series of connected line segments (a polyline) and a radius. This behavior is related to containment and wall following but differs because the path implies a direction of travel.
Path following is implemented here by performing corrective steering only when the vehicle begins to head off the gray region. A prediction of the vehicles future position is made based on its current velocity (red dot). This predicted future position is mapped onto the nearest point (red circle) on the path spine (black line). When the distance between these points exceeds the path radius (indicated by a red line) corrective steering is required. (In the diagram presented here, an equivalent condition is that the red dot moves outside the grey region.) Corrective steering is obtained using seek behavior on a target point further down the path. The vehicle's position is mapped into a distance along the path, that distance is incremented by speed-proportional amount, and converted back to a target point on the path (white circle). Note that for a very smooth path, the red circle could be used as the seek target, while the method shown here works well for unsmooth paths.
A non-zero path radius produces a sort of "sloppy path following". That is, the path following goal is considered to be met as long as the vehicle is within a certain neighborhood of the path spine. The path following requirement can be made more strict by reducing the radius toward zero. In general, the vehicle cannot be forced to always be exactly on the path if the path can change direction faster than the vehicle (as shown here, where the path makes sharp corners).
This path following implementation is based on a generic path protocol: mapping an arbitrary point to one on the path, converting from an arbitrary point to a distance along the path, and vice versa. As a result, the steering behavior needs no knowledge of the path's shape.