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

# Calculate the transformation from map to odom

Hi all,

For the last a few days, I am struggling with the correct way to calculate the transformation from map to odom. I have a robot system, which publish odom message. Since odom drift, I wrote my own algorithm. My algorithm can compute the location and orientation of the robot in the world (map) system. And I would like to publish a "map" frame and the transformation from map to odom.

I am working with a 2D robot and suppose geometry_msgs::Point position1 is the robot location in odom, geometry_msgs/Quaternion orientation1 is the robot orientation in odom, x, y, theta is real location and orientation of the robot in the world system I calculated with my algorithm. theta uses the x axis as 0 degree. What is the correct way to calculate the transformation from map to odom and publish it in tf?

Below is the code I am using to publish tf:

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

// set the time
tf_map_to_odom.stamp_ = ros::Time::now();

//set the transformation
tf_map_to_odom.setOrigin(***How to calculate this?***));
tf_map_to_odom.setRotation(***How to calculate this?***);

_tf_br.sendTransform(tf_map_to_odom);


Thank you very much for your help.

edit retag close merge delete

Anyone knows?

( 2018-11-25 12:12:05 -0500 )edit

Did you did this? If yes can you show your code?

( 2021-09-12 02:24:06 -0500 )edit

Sort by ยป oldest newest most voted

Which localization are you using? Usually the odom->map transform is broadcasted by the localization package. You can check this question or check the existing localization solutions to see how it is done.

To get a transform between two frames check this question.

more

I am writing my own localization algorithm and can calculate the position of the robot in "world" or "map" coordinate system. I am just not sure how to compute the offset from "world" system to "odom" system.

( 2018-11-28 14:48:30 -0500 )edit

More specifically, let's assume the 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?

( 2018-11-28 14:54:01 -0500 )edit

I think that the transform is usually from parent to child frame in this case

( 2018-11-29 05:48:24 -0500 )edit