Ask Your Question

Unable to subscribe to string topic using rosserial arduino nano

asked 2019-02-18 22:44:20 -0500

AK gravatar image

updated 2019-02-19 02:13:39 -0500

I am working with arduino nano to subscribe to a topic which reads keystrokes(Raspberry pi ubuntu mate melodic) and publishes into onto the topic.I am trying subscribe to the topic on an arduino which then prints the value onto the serial monitor. The output on the serial monitor is not consistent its printing random values onto to screen. The terminal is also showing a few errors which I am not able to decipher.
This is my code

#include <ros.h>
#include <std_msgs/String.h>

ros::NodeHandle_<ArduinoHardware, 2, 2, 125, 125> nh;

void comCallback( const std_msgs::String& command)

  if ( == "q")

ros::Subscriber<std_msgs::String> sub("/ignis/move", comCallback);

void setup(){

void loop(){


These are the errors that popup on the terminal for rosrun rosserial_python

[WARN] [1550492941.390503]: Serial Port read failure: device reports readiness to read but returned no data (device disconnected or multiple access on port?)
[INFO] [1550492941.498101]: wrong checksum for msg length, length 76
[INFO] [1550492941.502178]: chk is 1
[WARN] [1550492942.992464]: Serial Port read failure: device reports readiness to read but returned no data (device disconnected or multiple access on port?)
[ERROR] [1550492943.095225]: Mismatched protocol version in packet: lost sync or rosserial_python is from different ros release than the rosserial clien
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2019-02-19 03:12:48 -0500

Rosserial uses the arduino's serial port for communication. By writing to the same port using Serial.print you're breaking the protocol. This is hinted at in the error messages you're getting.

(device disconnected or multiple access on port?)

There are specific commands for logging inside arduino code using rosserial to solve this exact problem. As shown below:

nh.loginfo("Program info");

Hope this helps.

edit flag offensive delete link more


i checked the link given and I could not figure where to access the loginfo. Can you help me with this. Thank you

AK gravatar image AK  ( 2019-02-20 06:45:22 -0500 )edit

The output of the commands given in the code example should be the same as their equivalent ROS_INFO, ROS_WARN. . . commands. So they will be printed to screen or logged to file depending on how the node was started.

PeteBlackerThe3rd gravatar image PeteBlackerThe3rd  ( 2019-02-20 07:11:55 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2019-02-18 22:44:20 -0500

Seen: 863 times

Last updated: Feb 19 '19