# tf2.BufferCore::lookupTransform: 找不到从 frame_a 到 frame_b 的变换，错误：传递给 lookupTransform 参数 target_frame 的 'frame_b' 不存在。缓冲区大小已超出。

- **ID:** `ros2/tf2-buffer-size-exceeded`
- **领域:** ros2
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

tf2 缓冲区大小有限（默认 10 秒），较旧的变换会被移除；如果变换查找需要早于缓冲区窗口的数据，则会失败。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| ROS2 Foxy | active | — | — |
| ROS2 Galactic | active | — | — |
| ROS2 Humble | active | — | — |
| tf2 2.5.x | active | — | — |

## 解决方案

1. ```
   在节点中增加 tf2 缓冲区大小：'tf_buffer = tf2_ros.Buffer(cache_time=rclpy.duration.Duration(seconds=30.0))'
   ```
2. ```
   确保变换发布者以足够高的速率（例如 50 Hz）连续运行，并检查是否有丢弃的消息：'ros2 topic hz /tf'
   ```

## 无效尝试

- **** — This may cause memory issues and does not address the root cause of missing transforms; it only delays the problem. (60% 失败率)
- **** — The transform may never become available if the publisher has stopped or the frame is no longer being broadcast. (90% 失败率)
- **** — If sim_time is enabled but no /clock is published, timestamps may be zero, causing all lookups to fail. (85% 失败率)
