Yes, we've seen that it
can be done. Technically.
But by and far the majority of trains are still human operated. Even though the traffic rules are very straight forward ("get out of my way, or...") and the guidance systems, robotics, CC surveillance, scheduling and logistics are 99% there in (for example) major parts of continental Europe.
So why are train services in Germany, Netherlands, France frequently canceled for lack of train drivers? I honoustly don't know the answer but I wager that return on investment plays a significant role. And I think the self-driving car rationale isn't all that different, except for the easy venture billions of the last decade(s).