Waiting for a traffic light turning green is never fun! But what if there was a world without any traffic lights? Well, when all cars on our roads are self-driving then it's possible to create an intersection without any traffic lights. This idea is called Autonomous Intersection Management.
So how is it working? The basic idea originates from the report A Multiagent Approach to Autonomous Intersection Management. But the version you can test here is more complicated as each car is more realistic and not just a mathematical model of a car.
The basic idea is that each car knows where it is going, such as driving forward or turning left, so it has a path through the intersection with waypoints. When the car is close to the intersection, the intersection checks if the path through the intersection is clear by using the car's velocity and acceleration. If the first car that has arrived to the intersection can't find a clear path, the intersection checks if next car in the queue can find a clear path, and so on. The problem now is that the first car in the queue might wait for a path for an infinite amount of time. To solve this, there's a timer saying that if the first car in the queue has waited for x seconds, then the intersection should prioritize this car until it finds a path through the intersection.
If an emergency vehicle arrives, the intersection prioritizes all cars in the same lane as the emergency vehicle until the emergency vehicle has entered the intersection. It will at the same time prioritize all cars in the lane next to the lane the emergency vehicle is in because those lanes will never cross in the intersection.
You can find a more detailed explanation of the algorithm here: No-more red traffic lights!.
...and follow me on Twitter: @eriknordeus