Ask Your Question
0

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?

Thanks.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

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.


Edit:

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

edit flag offensive delete link more

Comments

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

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

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

Comments

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

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

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

Seen: 158 times

Last updated: Jun 26 '13