Originally Posted by
florin
The train doesn't have to 'sense' when to open the doors any more than it senses when to activate the open/close button. It is the conductor who activates the buttons, who could instead open ALL the doors.
If, indeed, there is a conductor or guard on board. Many trains in the UK are driver-only operated, and traditionally rely on either on-board or station CCTV (or mirrors, in older cases). More modern trains additionally use GPS to ensure the doors are not accidentally activated outside of a station.
(Which caused all sorts of problems for stations in tunnels when it was first introduced...)
Mind you, in the UK, there's still slam-door trains doing 125mph up and down the country...