# ROS2 Humble下SLAM-Toolbox报TF2消息时间早于变换缓存数据错误

> 原文链接：https://robotics.hellobike.com/pitfalls/2025-03-27-robotics-se-115148
> 频道：pitfalls | 更新日期：2025-03-27 | 标签：auto, stackexchange, slam
> 核心摘要：Gazebo仿真中使用async slam-toolbox节点时出现TF2时间相关报错，通过设置所有节点use_sim_time参数为true解决

# ROS2 Humble下SLAM-Toolbox报TF2消息时间早于变换缓存数据错误

::: v-pre
> 本文由 AI 根据公开内容整理，可能有误，请以原文为准：[ROS2 Humble- Gazebo & SLAM-Toolbox: TF2 dropped message reason 'the timestamp on the message is earlier than all the data in the transform cache"](https://robotics.stackexchange.com/questions/115148/ros2-humble-gazebo-slam-toolbox-tf2-dropped-message-reason-the-timestamp-on)（Robotics Stack Exchange #115148）

**状态**：已解决

## 问题

配置async slam-toolbox节点时出现报错，`async_slam_toolbox_node`提示消息过滤丢弃base_link帧消息，原因是消息时间戳早于变换缓存中的所有数据

## 环境

Ubuntu 22.04，ROS2 Humble，CPU I5+32GB RAM无GPU，RMW为CycloneDDS，使用Gazebo仿真漫游车机器人，包含IMU、磁力计、2D激光雷达、里程计

## 解决办法

1. 确保robot_state_publisher节点的`use_sim_time`参数设为True
2. 所有使用仿真时间的节点都将`use_sim_time`参数设为True

原问题作者：Meltwin；采纳答案作者：Antonia Hoffman。原内容依 CC BY-SA 4.0 授权，本页摘要同样依 CC BY-SA 4.0 授权。
:::

## 原始参考来源 (Sources)

- [Robotics Stack Exchange #115148：ROS2 Humble- Gazebo & SLAM-Toolbox: TF2 dropped message reason 'the timestamp on the message is earlier than all the data in the transform cache"](https://robotics.stackexchange.com/questions/115148/ros2-humble-gazebo-slam-toolbox-tf2-dropped-message-reason-the-timestamp-on)