Don't get all rostopic echo data
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;
pubheader=nh.advertise<std_msgs>::Int16MultiArray>("Audio_head",1);
ros::Rate loop_rate(1);
int i,j;
for(j=0;j<3;j++)
{
head.data.clear();
for(i=0;i < headersize;i++)
{
head.data.push_back(header.ROSheader[i]);
}
pubheader.publish(head);
ros::spinOnce();
loop_rate.sleep();
}
Any reason that only the last two instances are echoed?
Thanks
did you run rostopic echo before the node?
Yes, I had rostopic running before running the node