0
$\begingroup$

Rosanswers logo

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


Originally posted by onishly on ROS Answers with karma: 13 on 2022-06-01

Post score: 1

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

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.


Originally posted by tianb03 with karma: 710 on 2022-06-07

This answer was ACCEPTED on the original site

Post score: 1

$\endgroup$
0
$\begingroup$

Rosanswers logo

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.


Originally posted by Mike Scheutzow with karma: 4903 on 2022-06-08

This answer was NOT 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.