📜 ⬆️ ⬇️

Bear, the dismemberment and February 14



A teddy bear, a teddy bear - that is what increases the pulse rate of girls and detonates in the palaces of men's memory. Remember, not so long ago, not a smartphone was dragged under a blanket, but a battered, earless and one-eyed, but still beloved Mishun? Teddybir in many countries have become a universal symbol of love, care and warm teenage feelings. So when the question arose of how to congratulate colleagues on the holiday of lovers, the answer came immediately - a bear! Big robot robot - after all, it was invented by programmers.

By February 14, we decided to assemble a robotic bear that would not only be able to communicate and give people joyful hugs, but also analyze human actions. After all, hugs, both sluggish and intense, are able to give true feelings and reveal hidden emotions. Suddenly there are two people in the company who are hugging exactly the same? What if PHP programmers prefer long-term touches, and barbels are limited to dry-fingered? With the help of robomed we managed to collect the most unusual data from the life of IT people.

General theory of hugs



')
To clasp another person with his hands and to touch him for some time is one of the most common forms of manifestation of love and attention. People console with comfort and joy, communicate with each other. Free hugs are needed for children, adults, and even some animals. Our bear with the help of hugs helps staff to express feelings in honor of Valentine's Day.

Touching a bear means passing a piece of your love and some information that we use to analyze various embracing parameters. The process of positive compression of the body has several basic characteristics: pressure (force), smoothness, vigor and duration. By comparing these characteristics, we can classify any hug. It will be possible to see who is hugging the bear more strongly, or who is your “friend in hugs” - with exactly the same characteristics of hugs.



To translate this idea, we used something called the General Hugging Theory — several formulas that explain to a computer how to classify hugs. The computer perceives each hug strong or weak, sharp or smooth, short or long.

The data used in the formulas, the bear collects with the help of various sensors installed in his powerful body. So, to analyze the strength of the embrace, we use a pressure sensor installed in a mishka's chest. And in his head are an accelerometer and a gyroscope, allowing you to determine how active (energetic) were hugs.

All sensors are processed on a Raspberry Pi program written in python. Raspberry Pi is also inside the bear.

The requests that the bear sends to our intranet look like this:

POST /somewhere/hug/plot/ { "id": 12345678, "pres": 12345.0, "acc": 10.4, "gyr": 2.4, } POST /somewhere/hug/event/ { "id": 12345678, "text": "olololo" } POST /somewhere/hug/start/ { "id": 12345678 } POST /somewhere/end/ { "id": 23456789, "params": { "force": 3, "tenderness": 10, "dance": 5, "time": 10, #      } } 

Embrace metrics




The system determines which type of hugging includes recorded sensor readings using several metrics. First of all, we are interested in pressure and absolute power - they are calculated directly, because the higher the strength indicators, the stronger the embrace will be. Since hugs and exponents are distributed in time, it is possible to assess whether the hug was tender, sharp or lively. If the peak of power is smooth, then hugging is considered gentle . If the peak is smooth, but ends abruptly, it means that the person quickly released the bear - this hug is considered to be sharp . In the event that the employee began to embrace the bear sharply, but smoothly completed the process, embracing is considered to be lively .

The next most important parameter is tenderness . Taking any of the graphs and considering the delta between all readings, we determine the tenderness of the hugs. If any delta is less than the threshold value, then the person embraces quite smoothly, and such a hug can be considered gentle . If this condition was violated, we believe that the hug was more rude .



Absolutely the same mathematical principle laid for the accelerometer and gyroscope. We look at how far the deviation was made during hugging (for example, when the bear was swaying), if the amplitude of embracing is high, and how smoothly the amplitude is shifted relative to the total embracing time.



Thus, we received a set of metrics on pressure, tenderness and mobility. The embrace data is sent to our intranet, where it is stored in a common base and compared with each other, after which it is displayed in real time with the addition of information from the employee’s profile.

How does a soft cuddle




Our bear turned out to be autonomous: in addition to the Raspberry Pi, we added a wi-fi-module and powered everything from a small external battery. Bear knows who he is hugging with, since the NFC reader is embedded in him. Approaching the bear, the employee puts his pass and embraces, and all the information about the hug enters the database, on the basis of which the embracing top staff is built.


On the screen next to the bear, we display the results of mass hugs.

The bear can communicate with those who embrace him - using the built-in voice synthesizer with pre-recorded samples. In addition, from our database of employees, we unloaded all the names and voiced them. Thus, when someone from the staff wants to hug the bear, he puts his pass, and the information received from him is sent via sockets to a web page that voices the samples, “pasting” them through the Web Audio API.



In the course of the experiment, we had to constantly get into the bear: install equipment, change batteries, check sensors. Therefore, we decided to sew a zipper into a misha so as not to dismember it each time.

So from the club of anonymous bear lovers, we turned into a fighting embracing squad, who in his spare time gathered for all employees a real love machine - because it is impossible not to fall in love with a white teddy bear, who welcomes you by name and knows how hard and caring you are you can squeeze it.



Happy Valentine's Day, Habr! All strong, energetic and long hugs!

Source: https://habr.com/ru/post/277105/


All Articles