ROS Answers: Open Source Q&A Forum - RSS feedhttps://answers.ros.org/questions/Open source question and answer forum written in Python and DjangoenROS Answers is licensed under Creative Commons Attribution 3.0Fri, 04 May 2018 06:46:43 -0500Finding map to odom tfhttps://answers.ros.org/question/290288/finding-map-to-odom-tf/ Hi,
So I know my robots position in map frame and I know its position in odom frame. How can I get tf which translates map-odom?
I know package like amcl will give you pose in map and also give map-odom tf. I am making my own localization algorithm and can calculate my position in map, and I have got odom-baselink tf, but haven't figured out how to calculate map-odom tf. I know I can run mathematical equations to calculate it, but is there any function in rospy transformations of even roscpp that might automatically handle it?
Thank you
Wed, 02 May 2018 22:04:11 -0500https://answers.ros.org/question/290288/finding-map-to-odom-tf/Answer by villie for <p>Hi,</p>
<p>So I know my robots position in map frame and I know its position in odom frame. How can I get tf which translates map-odom?
I know package like amcl will give you pose in map and also give map-odom tf. I am making my own localization algorithm and can calculate my position in map, and I have got odom-baselink tf, but haven't figured out how to calculate map-odom tf. I know I can run mathematical equations to calculate it, but is there any function in rospy transformations of even roscpp that might automatically handle it?</p>
<p>Thank you</p>
https://answers.ros.org/question/290288/finding-map-to-odom-tf/?answer=290464#post-id-290464I found the answer to that in amcl code.
1. First you convert map to base position into a transform.
2. Then you get tf::Stamped<tf::Pose> object of it
3. Then you reverse it
4. After that you transform the reverse to "odom" frame
5. Then you make a temporary transform object from above result
6. Reverse of transform is result and you broadcast it.
Below is the code.
tf::Stamped<tf::Pose> map_to_base (map_position_transform.inverse(),
msg->header.stamp,
"base_footprint");
listener.transformPose("odom",
map_to_base,
odom_to_map);
latest_tf_ = tf::Transform(tf::Quaternion(odom_to_map.getRotation()),
tf::Point(odom_to_map.getOrigin()));
tf::StampedTransform map_to_odom(latest_tf_.inverse(),
ros::Time::now(),
"map", "odom");
br.sendTransform(tf::StampedTransform(map_to_odom, ros::Time::now(), "map", "odom"));Fri, 04 May 2018 06:46:43 -0500https://answers.ros.org/question/290288/finding-map-to-odom-tf/?answer=290464#post-id-290464