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

Publishing map->odom transform using custom localization and SLAM algorithms

asked 2022-06-01 14:34:42 -0500

onishly gravatar image

I am writing my own FastSLAM and Monte-Carlo localization algorithms and I am trying to figure out how to calculate the map->odom transform. From what I understand, my SLAM and localization algorithm will give the transform from the map frame to the base_link frame when given odometry data calculated in the odom frame. I have seen that AMCL and Gmapping publish the transform from the odom frame to the map frame, but I am not sure of how to calculate this once I have the map to base_link transform from the SLAM or localization algorithm.

Would I assume that the transform from the odometry data is "correct", create transformation matrices for T_(map->base_link) and T_(odom->base_link) and then say:

T_(map->odom) = T_(map->base_link) * T_(odom->base_link)^-1

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
1

answered 2022-06-07 21:17:11 -0500

updated 2022-06-09 08:12:37 -0500

Though not all the same but similar for the localization and SLAM algorithms. The TF publishing in GMapping is easier to understand.

slam_gmapping/gmapping/src/slam_gmapping.cpp

map_to_odom_ = (odom_to_laser * laser_to_map).inverse();

The following is the most frequently used and I am sure it is correct.

T_(map->odom) = (T_(odom->base_link) * T_(map->base_link)^-1)^-1

T_(odom->base_link) is given by your odometry (either encoders or VO or anything else), T_(map->base_link) is calculated by the "localization" algorithm. Both are known.

edit flag offensive delete link more
1

answered 2022-06-08 07:25:20 -0500

Mike Scheutzow gravatar image

Yes, your matrix multiply is correct. You can eliminate the inverse() by asking tf2 for T(base_link->odom).

This calculation is valid for any arbitrary value of T(odom->base_link), so "correctness" is not a concern.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2022-06-01 14:25:32 -0500

Seen: 641 times

Last updated: Jun 09 '22