The simple solution is what I'm currently doing which is to create a publisher using String. and don't bother defining the string. Sends an empty message and it triggers the event I want.
There is an Empty message in std_msgs
, perhaps you could use that. You'd still be publishing something, it just doesn't have any contents.
Although if you're not looking for fire-and-forget semantics, using a service may be better. There's Empty there as well, and Trigger.
However, I can't imagine there isnt a simple signal that can be linked like pub/sub that doesn't require a data_class, unlike Publishers.
I'm not entirely sure how to take this comment. Nodes can communicate in three ways:
- topics
- services
- actions (sort-of a hybrid, or asynchronous services with feedback)
in all cases, something will have to be exchanged. There is no other way.
And all of it is only done because the publisher or client has the intention to communicate.
Even in Qt (which I believe you're referring to in your question), there is data exchanged. It may not be visible to you at the API/application level, but it's certainly there (invoking a function / method is essentially data exchange).
Publish-subscribe can be used to implement an Observer pattern, but it's not the same thing.
Originally posted by gvdhoorn with karma: 86574 on 2021-02-02
This answer was ACCEPTED on the original site
Post score: 1
Original comments
Comment by nightpoison on 2021-02-02:
@gvdhoorn.
Thank you! Great information. I haven't' jumped into Services just yet. I'm mainly working with Topics right now, as I'm trying to build out a good knowledge base with topics first. In this situation I wouldn't need any type of return message for the event trigger I'm looking for. However, the "std_msgs/Empty.msg" makes sense and I'll probably switch up from string to "Empty.msg" in its place. It meets the criteria, simple, which sometimes means not creating other operations when the current ones will do the same thing. Thanks again for the support.