ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

How to control a callback ?

asked 2018-11-08 04:16:18 -0500

jithinreju@gmail.com gravatar image

use case : I have a topic which is subscribed by a ROS node locally and also by a ROs node on a remote system ,Since both the nodes are subscribed to the topic, both node gets a a call back when the message is published , But i want the callback on the remote system to work only during some times otherwise it is done locally .

I could always recieve the payload via the callback on the remote system and decide not to do any computation with it . But the problem is I am loading the bandwidth with information i dont use ,i want to prevent this ?

Is there any way to achieve this ?

edit retag flag offensive close merge delete

Comments

A general comment: you now have 5 questions posted of which 3 received a answers. It would be good if you could go back to those questions and see which of the answers actually solved your problem. Then accept those answers.

gvdhoorn gravatar image gvdhoorn  ( 2018-11-08 04:42:18 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2018-11-08 04:49:54 -0500

gvdhoorn gravatar image

updated 2018-11-08 04:59:29 -0500

But i want the callback on the remote system to work only during some times otherwise it is done locally

I don't believe that is how publish-subscribe works -- or at least, not in the default implementation in ROS 1.

At the user/application level, there is no knowledge/state your publisher has access to that would allow it to actively influence which subscribers receive messages, neither whether they have actual callbacks registered for those messages.

In addition: publish-subscribe (again: as implemented in ROS 1) provides location transparency: nodes do not "know" where other nodes are (or where they are deployed).

So "the callback on the remote system" is not something that you can say given these two properties.

But this is all at the user/application level, the middleware obviously does know where other nodes are (see also #q203129).


A naive way to do what you describe could be to deregister your subscribers whenever they are not needed. Then resubscribe again when the need is there. Provided you're not doing that multiple times per second that should not incur too much latency / performance overhead.

Perhaps this is a use-case for ros::topic::waitForMessage(..).

Alternatively: if control over where (and when) processing takes place is important, it could be that services or actions are a more suitable interaction pattern.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-11-08 04:16:18 -0500

Seen: 173 times

Last updated: Nov 08 '18