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

Revision history [back]

click to hide/show revision 1
initial version

I'm not sure of your issue, but your WHILE loop will only last for approximately 1/10th of a second, meaning there must be a message waiting for you from your publisher within that 1/10th of a second or before.

I am not sure if output from a publisher will even buffer if nothing on your system is listening to it (since ROS core somehow makes direct connections between ROS nodes once they subscribe).

Try this. Change while(i<10) to while(ros::ok()) and see if you then ever get those messages through. If you do, it probably has something to do with your timing of when the publisher sends and the the subscriber checks for it.

Also, if you are starting your publisher after the receiver, it surely wont get anything (although it seems you're not doing this).