Giter VIP home page Giter VIP logo

Comments (5)

dirk-thomas avatar dirk-thomas commented on August 20, 2024

Please don't double post your question here but wait for an answer on your original question.

Short answer: any non-const subscriber must be handed a copy of the message since by API contract he is allowed to change the message. Otherwise any change would affect all other subscribers as well.

from roscpp_core.

protobits avatar protobits commented on August 20, 2024

Ok, sorry, it was due to the fact I felt it was a bug since it seems the
behavior is not consistent as I described. In fact, I can see that this
behavior you mention is not the case: the non-const subscriber is not
receiving a copy the first time, but later it does.

In any case, I don't quite understand at which level this is expected to be
respected by the user or enforced by ROS itself. I agree that "the
subscriber may make modifications to the message which affect other
subscribers". However, in some cases this may be the intended consequence
and, thus, the user could be aware of this and expect to deal with the
consequences. However it seems that something is forcing the copy between
publisher-subscriber, even when it is not necessary in terms of constness
(in contrast to a const-sender and a non-const receiver, which can only be
solved by a copy in between).

If this still does not look like a bug to you, we can continue this on ROS
asnwers. My question would thus be: is ROS supposed to enforces the copy to
maintain this contract? Or should a non-const publisher and a non-const
subscriber still be able to receive the same object and leave the user the
responsibility of not breaking things with other subscribers?

Thanks

On Fri, Oct 24, 2014 at 2:41 PM, Dirk Thomas [email protected]
wrote:

Please don't double post your question here but wait for an answer on your
original question.

Short answer: any non-const subscriber must be handed a copy of the
message since by API contract he is allowed to change the message.
Otherwise any change would affect all other subscribers as well.


Reply to this email directly or view it on GitHub
#31 (comment).

from roscpp_core.

dirk-thomas avatar dirk-thomas commented on August 20, 2024

The signature of the published message (const or non-const) does not matter for this at all.

ROS can not allow a subscriber to affect other subscribers. So if you have multiple subscribers the non-const subscribers must receive a copy (which is enforced by ROS). In the case that there is only one subscriber it does not make a difference if ROS is handing it the original instance or a copy (I guess this is what you see as inconsistent behavior). But you should consider that an implementation detail and not rely on it.

While it might look like a nice way to communicate information from one subscriber to another subscriber by changing the message instance in-place that would violate the publish / subscribe model of the communication. That is not a support way of communication.

from roscpp_core.

protobits avatar protobits commented on August 20, 2024

Sorry, I just read this after replying on ros answers. Your last reply clarifies the situation for me. Thanks for the information.

from roscpp_core.

dirk-thomas avatar dirk-thomas commented on August 20, 2024

That's why not reposting the question in a second location makes sense 😉

Anyway I linked this ticket from the answer that future readers will find both.

from roscpp_core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.