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

Rosserial_python on samd21

asked 2019-07-17 03:52:39 -0600

Capt_Crunch gravatar image

updated 2019-07-17 06:19:34 -0600

gvdhoorn gravatar image

Hi, I am using a "modified" version of rosserial_arduino so that it works with samd21 chip. I can send/receive topics and services successfully using the terminal, but when I try to receive a topic from a ros package, it doesn't work! To be more exact, the steps I am doing are.....

  1. Upload a simple subscriber and a publisher to my samd21 chip.
  2. Connect to it using rosserial_python (this step is successful)
  3. publish a topic from the terminal using rostopic pub .......
  4. the samd21 chip listen to the topic and relays it back (using its publisher)
  5. listen to the published topic using rostopic echo... The mentioned procedure works fine, I am trying it currently with std_msgs/Bool

However, when I try to publish the a topic from a rosnode (my custom package), rosserial_python gives me multiple errors:

Mismatched protocol version in packet: lost sync or rosserial_python is from different ros release than the rosserial client
Protocol version of client is Rev 0 (rosserial 0.4 and earlier), expected Rev 1 (rosserial 0.5+)
wrong checksum for topic id and msg
wrong checksum for topic id and msg

And the errors keep on repeating (not always in the same order).

Any idea what is causing this? I have the same versions of rosserial_python and rosserial_arduino: 0.7.7

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2019-07-17 08:09:46 -0600

Capt_Crunch gravatar image

updated 2019-07-17 08:10:57 -0600

I think I have found the solution, I added sleep() inside the loop after spinOnce() and it seems to do the trick. The weird thing is that it works fine without the sleep with normal AVR arduinos, but not with the zero (samd21) ones. I will update my answer if I find the root of the problem.

edit flag offensive delete link more


Where did you get a SAMD21-compatible rosserial library? Looking for one myself.

howardcochran gravatar image howardcochran  ( 2019-08-29 15:53:48 -0600 )edit

Hi... I am also looking for a SAMD21-compatible rosserial library. Would you mind to share the link here.

fsado gravatar image fsado  ( 2021-10-28 06:54:36 -0600 )edit

Hi. It has been a while since the post, so I don't remember exactly the steps. From what I recall, you have to generate the "ros_lib" folder first, then adjust the "ArduinoHardware.h" file for SAMD21, that should work. You can find the modifications I made on this link:

Capt_Crunch gravatar image Capt_Crunch  ( 2021-11-01 04:56:31 -0600 )edit

Thanks so much Capt_Crunch! This worked for me. This should be part of ROS. I found it very frustrating that I could load a ROS program into my MKRZero thru the Arduino IDE but no other ROS nodes could communicate with it.

BrianS gravatar image BrianS  ( 2022-07-29 22:32:19 -0600 )edit

answered 2022-07-30 11:43:02 -0600

BrianS gravatar image

updated 2022-08-01 16:24:20 -0600

For others: this is how I used Capt_Crunch's fix on Ubuntu:

1) I followed the steps in How to Connect Arduino to ROS to try out a simple ROS node that toggles the Arduino LED. It all worked for me with an Arduino UNO. However, using my MKR-Zero the rosrun rosserial_python /dev/ttyS0 command failed to communicate with the node. This is the error message I got:

[ERROR] [1659388887.198154]: Unable to sync with device; possible link problem or link software version mismatch such as hydro rosserial_python with groovy Arduino

2) To find out where my ArduinoHardware.h file was I looked at the Arduino IDE "Sketchbook location:" in the under File->Preferences. In the "Sketchbook location:" dir I edited libraries/ros_lib/ArduinoHardware.h. To verify I had the right file I first added a line of code that obviously would not compile. When I tried to upload the toggle LED program the Arduino IDE verified the Python code but the upload (compile phase) failed. Then I removed the line and the upload worked.

3) To find Capt-Crunch's fix I looked in his repository at his ArduinoHardware.h file. I found the code in the #if defined(SAMD21) section. Note: in that code it hardcodes the baud to 250000.

4) I added that section (plus the #endif) to my ArduinoHardware.h file changing the #if defined(SAMD21) to #if 1

5) I then uploaded the toggle LED node through the Arduino IDE and the rosrun rosserial_python /dev/ttyS0 _baud:=250000 worked


(Additions keywords so google can point people to this: MKR MKRZero MKR-Zero Zero MKR1000 MKR-1000 MKR1010 MKR-1010 Cortex M0)

edit flag offensive delete link more

Question Tools


Asked: 2019-07-17 03:52:39 -0600

Seen: 502 times

Last updated: Aug 01 '22