ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
You can pass extra argument to a callback function, I think you could pass the topic_name. See this from the Subscriber Class:
class Subscriber Found at: rospy.topics
class Subscriber(Topic):
"""
Class for registering as a subscriber to a specified topic, where
the messages are of a given type.
"""
def __init__(self, name, data_class, callback=None, callback_args=None,
queue_size=None, buff_size=DEFAULT_BUFF_SIZE, tcp_nodelay=False):
"""
[...]
@param callback_args: additional arguments to pass to the
callback. This is useful when you wish to reuse the same
callback for multiple subscriptions.
2 | No.2 Revision |
You With rospy, you can pass extra argument to a callback function, I think you could pass the topic_name. See this from the Subscriber Class:
class Subscriber Found at: rospy.topics
class Subscriber(Topic):
"""
Class for registering as a subscriber to a specified topic, where
the messages are of a given type.
"""
def __init__(self, name, data_class, callback=None, callback_args=None,
queue_size=None, buff_size=DEFAULT_BUFF_SIZE, tcp_nodelay=False):
"""
[...]
@param callback_args: additional arguments to pass to the
callback. This is useful when you wish to reuse the same
callback for multiple subscriptions.
I think with roscpp something similar exists