ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
I think your solution with message filters is pretty close to the solution you need, except that you're putting the subscriber creation inside your callback, and that doesn't make sense.
I think the solution looks something like this:
# some lines of plugin initialization from .ui file
# callback started when button is pressed
self._c.Action_button.clicked.connect(self.visual_callback)
def visual_callback(self):
""" This function is triggered by pressing the connect button."""
# Create subscribers for each topic
self.left = message_filters.Subscriber("/my_stereo/left/image_raw", Image)
self.right = message_filters.Subscriber("/my_stereo/right/image_raw", Image)
# Create synce filter. Use exact or approximate as appropriate.
self.ts = message_filters.TimeSynchronizer([left, right], 10)
# Assuming your object has a method maker(left, right) that takes in two Image objects
self.ts.registerCallback(self.maker)
# rospy.spin() is not desired here, as all it does is run an infinite loop