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

Python ApproximateTimeSynchronizer callback working but no sync

asked 2016-08-07 23:58:12 -0500

b2256 gravatar image

updated 2016-08-07 23:59:56 -0500

Hi All:

I am using message_filters (python) ApproximateTimeSynchronizer to sync two topics in a class; one custom rpy msg (tat_bry) and output from robot_localization's navsat_transform (/gps/filtered). Both nodes appear in the default (/) namespace. The callback (see code snippet below) seems to be working as my roslog text message comes through "syncing'. When echoes for both topics, are initiated, there appears a difference in sequence numbers of around 5 and a disparity between topics of a maximum of slightly more than .06s using a 'slop' of 0.033s. After reading the documentation for both the C++ and Python version, I chose this value as 1/2 of the 16Hz frequency of 0.0625/s or about 0.033s.

After many forms of experimenting with queue sizes, and 'slop' parameters, changing input frequencies and namespaces to no avail; I cannot produce a synchronized set between the two topics. I wonder after looking at the affected portion of the node diagram, it appears that echoing the topics may be taking place prior to the synchronization?

Is there a way to echo the resultant output stream of the callback (after sync)? Are the topics spread too far to sync using this filter? I've used this filter before and did not seem to have this issue.

Using Ubuntu 14.04LTs, Indigo

Any insight is greatly appreciated.

B2256

class AflSync():
def __init__(self):
    self.got_new_msg = False
    self.tat_bry_msg = TatBry()
    self.sync_msg = Sync_orb()

# Create subscribers and publishers
# subscriber to message_filters module and assigning to local class variable
    self.sub_gps = Subscriber("gps/filtered", NavSatFix)
    self.sub_rpy = Subscriber("tat_bry", TatBry)
# Synchronize topics
    ts = ApproximateTimeSynchronizer([self.sub_gps, self.sub_rpy], 2, 0.033)
    ts.registerCallback(self.cb_aflsync)

def cb_aflsync(self, sync_msg, tat_bry_msg):

    r = rospy.Rate(16) # 16hz
    rospy.loginfo('syncing')


    # Main while loop.
    while not rospy.is_shutdown():

        r.sleep()

afl_sync_node2.jpg

edit retag flag offensive close merge delete

Comments

Still cannot get returned sync messages. Queue length or slop- neither seems to matter, yet the loginfo prints?? What else can affect this?

b2256 gravatar image b2256  ( 2016-08-11 10:09:03 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2018-03-07 23:23:16 -0500

b2256 gravatar image

Old question but I thought it might help someone else with an answer. Turns out that the filter buffer was being overran. I was able to adjust the queue sizes by trial and error and it seems to work fine now.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-08-07 23:58:12 -0500

Seen: 2,205 times

Last updated: Mar 07 '18