Transformation between "map" and "odom" in tf

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();

tf_map_to_odom.setOrigin(tf::Vector3(
point_in_map.x - odom.pose.pose.position.x,
point_in_map.y - odom.pose.pose.position.y,
0));

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

_tf_br.sendTransform(tf_map_to_odom);
edit retag close merge delete

Sort by » oldest newest most voted 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.

more