Throwing up our hands about how hard a problem this is seems like a ridiculous position to stake. If we can design self-driving cars, that operate safely in far less controlled environments, we can figure out the linear offset of a large vehicle traveling along a physical rail running along a fixed pre-determined path.
Self-driving cars aren't supposed to drive quicker than they can look ahead, which makes the problem way easier because you don't have to figure out how to detect obstacles ahead of time and can simply rely on vehicle-local information to stop if necessary. And because cars can brake way more rapidly than trains, it means you can still drive reasonably quickly even within that limitation.
Plus in an emergency, cars have steering as an additional degree of freedom to attempt getting out of any nasty situation that may have developed.
(And of course the socially expected safety standards for cars are quite a bit lower than for public transport…)
Trains on the other hand have braking distances on the order of a kilometre or so, and high-speed trains at full speed several kilometres, so trying to get by on local data only is hopeless and the usual strategy is instead having central signalling system that can accurately track trains and coordinate their movements.
> If we can design self-driving cars
We can not design self-driving cars to the safety standard that is required for railways. They are way less safe than the current half-manual system for railways. What you suggest is using less automatic safety systems than what we currently do.
That is completely false. PTC does that, and we've had it for several decades. There are several self-driving cars operating in the world right now. I have never heard of a PTC system causing accidents; those occur in places where the system isn't required (like entering Grand Central).
You keep pretending that avoiding train collisions is too magical to achieve with current tech, but train traffic is easy to limit (but slightly harder to optimize), and systems exist to do that, because rail is unique amongst all forms of travel: if you drop speed to zero for any trains at risk of collision, they are safe. Planes will plummet; most cars are human-operated and you can get rear-ended, etc.