c++ equivalent of callback_args for subscribers? [closed]

asked 2021-01-19 14:04:32 -0600

LukeAI gravatar image

Subscribers in rospy can be optionally passed callback_args on creation. This is really handy when you have one callback for multiple incoming topics and you want to do topic-specific stuff for a given message. Equivalent functionality does not appear to be built into c++ subscribers

Is there some way to achieve the same thing in C++?

Context:

I have arbitrary number of multiple incoming topics each with corresponding outgoing topics - and a single callback that does the computation for an incoming topic and needs to publish the results to the correct outgoing topic.

edit retag flag offensive reopen merge delete

Closed for the following reason duplicate question by LukeAI
close date 2021-01-20 04:34:49.117154

Comments

1

I believe the keywords here are "multiple arguments ros c++ subscriber".

See #q232204 for what I believe is a (random) duplicate.

std::bind(..) would be the recommended approach these days.

See also wiki/roscpp/Overview/Publishers and Subscribers: Callback Types.

gvdhoorn gravatar image gvdhoorn  ( 2021-01-19 14:33:00 -0600 )edit

If you agree this is a duplicate, could I ask you to please close it as one?

gvdhoorn gravatar image gvdhoorn  ( 2021-01-19 14:33:28 -0600 )edit

yes, I agree, didn't quite have the language to articulate the question properly, thanks for reply.

LukeAI gravatar image LukeAI  ( 2021-01-20 04:34:41 -0600 )edit