Question on topic publication
I'm trying to create some sort of base_controller for my motors in C++. I have two question about topics that I cannot answer for now.
First, if I read a message on the cmd_vel topic for example using a subscriber does the message I just read "disappeared" from the topic. Meaning if another Node try to read it, is the previously read message "gone" ?
Second, depending on the answer to the first question, how can I know if their is a steady stream of command coming from the cmd_vel topic ? Meaning if the message is erased when I read it how can I know that it was not 'outdated" or when to stop ? If it is not erase by reading but rather by if their more new information, how can two node send data on the same topic ?
To try to be clearer here is a situation example :
Let's say I publish a Twist for my robot to go forward on the cmd_vel for 3 second and I publish no stop Twist after those 3 seconds.
- What is my subscriber to this topic going to read during the 3 first second and after ?
- Same question but what if my subscriber is a little bit slow and start reading 1 second after I start publishing the twists ?
Thanks a lot.
when you publish a msg on a topic you give it an buffer to keep how many msgs in buffer and when you want to subscribe a msg you give it another buffer to keep how many msg in buffer. if you want to have two subscriber in one topic you can use header to separate msgs.
If I publish one message, then I read it with my subscriber how can I know that there is no more input in the topic ? My question is more oriented at understanding how for example, turtlebot is able to know that the input is not steady.