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

Calculate the transformation from map to odom

asked 2018-11-23 17:22:26 -0500

AutoCar gravatar image

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

// broadcast transform
_tf_br.sendTransform(tf_map_to_odom);

Thank you very much for your help.

edit retag flag offensive close merge delete

Comments

Anyone knows?

AutoCar gravatar image AutoCar  ( 2018-11-25 12:12:05 -0500 )edit

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

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

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-11-26 03:21:21 -0500

pavel92 gravatar image

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.

edit flag offensive delete link more

Comments

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.

AutoCar gravatar image AutoCar  ( 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?

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

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

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

Question Tools

2 followers

Stats

Asked: 2018-11-23 17:22:26 -0500

Seen: 1,240 times

Last updated: Nov 26 '18