running rossserial on an Arduino MKR ZERO
What is the recommended way to get rosserial
to work on an Arduino MKR ZERO board?
My experience is rosserial
runs without issus on an Arduino UNO but rosserial
fails on an Arduino MKR ZERO.
I'm on Ubuntu 20.04 connected via USB to an Arduino MKR ZERO. When I run rosrun rosserial_python serial_node.py /dev/ttyACM0
I get this error:
[ERROR] [1659201314.552018]: Unable to sync with device; possible link problem or link software version mismatch such as hydro rosserial_python with groovy Arduino
The Arduino IDE can successfully download/run an example ROS command on my Arduino ZERO. But rosserial_python serial_node.py /dev/ttyACM0
on that board always gets the above error. I checked the baud rate using stty -F/dev/ttyACM0
. I tried setting various baud rates (9600, 57600, 11520, etc.) in the command; eg, rosrun rosserial_python serial_node.py /dev/ttyACM0 _baud:=57600
. It always gets the error.
I can get it to work following Capt_Crunch's suggestion in Rosserial_python on samd21. It looks to me like his code uses SerialUSB instead of the other serial classes. Should that be part of ROS?
FWIW: as best I can tell this applies to all the Arduino boards using the SAMD21 / Cortex MO; eg, Arduino Zero, MKR-ZERO, MKR-1000, MKR-1010, etc.
DETAILS
I'm following the instructions in How to Connect Arduino to ROS. In summary:
- Download the Arduino IDE
- follow these instructions for installing the Arduino IDE on Ubuntu
- Go to this website, and download the software
- extract the tar and install
- Run a sample Arduino (non-ROS) command on the MKR board
- Go to File – > Examples -> 01.Basics, and choose Blink.
I ignore the VirtualBox instructions since I'm already directly running on Ubuntu.
Install ROS
sudo apt-get install ros-noetic-rosserial-arduino
sudo apt-get install ros-noetic-rosserial
Start ROS and run a sample ROS command
roscore
- Go to File -> Examples -> ros_lib and run Blink
- this works
Run a ROS node that accepts commands to toggle LED
rosrun rosserial_python serial_node.py /dev/ttyACM0
- this works on an UNO
- this fails on an MKR ZERO without the patch
- this works on an MKR ZERO with the patch
Run a ROS command to send a toggle LED command (once the node above is working)
rostopic pub toggle_led std_msgs/Empty --once