How to synchronize received laser scan and predicted robot pose before scan matching
Hi, all! I am learning slam and studying the source code of hector mapping and karto mapping. It is well known that these two slam algorithms utilize scan matching to estimate the robot pose.
Before every time doing scan matching, a predicted robot pose is obtained from tf tree. For example, in the source code of hector mapping, every time a laser scan is received, the transform between map frame and base_link frame is obtained as the start estimate of scan matching. Very similar to hector mapping, in nav2d_karto, every time a laser scan is received, the transform between the odom frame and laser frame is obtained as the start estimate of scan matching.
However, every time a laser scan is received at some timestamp, the transform obtained from tf tree can't be obtained at the same timestamp. For example, in hector mapping, it always outputs error messages:
[ERROR] [1501720267.512793847]: Transform from map to base_link failed with Lookup would require extrapolation into the future. Requested time 84.940000000 but the latest data is at time 84.740000000, when looking up transform from frame [base_link] to frame [map]
And in nav2d_karto, the warning messages are same to hector mapping:
Failed to compute odometry pose, skipping scan (Lookup would require extrapolation into the future. Requested time 68.500000000 but the latest data is at time 68.490000000, when looking up transform from frame [laser_sensor_link] to frame [offset]).
The above two error messages mean that the timestamp of transform of start estimate is after the one of received laser scan, in another word, the speed of getting the transform of start estimate is slower than receiving laser scan. Even if the frequency of laser scan is decreased, the problem still exists.
I want to solve this problem, because, I have found that the out-of-sync on timestamp between two data source(laser scan and tf tree) would influence the results of built map.
So Looking forwards to any great advices here, Thank you!
P.S Another thing worth mentioning is, in slam_karto (another karto mapping package), the transform between odom frame and base_link frame is obtained as start estimate of scan matching, above problem mentioned doesn't exist.
So we also wonder that, being same as slam algorithm , why this problem exists in nav2d_karo but not in slam_karto.