Questions about spinOnce() and link problem with Arduino Due

asked 2018-06-08 02:59:11 -0600

ycchen gravatar image

Hi, I'm trying to build communication between my PC (ubuntu 16.04) and Arduino Due. I follow rosserial tutorial and run the "helloworld" example, then confused by two questions.

  • Q1: After every effort to fix the error message "Unable to sync with device", it still comes up once though the link finally succeeded. I've added #define _SAM3XA_ and #define USE_USBCON before #define <ros.h> according to other discussion in the forum and the comments in Arduinohardware.h, and the baud rate is properly set to 9600 on both sides. The result seems to be fine: it does work, but the error still occurs once (as shown below). I think it could just be explained as the failure of requesting topic at first try, so it keeps trying and finally succeeds, but I'm still wondering how it happens.

ycchen@ubuntu:~$ rosrun rosserial_arduino serial_node.py _port:=/dev/ttyACM0 _baud:=9600
[INFO] [1528440034.212783]: ROS Serial Python Node
[INFO] [1528440034.215776]: Connecting to /dev/ttyACM0 at 9600 baud
[INFO] [1528440037.920751]: Requesting topics...
[ERROR] [1528440052.922209]: Unable to sync with device; possible link problem or link software version mismatch such as hydro rosserial_python with groovy Arduino
[INFO] [1528440052.922912]: Requesting topics...
[INFO] [1528440054.055047]: Note: publish buffer size is 512 bytes
[INFO] [1528440054.055647]: Setup publisher on chatter [std_msgs/String]

  • Q2: What's the function of spinOnce() in the sketch "helloworld"? My understanding is that spin() or spinOnce is associated with callback function, which is used by a subscriber, but in the "helloworld" case, only a publisher is created. Is it my misunderstanding of spin() and spinOnce()? Or the sketch is more complicated than just including a publisher?

I appreciate every reply!!

edit retag flag offensive close merge delete