Teaching robots how to hug a person properly is easier said than done. This video from ASU Interactive Robotics shows how a robot teddy bear used an improved Bayesian Interaction Primitives (BIP) approach to learn how to huge a person. It can learn to adapt to different people.
The code and examples for this framework are available on GitHub.