Ask Your Question

Don't get all rostopic echo data

asked 2017-04-28 21:37:20 -0500

Bob H gravatar image

updated 2017-04-29 04:55:08 -0500

gvdhoorn gravatar image

I have a node which publishes data 3 times. But when I look at the results of the rostopic echo, I only get the last two cycles. I have tried this with different counts, but rostopic echo always misses the first cycle.

std_msgs::Int16MultiArray head;  
ros::init(argc,argv, "xxxxxx");  
ros::NodeHandle nh;  
ros::Rate loop_rate(1);  
int i,j;  
  for(i=0;i < headersize;i++)  

Any reason that only the last two instances are echoed?


edit retag flag offensive close merge delete


did you run rostopic echo before the node?

Archhaskeller gravatar image Archhaskeller  ( 2017-04-28 23:39:19 -0500 )edit

Yes, I had rostopic running before running the node

Bob H gravatar image Bob H  ( 2017-04-29 10:15:11 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2017-04-29 04:58:48 -0500

gvdhoorn gravatar image

A bit of a guess, but setting up subscriptions takes time, even if you only have everything running on a single machine.

As @Archhaskeller hints at, rostopic might simply be 'too late' to receive all publications.

If receiving all messages is important, consider using an interaction pattern that is not so completely decoupled as pub-sub (ie: services or actions), or see if a latched topic helps.

Another option might be to wait with publishing until there is (are) at least one (or more) subscriber(s). You can do that with checking ros::Publisher::getNumSubscribers().

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

1 follower


Asked: 2017-04-28 21:37:20 -0500

Seen: 877 times

Last updated: Apr 29 '17