cpp publisher/subscriber tutorial loosing some messages
I was following the tutorial) and faced the following problem: some messages (usually 3) are lost when doing the sequence:
- start talker
- start listener
- stop talker
- start talker
For example, an output like this is produced in the talker window:
$ rosrun beginner_tutorials talker
[ INFO] [1548238652.003693516]: hello world 0
[ INFO] [1548238652.103993652]: hello world 1
[ INFO] [1548238652.203964623]: hello world 2
[ INFO] [1548238652.304064752]: hello world 3
[ INFO] [1548238652.404034941]: hello world 4
...
While in the listener window only latter are shown:
[ INFO] [1548238652.304599291]: I heard: [hello world 3]
[ INFO] [1548238652.404490112]: I heard: [hello world 4]
[ INFO] [1548238652.504314152]: I heard: [hello world 5]
...
There is no such problem with the Python publisher/subscriber, not even a single message was lost.
ROS Kinetic, Ubuntu 16.04.05 x64 (run under VirtualBox with Win7 x64 as a host). No original files were changed, just copy and paste from the tutorials.
You could try increasing the queue size of the publisher. However, there is no guarantee that all messages will be delivered.
if you lose only the first three messages each time you start the talker node, the reason might be that: the publisher takes milliseconds to be initialized. try to put some delay like 1 sec before publishing any message and see what will happen.
@curi_ROS increasing queue size from 1000 to 10,000 did not give any difference. As only 3 messages were lost, buffer size of 1000 would already be enough to avoid the problem.