Which data is thrown away in queue if publish and spinonce rate is different?
I read that SpinOnce does not only make callback, but it will also clean the queue if possible. is that right?
Let's say publisher publish alphabets (a,b,c,...) at 9hz, and subscriber call Spinonce at 3hz.
So publisher will publish a,b,c to queue. Then subscriber does spinonce, getting a (because queue is First in first out) and empty the queue.Now the queue is empty. Next, publisher will publish d,e,f to queue. Then subscriber does spinonce, getting d and empty the queue.Now the queue is empty. Next, publisher will publish g,h,i to queue. Then subscriber does spinonce, getting g and empty the queue.Now the queue is empty.
So at the end what the subscriber gets is a,d,g,...
Is that right? Please explain
EDIT (additional question) Where should we call ros::spin() or ros::spinOnce()? Is it in the publisher code, or subscriber code? and why is so?
In this tutorial of publisher-subscriber It calls ros::spinOnce() in the publisher code, and it also calls ros::spin() in subscriber code. Why is that so? please explain..