Ask Your Question
0

Python ApproximateTimeSynchronizer not working

asked 2015-11-18 23:29:42 -0500

Markus Eich gravatar image

Dear all,

I want to subscribe to synchronized depth and rgb images using message_filters and ApproximateTImeSynchoronizer.

def rgb_callback(image):
     rospy.loginfo("got RGB image")

def depth_callback(image):
    rospy.loginfo("got DEPTH image")

def scan_callback(image,depth):
    rospy.loginfo("got synched images")


def hand_tracker():

    rospy.init_node('hand_tracker')
    image_sub=message_filters.Subscriber('/kinect2/hd/image_color_rect',Image)
    depth_sub=message_filters.Subscriber('/kinect2/hd/image_dept_rect',Image)        

    rospy.Subscriber('/kinect2/hd/image_color_rect',Image,rgb_callback)    
    rospy.Subscriber('/kinect2/hd/image_depth_rect',Image,depth_callback)    

    ts=message_filters.ApproximateTimeSynchronizer([image_sub,depth_sub],10,1)    
    ts.registerCallback(scan_callback)
    try:
        rospy.spin()
    except KeyboardInterrupt:        
        print "Shutting down"

The problem is that rgb callback and depth callback are called, but the scan_callback using ApproximateTimeSynchronizer not. Is it a bug or is there something I am doing wrong?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-11-20 05:51:39 -0500

Chrissi gravatar image

This is something I recently discovered as well, you cannot subscribe to the same topic twice from within the same node. The second subscribers is just ignored and the callback will never be called. Try removing the

rospy.Subscriber('/kinect2/hd/image_color_rect',Image,rgb_callback)    
rospy.Subscriber('/kinect2/hd/image_depth_rect',Image,depth_callback)

and see if your scan callback is now called.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-11-18 23:29:42 -0500

Seen: 846 times

Last updated: Nov 20 '15