I have an error "AttributeError: 'module' object has no attribute 'ApproximateTimeSynchronizer'" even if i already used TimeSynchronizer
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.