0
$\begingroup$

Rosanswers logo

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

// broadcast transform
_tf_br.sendTransform(tf_map_to_odom);

Originally posted by AutoCar on ROS Answers with karma: 102 on 2018-11-28

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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.


Originally posted by mgruhler with karma: 12390 on 2018-11-29

This answer was ACCEPTED on the original site

Post score: 1

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.