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

rosserial connection not working with custom messages! [SOLVED]

asked 2016-03-19 10:36:23 -0500

thepirate16 gravatar image

updated 2016-10-24 08:33:22 -0500

ngrennan gravatar image

Hi community!

I've got a problem, as the title suggests, with my custom messages used in arduino.

I publish here the arduino code and explain later:

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

ros::NodeHandle  nh;

pkg1::Num type_Num;
std_msgs::String str_msg;

ros::Publisher chatter("chatter", &str_msg);
ros::Publisher PUB2("newmessage", &type_Num);

char hello[20]= "hello world";
int counter=0;

void setup()

void loop()
  type_Num.first_name = "danielooow";
  type_Num.last_name = "gonsaleeesss";
  type_Num.score = counter;
  PUB2.publish( &type_Num ); = hello;
  chatter.publish( &str_msg );

As you see, the code is only an expansion of the HelloWorld example of ros_lib.

It compiles perfectly.

Once uploaded to my Arduino UNO, I call the rosserial connection:

~/catkin_ws$ rosrun rosserial_python _port:=/dev/ttyACM0

And i get this error:

    [INFO] [WallTime: 1458399926.066204] ROS Serial Python Node
    [INFO] [WallTime: 1458399926.072844] Connecting to /dev/ttyACM0 at 57600 baud
    [ERROR] [WallTime: 1458399943.176784] Unable to sync with device; possible link problem or link software version mismatch such as hydro rosserial_python with groovy Arduino

The thing is, when I upload the HelloWorld example, the connection works!! and the chatter topic is properly registered in the ROS master, but when I use the new code, it doesn't .

I just don't know what's going on here.


  • I thought it could be a delay problem but removing the delay in the code hasn't made anything.
  • I also thought that maybe in the creation of the custom message there's a problem (something related with the CMakeLists.txt or the pakage.xml) but the message can be used in a normal non-arduino code, registering successfully in the ROS master and all that stuff, so that makes me doubt about it.
  • It's maybe that i have to use a second Node Handle??

For possible answers regarding using #define USE_USBCON -> i've already tried that and then the compiler says something about it requires the iostream library --> i just don't think that is the way to go for solving this (maybe i'm wrong i don't know..).

Thanks to everyone in advance. I would appreciate a detailed answer.


edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-03-19 10:44:34 -0500

thepirate16 gravatar image

updated 2016-03-19 10:45:45 -0500


It was a novice error! I JUST HAD TO ADVERTISE THE PUBLISHER!!!!


Everything is working now!

Thanks anyway, you're great guys.

Can someone mark the answer as the correct one? I can't due to my lack of points. Thanks.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2016-03-19 10:36:23 -0500

Seen: 1,920 times

Last updated: Mar 19 '16