Why Are Some Messages Being Buffered
I'm running into a bit of an issue where some messages aren't being delivered right away but appear to be getting buffered. Here's a quick overview of my setup ( I tried posting a block diagram but I don't seem to have enough points to attach an image)
UART
App Node -> Intermediate Node -> Serializer Node <-----> Arduino
In essence, the intermediate node subscribes to a number of application nodes, amalgamates data from them and publishes it as a serial command. The serializer is responsible for sending the commands to the Arduino as well as receiving data from the Arduino and publishing it for the app nodes.
The issue is that sometimes I see a case where the serial commands are being buffered and then delivered all at once in quick succession. At first I thought it was the UART interface being busy, but the Serializer Node is still able to receive commands while the buffering is happening so that doesn't seem to be it.
I noticed that if I remove the Intermediate Node and publish Serial commands directly from the App Nodes, then the buffering doesn't happen.
Is there anything inherently wrong with having this double subscriber model? Any idea why the messages are being buffered? Is there any way to prevent messages from being buffered?
Platform: Raspberry Pi4 ROS Version: Kinetic Language: Python (Rospy)
Edit: Adding some more details
- The intermediate node subscribes to multiple topics but I can reproduce this with a single subscriber
- The App Node publishes inside a ROS timer running at 100Hz and I monitor the time between subscriber callbacks in both the intermediate and serializer nodes using Pytthon's datetime.now().
- I don't see any missed callbacks in the intermediate node, but in the serializer node I often see a callback that is several 100ms after the last one, followed by lots of very tightly spaced callbacks (the delayed messages catching up).
Could this be caused by Nagle's being active on the subscribers in your intermediate node?
Thanks for the suggestion, but that doesn't seem to have made a difference. Is there any way I can further debug this using the ROS tools or otherwise?
Please update your question with code showing how you configured your subscribers.