These systems are known as ‘Advanced Driver Safety Assistance Systems’ or ADAS, which are in-car technologies, using cameras, ...
Radar sends out electromagnetic (EM) waves rather than rubber balls, but the principle is analogous – we measure the reflections and use it to calculate the position of objects relative to the radar.