How to get the current position of a robot (C++) ?
Hello !
I try to get the situation of my robot using the following code:
tf::TransformListener listener;
tf::StampedTransform transform;
listener.lookupTransform("/move_base/local_costmap/global_frame", "/move_base/local_costmap/robot_base_frame", ros::Time::now(), transform);
and use it using the following methods:
transform.getOrigin().x()
transform.getOrigin().y()
//...
My problem is when I run this code, I get the the following error:
[ERROR] [..., ...]: "move_base/local_costmap/global_frame" passed to lookupTransform argument target_frame does not exist.
But when I check the "move_base/local_costmap/global_frame" parameter existence (the same with the "move_base/local_costmap/robot_base_frame" parameter), I find that it exists well and is settled to 'odom' value (respectively 'base_link').
I also tried to write directly "odom" and "base_link" instead of "move_base/local_costmap/global_frame" and "move_base/local_costmap/robot_base_frame" but I have the same error:
[ERROR] [..., ...]: "odom" passed to lookupTransform argument target_frame does not exist.
However, when I do:
rosrun tf view_frames
I have the following tree:
The first and the third frames are those which interest me.
Moreover, when I use the command:
rosrun tf tf_monitor odom base_link
I have this:
RESULTS: for odom to base_link
Chain is: odom -> base_footprint -> base_link
Net delay avg = 0.00599856: max = 0.016
Frames:
Frame: base_footprint published by unknown_publisher Average Delay: 0.000963 Max Delay: 0.005
Frame: base_link published by unknown_publisher Average Delay: -0.500052 Max Delay: 0
All Broadcasters:
Node: unknown_publisher 146.156 Hz, Average Delay: -0.102412 Max Delay: 0.005
If someone can help me, I will be very grateful,
lfr
Check my update with waitforTransform