Ask Your Question
0

I have an error "AttributeError: 'module' object has no attribute 'ApproximateTimeSynchronizer'" even if i already used TimeSynchronizer

asked 2020-02-25 09:36:15 -0500

MohamedAkaarir gravatar image

System information

OS: Ubuntu 12.07 ROS version: Hydro

this the code i just create to be able to use two topics at the same time:


import numpy as np
import  message_filters
import rospy
from gps_common.msg import GPSFix
from personalpackage.msg import imu
from personalpackage.msg import GNSS

message = ""

def callback(GNSS,GPS): f=open("the_times.csv","a+") print("inside callback") time_ros= GNSS.header.stamp.secs+GNSS.header.stamp.nsecs0.000000001 time_gps= GNSS.time.secs+GNSS.time.nsecs0.000000001 time_gps_pps= GNSS.time_clock.secs+GNSS.time_clock.nsecs*0.000000001 tsmp = time_gps_pps - time_ros message="time_ros time_gps time_gps_pps difference between timeGPS & timeGPSPPS\n" message=message+str(time_ros)+"\t"+str(time_gps)+"\t"+str(time_gps_pps)+"\t"+str(tsmp)+"\n" print(message) rospy.loginfo(rospy.get_caller_id() + "I heard %s", data.data)

def the_times(): rospy.init_node('the_times', anonymous=True) GnssData=message_filters.Subscriber("GPS",GPSFix) ImuData=message_filters.Subscriber("GNSS",GNSS) print("after filtering") ApproSynchron=message_filters.ApproximateTimeSynchronizer([GnssData,ImuData], 10, 0.1,allow_headerless=True) print("after Synchro") ApproSynchron.registerCallback(callback) print("after Callback") rospy.spin()

if __name__ == '__main__': the_times()

When i execute it i get this error message :

Traceback (most recent call last): File "the_times.py", line 51, in <module> the_times() File "the_times.py", line 41, in the_times ApproSynchron=message_filters.ApproximateTimeSynchronizer([GnssData,ImuData], 10, 0.1,allow_headerless=True) AttributeError: 'module' object has no attribute 'ApproximateTimeSynchronizer'

I already tried the same code using "TimeSynchronizer" and i didn't get any error message.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-02-25 10:15:35 -0500

MohamedAkaarir gravatar image

The problem was simply that i don't have the good version of message_filters library that contains "ApproximateTimeSynchronizer", the default version of message_filters library on hydro distro is 1.10.12.

ApproximateTimeSynchronizer was first introduced in 1.11.4 version of message_filters library.

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

2 followers

Stats

Asked: 2020-02-25 09:36:15 -0500

Seen: 29 times

Last updated: Feb 25