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

int callback

asked 2012-07-26 07:07:57 -0600

Rydel gravatar image

Is it possible to have a callback function other than type void? If yes, how would you handle a situation where you call ros::spinOnce() and say you are subscribing to two different topics each with their own callback function... how would you store the variable that one of the callback functions returned?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
5

answered 2012-07-26 07:10:21 -0600

dornhege gravatar image

updated 2012-07-27 02:10:39 -0600

I would say: No.

For the reason that you basically explained yourself: What would one do with the return value?, What is the meaning of that?

PS: Maybe, your intended usage of ros::spinOnce is based on a misconception. ros::spinOnce will not call one callback, but all available callbacks at the time. For more information, see: http://www.ros.org/wiki/roscpp/Overview/Callbacks%20and%20Spinning

edit flag offensive delete link more

Comments

Possibly a boolean return? That could be useful in some scenario.

allenh1 gravatar image allenh1  ( 2012-07-26 09:55:04 -0600 )edit
2

But who would use that? Callbacks come from spin, so what should happen in spin if a callback returns false? Things like error handling in client code should not go through spin, but be handled directly by the callback (IMO). Figuring out what callback caused a false return would also be messy.

dornhege gravatar image dornhege  ( 2012-07-27 02:02:23 -0600 )edit

Question Tools

Stats

Asked: 2012-07-26 07:07:57 -0600

Seen: 947 times

Last updated: Jul 27 '12