It's very complicated. Not bumping into stationary objects on the road is fairly simple with the right kind of sensors, but most obstacles you encounter in real life are neither permanently stationary nor permanently in motion, and are not always on the road.