That seems to be an order of magnitude simpler issue to solve, and yet we don't seem to be there yet. Granted, forms of automation have penetrated that industry - deadmans switches, automated signalling and such. But there's still a human at the helm of every freight loco.
Smaller scale urban light rail deployments seem to have got close to full automation, presumably due to being able to embed all the necessary elements into the end-to-end installation of the system (signalling, stock, cameras/sensors etc).
How can the kind of full automation that would put truck drivers out of work, arrive before the kind that would put train drivers out of work?