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.
Originally posted by volume_8091 on ROS Answers with karma: 27 on 2019-01-23
Post score: 1
Original comments
Comment by curi_ROS on 2019-01-23:
You could try increasing the queue size of the publisher. However, there is no guarantee that all messages will be delivered.
Comment by mali on 2019-01-23:
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.
Comment by volume_8091 on 2019-01-24:
@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.