Ask Your Question

Transformation between "map" and "odom" in tf

asked 2018-11-28 14:55:14 -0500

AutoCar gravatar image

updated 2019-02-01 19:18:38 -0500

jayess gravatar image

Let's assume I am working on a localization algorithm and need to publish the transformation between "map" frame and "odom" frame. I already know he robot's location in "map" coordinates is PM, and its location in "odom" coordinates is PO, if I publish a transformation using "map" as parent frame, and "odom" as the child frame, then this transformation should be PO-PM or PM-PO?

Update: Below is my code, is it correct?

tf::StampedTransform tf_map_to odom
// set up parent and child frames
tf_map_to_odom.frame_id_ = string("map");
tf_map_to_odom.child_frame_id_ = string("odom");

// set up publish rate
//ros::Rate loop_rate(100);

// main loop
tf_map_to_odom.stamp_ = ros::Time::now();

   point_in_map.x - odom.pose.pose.position.x,
   point_in_map.y - odom.pose.pose.position.y, 

tf::Quaternion q;
q.setRPY(0, 0, point_in_map.orientation);
tf::Quaternion qq;
quaternionMsgToTF(ddom.pose.pose.orientation, qq);
q = q * qq.inverse();

// broadcast transform
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2018-11-29 01:18:21 -0500

mgruhler gravatar image

PM-PO, but you need to make sure you are not simply "subtracting", as you have to take care about the orientation of the frames as well.

As a simple example, assume PM = (10,0,0) in (x,y,yaw), PO = (2,0,0), you'd get MO = (8,0,0).

In amcl it is solved like this , e.g.

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

1 follower


Asked: 2018-11-28 14:55:14 -0500

Seen: 296 times

Last updated: Feb 01