I cant get data from topic
I want to get data from rtmap topic. But something wrong in my code.
import rospy
from nav_msgs.msg import Path
from geometry_msgs.msg import PoseStamped
import pandas as pd
def callback(data):
pose = PoseStamped()
pose.pose.header.frame_id = "map"
pose.pose.position.x = float(data.pose.position.x)
print(pose.position.x)
def listener():
rospy.init_node("Oret_pose")
rospy.Subscriber("/zed/mapPath",Path,callback)
rospy.spin()
if __name__ == '__main__':
listener()
Asked by gurselturkeri on 2022-06-29 10:28:56 UTC
Comments
It's not clear why you feel there's an error with your code here: what behavior have you observed with your code? What were you expecting to see compared to what is actually taking place here?
Asked by cst0 on 2022-06-29 10:48:58 UTC
i want to get x position and y position from "/zed/mapPath" topics and this topic type is nav_msgs/Path.
Asked by gurselturkeri on 2022-06-29 11:06:11 UTC
Yes, I can see that from the question. Unfortunately, you haven't provided any detail about the behavior of your code, or what you were expecting to see compared to what is actually happening, or what other nodes you have running, etc. As a result, it is not possible for anyone to answer this question other than wild guessing.
Asked by cst0 on 2022-06-29 11:18:55 UTC
You do seem to be trying to access a member of the message that doesn't exist, however. The path is an array of
poses
, each one has a pose with a position with an x. You're attempting to access a pose, which won't work.Asked by cst0 on 2022-06-29 11:21:07 UTC