"Lost sync with device, restarting" - Controlling arms and head on a robot
Hi all!
We're currently working on a project involving a Meccanoid G15KS robot. We've implemented facial detection using a Kinect Camera, and are using an arduino to control the arms and head. The goal is to make the robot wave whenever he sees a face, as well as "look" at the person.
We've managed to get it working - he can identify faces and then notify the arms to make them wave. However, we ran into a problem where the camera wouldn't stop recognizing the same face if it stayed in the camera's view for too long (which is logical), causing the robot to wave forever. To solve this, we created a boolean variable called ReadyForFace and a rostopic called wavedone. When a face is identified, ReadyForFace is set to false and this makes the robot stop looking for faces. A message is published on the servo-topic, triggering the arduino code to make the arm wave. At the end of the wave, we publish a message on wavedone, and the callback function in the face recognition node then sets ReadyForFace to true.
This (seemingly) works, but we are constantly getting "Lost sync with device, restarting...". it's also not consistent - sometimes the robot will wave twice before crashing, sometimes up to 5 times. It also seems to not be dependent on the amount of time the nodes have been running. Some initial googling revealed that too long of a delay after spinOnce() can cause rosserial to crash, so we changed it from 300 ms to 1 ms, but it made no difference.
I've attached the arduino-code aswell as the face recognition node in the pastebins below (everything is very much a work in progress):
Arduino: https://pastebin.com/GWB1kDtS Face: https://pastebin.com/J23uhVix
Help is greatly appreciated!
Best regards,