message_filters giving me errors

asked 2022-03-30 16:58:28 -0500

distro gravatar image

updated 2022-03-30 19:48:49 -0500

I've been trying to use message_filters. I was testing it with some topics and messages I'm using for my project. This was the code for my test

#!/usr/bin/python2.7
import rospy
import message_filters
from nav_msgs.msg import Odometry
from sensor_msgs.msg import LaserScan #ros msg that gets the laser scans
from std_msgs.msg import String

#f=String()
rospy.init_node("ert")

def hj(g,h):
    return g.ranges[12]*h


def callback(msg,odom):
    pub = rospy.Publisher("/remembrancer", String, queue_size=10)
    #global f
    #rospy.loginfo(df.pose.pose.position.x)
    #g=msg.ranges[12]
    f=hj(msg,odom.pose.pose.position.x)
    rospy.loginfo(f)
    #rospy.loginfo(df)

image_sub = message_filters.Subscriber('/scan', LaserScan)
info_sub = message_filters.Subscriber('/odom', Odometry)
#rospy.Subscriber("/scan", LaserScan, callback)
ts = message_filters.TimeSynchronizer([image_sub, info_sub], 1)
ts.registerCallback(callback)
rospy.spin()

It worked successfully, when I try basically the exact thing for my project, I get an error which says Laserscan has no Attribute pose I don't know why this is.

Let me reinstate in case it wasnt clear. This code above executes without error fail. it's when I try the exact same method for project that I get issues.

edit retag flag offensive close merge delete