I have an error trying to subscribe to multiple topics, between them there are two of the same type, this is the error, please what can I do ?
this is the code:
#! /usr/bin/env python
import serial
import rospy
import message_filters
import numpy as np
from sensor_msgs.msg import Imu
from nav_msgs.msg import Odometry
from std_msgs.msg import Float32
class adq_datos(object):
def __init__(self):
self.datos = 0
self.pwm = message_filters.Subscriber('/PWM', Float32)
self.encoder = message_filters.Subscriber('/enc_data', Odometry)
self.gps = message_filters.Subscriber('/gps', Float32)
self.imu = message_filters.Subscriber('/mti/sensor/imu_free', Imu)
self.ts = message_filters.TimeSynchronizer([self.pwm, self.encoder, self.gps, self.imu], 10)
self.ts.registerCallback(self.synchronize_data)
rospy.spin()
def synchronize_data(self, data):
self.datos = data.pose.covariance[5]
print self.datos
if __name__=='__main__':
try:
rospy.init_node('save_data',anonymous=True, disable_signals=True)
print "Nodo Creado"
cv = adq_datos()
except rospy.ROSInterruptException:
pass
this is the error that show
[ERROR] [1576621538.678741]: bad callback: <bound method Subscriber.callback of <message_filters.Subscriber object at 0x75b23850>>
Traceback (most recent call last):
File "/opt/ros/kinetic/lib/python2.7/dist-packages/rospy/topics.py", line 750, in _invoke_callback
cb(msg)
File "/opt/ros/kinetic/lib/python2.7/dist-packages/message_filters/__init__.py", line 75, in callback
self.signalMessage(msg)
File "/opt/ros/kinetic/lib/python2.7/dist-packages/message_filters/__init__.py", line 57, in signalMessage
cb(*(msg + args))
File "/opt/ros/kinetic/lib/python2.7/dist-packages/message_filters/__init__.py", line 216, in add
my_queue[msg.header.stamp] = msg
AttributeError: 'Float32' object has no attribute 'header'