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

Common callback function

asked 2013-06-26 01:14:05 -0500

Verane gravatar image

updated 2014-01-28 17:17:02 -0500

ngrennan gravatar image

Hi. I've a c++ thread that is checking every x seconds if some robots are active. For that, every robot publishes a topic (/robot1/status). So if the robot is publishing, I know that it is alive.

For that reason, my thread subscribes to all these "status" topics. Is it possible to have a common callback for all the topics or I need one function to every one topic?


edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2013-06-26 02:40:15 -0500

Ben_S gravatar image

updated 2013-06-26 05:23:48 -0500

Yes, that is possible. Also have a look at this answer if you want your callback to have a custom parameter, to know which topic (/robot) is the source.


You could use only one topic and let every robot send messages with a unique id to it.

edit flag offensive delete link more


Thanks. I'll try with std::bind instead of boost::bind.

Verane gravatar image Verane  ( 2013-06-26 03:54:25 -0500 )edit

answered 2013-06-26 04:32:34 -0500

Verane gravatar image

But, Is there another way to know if some robot is alive without using a specific topic for each one?

edit flag offensive delete link more


Please dont use answers to extend your question. I will edit my answer.

Ben_S gravatar image Ben_S  ( 2013-06-26 05:22:19 -0500 )edit

Question Tools


Asked: 2013-06-26 01:14:05 -0500

Seen: 257 times

Last updated: Jun 26 '13