ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
5

Getting Coordinates of Turtlebot

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

zlalanne gravatar image

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

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?

Thanks

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
7

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

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
4

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

dornhege gravatar image

rosrun tf tf_echo /map /base_link

edit flag offensive delete link more

Comments

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 -0600 )edit

Question Tools

4 followers

Stats

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

Seen: 6,546 times

Last updated: Apr 16 '12