Ask Your Question

Revision history [back]

click to hide/show revision 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

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
    # rospy.spin() is not desired here, as all it does is run an infinite loop