How to get x,y from /move_base/NavfnROS/plan [closed]
I want to record the msg that on the /move_base/NavfnROS/plan
These msg class is Path , but when i whrite a callback to catch the data of this topic I can't Get X,Y separately
my callback funtion is below:
def Global_Callback(data):
global glo_x, glo_y
glo_x = data.poses.pose.positon.x
glo_x = data.poses.pose.positon.y
I run it ,it will show the failed msg below:
AttributeError: "list" object has no attribute 'pose'
Where am I doing wrong?
when I change funtion as this
def Global_Callback(data):
global glo_x, glo_y
glo_x = data.poses
It can run normally, But I Only want X and Y of these pose in the Path
it's a list,operator[]
yes i know,but can i only grab the coordinate of position?
because i can use the same way to grab the coordinates of /odom
i want do same thing on this topic
Please stop "yelling" (using caps), there is no need.
@pengjiawei is correct:
poses
is a list, you cannot use the dot operator directly on it. You need to first index into it using the[]
operator.This is not a ROS problem, but a basic Python one.
sorry for using caps, OK I'll try to split it.
ANW thank you for tour answer
Finally, I used the excel filter to successfully analyze the remaining simple data.
thank you~~
The following did not work for you?
Hello! Because ROS I was the first time I was exposed to the programming language, so my concept of using Python is still very basic. I have not tried this method and I will try again!
I would recommend to first learn a bit of Python (without ROS) and then start looking at ROS again.
A lot of 'magical things' will suddenly probably become a lot more transparent to you.