amcl_pose topic returns different than the map->odom->base transform
As the title states, amcl_pose is not giving me the same result as taking the map->odom transform and then combining that with the odom->base transform. I was originally using the map->odom transform to just correct my drift, but if anything it seems like amcl_pose is right, and the map->odom is wrong, at least based on comparing what I see on Rviz with where my robot actually was.
Rather than just swapping to amcl_pose I want to try and understand what is happening. Let me just show some culled log files from a ROS node that takes in my robots scans/odometry, publishes them for AMCL, and also listens for the amcl_pose topic to be published... All values are (x,y,theta) by the way:
[ INFO] [1541537079.104442235]: amcl_pose = 0.979757,1.041833,1.677116
[ INFO] [1541537079.104487697]: map->odom = 0.081080,-0.287248,0.212756
[ INFO] [1541537080.089657443]: odom->base = 1.164587,1.157537,1.452360
[ INFO] [1541537081.010870954]: odom->base = 1.170495,1.207187,1.452360
[ INFO] [1541537082.035011221]: odom->base = 1.176403,1.256837,1.452360
[ INFO] [1541537083.058245129]: odom->base = 1.181755,1.305040,1.464360
[ INFO] [1541537084.082075926]: odom->base = 1.186469,1.353310,1.476360
[ INFO] [1541537085.003592600]: odom->base = 1.190543,1.401638,1.488360
[ INFO] [1541537086.027702051]: odom->base = 1.193791,1.448525,1.512360
[ INFO] [1541537087.052686791]: odom->base = 1.196423,1.496953,1.524360
[ INFO] [1541537088.076706817]: odom->base = 1.198293,1.545416,1.536360
[ INFO] [1541537088.997988424]: odom->base = 1.199228,1.592406,1.560360
[ INFO] [1541537089.104671886]: amcl_pose = 0.880494,1.507386,1.807045
[ INFO] [1541537089.104765416]: map->odom = 0.106420,-0.329653,0.246685
You can clearly see that the last amcl_pose says the robot is at X=0.880494, but removing the drift error AMCL also published from the last published odometry value returns X=1.199-0.106=1.093. The Y value is even farther off!
I don't know if I'm misunderstanding something about AMCL, or misusing it somehow. These should be the same right? Thanks for any help.
Update: mgruhler pointed out what I was doing wrong, but I'll explain what I should have done if anyone has the same problem and stumbles upon this:
The odom->base vector is in the odometry frame, a different frame of reference than the map frame. Since there is a rotation between the two, that means you cannot simply sum up their vectors.
Using a rotation matrix with the known rotation (0.246685rad in this case) on the odom->base vector to converts it into the map frame, and then it can simple be summed up with the map->odom vector, and you get the expected answer.
Miscellanious info I don't think matters for this issue: Ubuntu 16.04 LTS ROS kinetic 1.12.14