How to subscribe to dynamic number of topics while using message_filters.TimeSynchronizer

asked 2020-11-24 12:28:23 -0600

utkarshjp7 gravatar image

updated 2020-11-25 10:16:39 -0600

I want to create a time syncronizer for n topics.

Is there a way to create a callback function that can accept dynamic number of arguments?

I tried to do the following for n=4, but I got the error callback() takes exactly 2 argument (5 given)

n = 4
subs = []
for i in range(n):
    sub = message_filters.Subscriber("/camera_{}".format(i), CompressedImage)
    subs.append(sub)

time_sync = message_filters.ApproximateTimeSynchronizer(subs, 1, slop=0.05)
time_sync.registerCallback(callback)

def callback(self, **all_msgs):
    pass
edit retag flag offensive close merge delete

Comments

any updates? I'm working on the same problem.

Frosha gravatar image Frosha  ( 2021-09-18 14:33:23 -0600 )edit