Ask Your Question

Getting Coordinates of Turtlebot

asked 2012-04-14 12:29:23 -0500

zlalanne gravatar image

updated 2012-04-14 17:17:10 -0500

We have successfully created a map and our robot localizes well using AMCL. Now we want to be able to get the coordinates of the robot once it has localized itself within the map that we supplied. What is the best way to get the coordinates of the robot relative to the map?


edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2012-04-16 01:52:35 -0500

Eric Perko gravatar image

The best way to get the current location of the Turtlebot is using TF. Assuming you are in C++ and already have a tf::TransformListener object as listener, that your robot's local frame is base_link and your map frame is map, you could use a block of code like the following:

geometry_msgs::PoseStamped pBase, pMap;
pBase.header.frame_id = "base_link";
pBase.pose.position.x = 0.0;
pBase.pose.position.y = 0.0;
pBase.pose.orientation = tf::createQuaternionMsgFromYaw(0.0);
ros::Time current_transform = ros::Time::now();
listener.getLatestCommonTime(pBase.header.frame_id, "map", current_transform, NULL);
pBase.header.stamp = current_transform;
listener.transformPose("map", pBase, pMap);
// pMap now contains the pose of the robot transformed into map 
// coordinates according to the TF data available at time "current_transform"

If you are unfamiliar with the TF library, you should read through the tutorials.

edit flag offensive delete link more

answered 2012-04-14 22:44:01 -0500

dornhege gravatar image

rosrun tf tf_echo /map /base_link

edit flag offensive delete link more


So this launches a node that publishes the data I need correct? Do I need to subscribe to a topic it publishes? Thanks for the help.

zlalanne gravatar image zlalanne  ( 2012-04-15 10:49:32 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2012-04-14 12:29:23 -0500

Seen: 5,152 times

Last updated: Apr 16 '12