ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

"Lost sync with device, restarting" - Controlling arms and head on a robot

asked 2017-04-06 07:39:38 -0500

Meccanoid gravatar image

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,

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2017-04-08 11:50:16 -0500

Wolf gravatar image

updated 2017-04-08 11:50:57 -0500

There are still many delays in your callback. The error message means that your device has Not answered the serial node in your Host PC for couple of seconds. The answer happens Insider spinOnce. But your callback takes at least 2,5 seconds. During this time the Arduino can Not sync with your PC.

Either decrease the delays or (netter) move the control Code to your main loop and Set Up Dome Kind of state machine that ist started by a flag Set in the subscriber callback and then Starts the First command, then loops (and calls spinOnce) For 500 seconds, then starts the second command, then loops (and calls spinOnce) For 500 seconds, then starts the third command .....

As The Arduino Code ist completely sequential the Long delays May cause a Missing sync whereever placed, Not Just in the Main loop. Therefore ist ist better to avoid Them

edit flag offensive delete link more

Comments

Or you can move the spinOnce method in your loops

adiManav gravatar image adiManav  ( 2021-12-21 04:45:57 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2017-04-06 07:39:38 -0500

Seen: 2,182 times

Last updated: Apr 08 '17