-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Publisher only sends a message if at least one (ign-transport) subscriber exists #225
Comments
This is by design because publishing a message requires to serialize the message, among other things. This way we can save some CPU cycles if nobody is subscribed. |
@caguero Do you happen to know the section in the code where this happens? Maybe my understanding is wrong, but I thought the zmq+protobuf solution exists precisely because we want to have cheap serialization. ZMQ should not copy the message internally - it's zero-copy afterall - and PUB sockets without subscriber drop messages without them hitting the wire already. I don't see protobuf doing much work neither since the binary format is optimized for space, and we compile the message to get language-native bindings to directly interface with the objects; is the C-binding somehow inefficient? I can see how this could be a problem if we had to construct a fresh protobuf object from a different data structure each time. In that case, my question would be why there is a mismatch between them? |
I don't think we would be changing the behavior here. Depending on the message type, serialization is not cheap, so if there are no subscribers, it doesn't make sense to have to pay the cost. Also, we now have python bindings for gz-transport, so you should be able to subscribe to topics. |
Environment
Description
Steps to reproduce
ign gazebo
)/clock
topic (ign -e -t /clock
)I realize that this usage is (currently 👼) quite the hack and not following the "intended" way of subscribing to topics. My use case is that I need access to sensor data from within python. The message layer is already language-independent (protobuf+zmq), and it seems cleaner to use native zmq and protobuf libraries to subscribe to topics instead of having to create an ign-transport wrapper in my language of choice. Potentially, this approach could scale to all zmq supported languages (JS, Python, Rust, Java, MATLAB (via Java) ...).
I have a related question on gazebosim, but it seems rather unpopular. Now that I've made some progress on it via trial-and-error, it looks more like a bug (or is it a design decision?).
I'm only surface-level familiar with the codebase, so I'm doing a lot of guessing of what's actually happening. Here, I'm at a bit of a loss regarding what could be happening. Does ign-transport mediate messaging (e.g. via a central message broker)?
If somebody could help reduce my confusion, I'll be happy to help with a PR (if applicable).
The text was updated successfully, but these errors were encountered: