Waymo, the self-driving car unit of Google’s parent company Alphabet, has shared how it’s been training its vehicles to automatically identify emergency vehicles.

The human eye is fairly adept at observing where a flashing blue light is coming from and heading too, while the human ear can usually narrow down a siren to a rough location behind or in front. With eyes and ears combined, human drivers are generally good at manoeuvring out of the way of oncoming ambulances, police vans, and fire trucks.

But throwing self-guiding vehicles into the mix poses potential problems, which is why Waymo has been working specifically on this challenge.

Though Waymo states that it has been teaching its self-driving cars to respond appropriately to emergency vehicles for a number of years already, it’s now ramping up these efforts in partnership with the police and fire departments of Chandler, Arizona.

Last week, Waymo arranged what it called its first emergency vehicle testing day, using its recently unveiled autonomous minivans.

The minivans observed myriad emergency vehicles, including police cars, motorcycles, ambulances, and even “a few undercover vehicles,” according to a blog post.

“As these emergency vehicles drove around, our sensors collected samples at various speeds, distances, and angles — all with the goal of building up a library of sights and sounds to help teach our self-driving cars to respond safely to emergency vehicles on the road,” the company explained.

Certainly, one of the greatest challenges facing the fledgling self-driving car industry is the speed and accuracy with which autonomous vehicles can respond to the environment around them. Countless companies have emerged to try to improve cars’ visual capabilities — Intel recently shelled out more than $15 billion to acquire Mobileye, which develops the visual smarts behind cars’ driving assistance systems.

Safety will be a crucial factor if self-driving cars are to become mainstream, so their onboard sensors — which serve as vehicles’ eyes and ears — need to be brought up to speed.

Waymo says it’s teaching its software to be able to distinguish between sirens that are coming from behind or ahead — audio cues, after all, are usually the first indicator that an emergency vehicle is approaching. “Our vehicles may pull over if an emergency vehicle is coming from behind, but yield at an intersection if our sensors detect sirens coming up ahead,” Waymo said.

In addition to improving its audio detection system, Waymo also noted that its on-board vision system is now better equipped to spot flashing lights from further away.

“These advanced sensors allow us to both reliably detect emergency vehicles in real time, and collect better information to train our software,” the company said. “That way, when we’re on the road, we can recognize an emergency vehicle even if we’ve never encountered it before — or if it appears differently because of the angle or lighting conditions.”