{
  "id": "ros2/tf2-timeout-on-startup",
  "signature": "tf2: Transform cache timed out while waiting for transform from 'base_link' to 'odom'",
  "signature_zh": "tf2：等待从'base_link'到'odom'的变换时，变换缓存超时",
  "regex": "Transform cache timed out while waiting for transform from '.*?' to '.*?'",
  "domain": "ros2",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "The transform broadcaster (e.g., robot_state_publisher or a custom node) is not publishing the required transform frequently enough, or there is a startup delay where the transform is not yet available, causing tf2's cache lookup to timeout after the default duration (e.g., 1 second).",
  "root_cause_type": "generic",
  "root_cause_zh": "变换广播器（如robot_state_publisher或自定义节点）未足够频繁地发布所需变换，或者存在启动延迟导致变换尚未可用，导致tf2的缓存查找在默认持续时间（如1秒）后超时。",
  "versions": [
    {
      "version": "ROS2 Humble",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "ROS2 Iron",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "ROS2 Rolling",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Increasing the tf2 buffer timeout to a very large value (e.g., 10 seconds) in the node's code",
      "why_fails": "This masks the problem but does not fix the underlying publishing issue; the transform may never arrive if the broadcaster is not running.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "Adding a sleep(5) at the beginning of the node's main function to wait for transforms",
      "why_fails": "Sleeping does not guarantee the transform will be available; it only delays the error, and the transform may still timeout.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Ensure the transform broadcaster is publishing at a high enough rate (e.g., 50 Hz) and that the node's timer for publishing is set correctly. For robot_state_publisher, check that the URDF is loaded and the joint states are being published.",
      "success_rate": 0.9,
      "how": "Ensure the transform broadcaster is publishing at a high enough rate (e.g., 50 Hz) and that the node's timer for publishing is set correctly. For robot_state_publisher, check that the URDF is loaded and the joint states are being published.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Add a retry loop with exponential backoff in the subscriber node: 'while not tf_buffer.can_transform('odom', 'base_link', rclpy.time.Time(), timeout=rclpy.duration.Duration(seconds=0.1)): rclpy.spin_once(node)'",
      "success_rate": 0.85,
      "how": "Add a retry loop with exponential backoff in the subscriber node: 'while not tf_buffer.can_transform('odom', 'base_link', rclpy.time.Time(), timeout=rclpy.duration.Duration(seconds=0.1)): rclpy.spin_once(node)'",
      "condition": "",
      "sources": []
    },
    {
      "action": "If using a static transform, publish it with a static_transform_publisher in the launch file to ensure it's always available.",
      "success_rate": 0.95,
      "how": "If using a static transform, publish it with a static_transform_publisher in the launch file to ensure it's always available.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "确保变换广播器以足够高的频率（如50 Hz）发布，并且节点的定时器设置正确。对于robot_state_publisher，检查URDF是否已加载并且关节状态正在发布。",
    "在订阅者节点中添加带指数退避的重试循环：'while not tf_buffer.can_transform('odom', 'base_link', rclpy.time.Time(), timeout=rclpy.duration.Duration(seconds=0.1)): rclpy.spin_once(node)'",
    "如果使用静态变换，在启动文件中使用static_transform_publisher发布它，以确保它始终可用。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://docs.ros.org/en/humble/Tutorials/Intermediate/Tf2/Tf2-Main.html",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.84,
  "fix_success_rate": 0.88,
  "resolvable": "true",
  "first_seen": "2023-09-05",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}