Huge delay in subscriber connection with new publisher at same node
I noticed a weird behavior in my ROS application, which I cannot yet replicate in a small example.
I have a GUI in which a panel opens up when a user clicks on an object. This panel contains a publisher and a button to send a message. Once a message is sent, the panel is destroyed. If a user clicks on another object, a new panel is created (and thus a new publisher). The problem is that when calling NodeHandle::advertise after the first, it takes a ridiculous amount of time for the subscribers to connect. I use a callback function to see that it takes between 1 and 30 seconds for a simple example running on my local machine. The NodeHandle instance is always the same, but the publishers are new each time.
Here are the steps.
Step 1: In a terminal, I start rostopic echo /myTopic
Step 2: In another terminal, I start my application, which creates a NodeHandle but nothing related to /myTopic
Step 3: I click on an object in my application, which creates a publisher for /myTopic
. Immediately (<100ms) I see that the rostopic subscriber is connected
Step 4: I click on a button to send a message. The message is echoed immediately. The publisher is destroyed.
Step 5: I click on another object, which creates a new publisher for /myTopic
. The subscriber connects after 1-30 seconds.
Step 6: I click on a button to send a message. The message is echoed after 1-3 seconds. The publisher is destroyed.
Here is the console output from my application. You can see the delays. In the first case, I published too soon and the subscriber did not even connect.
[ INFO] [1352991455.634938616]: Publisher created
[ INFO] [1352991456.164327470]: Published a ElementOfInterestConfirmationMessage for uuid #1 with status 1
[ INFO] [1352991456.166183498]: publisher is shutdown
[ INFO] [1352991456.179045474]: Publisher created
[ INFO] [1352991483.726720903]: Subscriber connected
[ INFO] [1352991707.015080917]: Published a ElementOfInterestConfirmationMessage for uuid #2 with status 2
[ INFO] [1352991707.016848508]: publisher is shutdown
Asked by Benoit Larochelle on 2012-11-15 04:28:58 UTC
Comments