Humanoid robots are starting to gain something that once belonged firmly in the realm of science fiction: a sense of pain.