Engineers working on self-driving technology have given a lot of thought to difficult questions over the years, including how to keep pedestrians safe and how to avoid collisions with other vehicles.