It is possible to know what ROS2 topic subscribe the message ?
Hello,
I'm working in a project using ROS2 and i would like to know if it is possible to know the topic o publish the message. For example, imagine that i have 3 subscribers (Sub1, Sub2and Sub3) and the callback function is just printing the data of the message, if i publish a message to Sub3 can i know in the callback function what topic as used ?
self.test_sub1 = self.create_subscription(Bool, "Sub1", self.callback, 10)
self.test_sub2 = self.create_subscription(Bool, "Sub2", self.callback, 10)
self.test_sub3 = self.create_subscription(Bool, "Sub3", self.callback, 10)
def callback(self, msg):
print(msg.data)
print(topic_name) -> can i know this ?
See the previously asked question Reading data from different topics, using the same callback