We're building robots that can walk and talk like us, but now we're giving them another a human quality you might not expect: the ability to feel pain. If nothing else, it should give us a chance if they ever try to overthrow humanity.

The researchers behind the technology think pain-sensitive robots are worth developing so they can keep themselves - and the humans working with them - safe from harm. If there's a threat to a robot's gears or motors, for example, it can take evasive action.

"Pain is a system that protects us," one of the team, Johannes Kuehn from Leibniz University of Hannover in Germany, told Evan Ackerman at IEEE Spectrum. "When we evade from the source of pain, it helps us not get hurt."

With that in mind, Kuehn and his colleague Sami Haddadin are developing what they describe as an "artificial robot nervous system" for the job.

For the system to work, it needs to be able to both sense sources of pain (like a flame or a knife) and figure out what to do about it (an appropriate reflex action). The pair are using the human nervous system as their inspiration.

They've have tested out some of their ideas using a robotic arm with a fingertip sensor that can detect pressure and temperature. It uses a 'robot-tissue' patch modelled on human skin to decide how much pain should be felt and thus what action to take.

If the arm feels light pain, it slowly retracts until the pain stops, and then returns to its original task. Severe pain, meanwhile, causes the arm to go into a kind of lockdown mode until it can get help from a human operator.

Keeping people safe is just as important, Kuehn and Haddadin say, especially as we're likely to see more robots operating alongside human workers in the coming years - if a robot is taught to recognise and react to pain, it can warn everyone around it.

"Getting robots to learn is one of the most challenging things but is fundamental because it will make them more intelligent," robotics expert Fumiya Iida of Cambridge University in the UK, who wasn't involved in the research, told the BBC. "Learning is all about trial and error. When a child learns that falling over causes pain, it then learns to do it with more skill."

This isn't the first time researchers have decided to try to humanise robots. Earlier this year, a US Defense Advanced Research Projects Agency (DARPA) sponsored started teaching robots empathy by making them read children's books, which is just one of many other DARPA projects that aim to make robots understand right and wrong. 

Kuehn and Haddadin's work is ongoing, but the pair have presented a paper on their experiments so far to the IEEE International Conference on Robotics and Automation (ICRA) in Stockholm, Sweden. Eventually, their work could lead to robots that are more human-like than ever.