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

Revision history [back]

You need to use callback_args parameter of the Subscriber class.

In your case, you can set the key as shown below:

    rospy.Subscriber(name=key,
                     data_class=self.ros_topics[key]["type"],
                     callback=self.common_callback,
                     callback_args=key)

And then change the callback signature to accommodate key as shown below:

def common_callback(self, msg, args):
    key = args

I have not tested the above code. In case of an error, please inform and change the callback_args to a tuple.

For more information, please check this answer.