This isn't by any means a new topic; Asimov codified it in his famous Three Laws back in 1942; and Wired ran an article in 2005 that considered some of the broader ethical implications of introducing ever-more-humanoid machines into society.
There now seems to be a burgeoning discussion on this topic, spread widely:
* Illah Nourbakhsh's lecture (below) has spawned a CMU class: http://ethicsandrobotics.posterous.com/
* Patrick Lin (along with George Bekey and others) at Cal Ploy SLO's Ethics + Emerging Technology Group have authored several good papers, with some intro and discussion at the Stanford Law Center for Internet and Society.
* There are several interesting blogs covering this area, such as moral machines
AxiDraw in the Wild - plotter vids as a service. pic.twitter.com/S0o0bUwe0s — anders hoff (@inconvergent) July 21, 2016 We’re excited to see so many people sharing what they are...
16 hours ago