We have a ROS2 Publish Laser Scan node. We found that in case we set the
Rotation Rate, when trying to visualize it in rviz2 we get the following error (repeated endless times):
[bash-21] 1666626946.927442130 [rviz2] [ERROR] Lookup would require extrapolation into the future. Requested time 6.274777 but the latest data is at time 6.266667, when looking up transform from frame [base_lidar_link] to frame [map]
We have made sure that
use_sim_time = true, and that the clock is published. After hours of trying to fix it, we found this post: LaserScan not visualized in rviz - #4 by hoanggiang, and removing rotation rate fixed the issue for us.
The problem is that this doesn’t simulate our real lidar, which doesn’t publish full scans each time.
After looking a little into
OgnROS2PublishLaserScan.cpp, it seems like this can be caused due to time_increment been set when rotation rate exists (it is always set, it will just be 0 if there is no rotation rate). Now since the
stamp property on the
LaserScan message is set to now, if you set time_increment on the
LaserScan, it causes the ranges to be in a future time. As it takes
time_increment * range_index + stamp.