Exception thrown while processing messages from 6 Topics using a callback within message_filters.ApproximateTimeSynchronizer

asked 2018-06-05 08:10:05 -0500

kolner gravatar image

updated 2018-06-07 02:52:52 -0500

Hello everyone,

I am trying to read messages from different sensors simultaneously and mostly synchronically, using a message_filters.ApproximateTimeSynchronizer class.

There are 6 six different topics and all messages collected from have to be written into a single .csv file. I use a callback to perform the writing. So basically, I start playing my bagfile and launch my python script, that process all messages from the bagfile. However, when I stop my python script (e.g. with Ctrl-C), I can not see all messages in the .csv file and furhtermore, I get the following exception:

Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
  File "/usr/lib/python2.7/threading.py", line 763, in run
  File "/opt/ros/indigo/lib/python2.7/dist-packages/rospy/impl/tcpros_pubsub.py", line 178, in robust_connect_subscriber
  File "/opt/ros/indigo/lib/python2.7/dist-packages/rospy/impl/tcpros_base.py", line 791, in receive_loop
 <type 'exceptions.TypeError'>: 'NoneType' object is not callable

My code looks in general like this:

# define and open csv file globally

rospy.init_node('my_listener', anonymous=True)
rospy.on_shutdown(<close csv file>) 

def callback(imu0, rpy0, mag0, imu1, rpy1, mag1):
    #convert messages into string and write as a row into global defined .csv file

def listener():
    #subscribe to all desired topics 
    imu_data0 = message_filters.Subscriber("/imu0/imu_data", Imu)
    rpy0 = message_filters.Subscriber("/imu0/inemo/rpy", Vector3Stamped)
    mag0 = message_filters.Subscriber("/imu0/inemo/mag", MagneticField)
    imu_data1 = message_filters.Subscriber("/imu1/imu_data", Imu)
    rpy1 = message_filters.Subscriber("/imu1/inemo/rpy", Vector3Stamped)
    mag1 = message_filters.Subscriber("/imu1/inemo/mag", MagneticField)

    ts = message_filters.ApproximateTimeSynchronizer([imu_data0, rpy0, mag0, imu_data1, rpy1, mag1], 60, 0.1)

if __name__ == '__main__':

Does anyone have an idea how to fix that?

Thanks in advance!

edit retag flag offensive close merge delete



@kolner please Refrain from bumping your question. If somebody would have known, he or she would have already answered. same foes for #q293266

mgruhler gravatar image mgruhler  ( 2018-06-07 02:59:32 -0500 )edit

Sorry, it will not repeat anymore :)

kolner gravatar image kolner  ( 2018-06-08 14:57:59 -0500 )edit