shupx / swarm_ros_bridge

A lightweight middle interface that enables specified ROS message transmission among swarm robots through socket communication
https://wiki.ros.org/swarm_ros_bridge
BSD 3-Clause "New" or "Revised" License
69 stars 23 forks source link

Add ZeroMQ HighWaterMark (message queue size) #4

Open shupx opened 1 year ago

shupx commented 1 year ago

ZeroMQ will create a message queue for each send threads. The queue size is specified by HWM(High Water Mark). If the queue fills up the new sending messages will be dropped/discarded by zeroMQ PUB socket.

Swarm_ros_bridge does not set HWM of send sockets, thus a default HWM value of 1000 is used. This means that the max sending queue size is 1000 ( maybe half in practice actually).

Large HWM value leads to less dropping of non-streaming sending messages if the consuming/receiving rate is less than the sending rate . But for streaming messages, large HWM leads to high latency for streaming messages as the receiving messages are those being queued 1000 before. If you wants high-real-time messages, then HWM should be set small.

Maybe we need add the HWM attributes in ros_topics.yaml and let user define the HWM in their need.

shupx commented 1 year ago
sender->set(zmqpp::socket_option::send_high_water_mark, 1); // HWM should be set before bind/connect!

receiver->set(zmqpp::socket_option::receive_high_water_mark, 1); // HWM should be set before bind/connect!

Adding these two lilnes does not seem to take much effects.