{
  "id": "ros2/ros2-launch-arg-substitution-not-found",
  "signature": "ros2 launch: Substitution error: argument 'my_arg' not found in launch configuration",
  "signature_zh": "ros2 launch: 替换错误：在启动配置中找不到参数'my_arg'",
  "regex": "Substitution error: argument '.*' not found in launch configuration",
  "domain": "ros2",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "A launch file uses $(var my_arg) or similar substitution for an argument that was never declared with DeclareLaunchArgument.",
  "root_cause_type": "generic",
  "root_cause_zh": "启动文件使用$(var my_arg)或类似替换，但该参数从未通过DeclareLaunchArgument声明。",
  "versions": [
    {
      "version": "ROS2 Humble (launch 1.0.0)",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "ROS2 Iron (launch 1.1.0)",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "ROS2 Rolling (launch 1.2.0)",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Add the argument to the launch command line without declaring it in the file",
      "why_fails": "Arguments passed on the command line must match a declared argument; otherwise, ros2 launch ignores them.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "Use $(env my_arg) instead of $(var my_arg)",
      "why_fails": "Environment variables are not the same as launch arguments; the substitution syntax is different.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Add a DeclareLaunchArgument for 'my_arg' in the launch file before using it: from launch.actions import DeclareLaunchArgument; ld.add_action(DeclareLaunchArgument('my_arg', default_value='default'))",
      "success_rate": 0.95,
      "how": "Add a DeclareLaunchArgument for 'my_arg' in the launch file before using it: from launch.actions import DeclareLaunchArgument; ld.add_action(DeclareLaunchArgument('my_arg', default_value='default'))",
      "condition": "",
      "sources": []
    },
    {
      "action": "If the argument is optional, use a conditional substitution: $(var my_arg 'default_value') to provide a fallback.",
      "success_rate": 0.85,
      "how": "If the argument is optional, use a conditional substitution: $(var my_arg 'default_value') to provide a fallback.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "在使用参数之前，在启动文件中添加DeclareLaunchArgument：from launch.actions import DeclareLaunchArgument; ld.add_action(DeclareLaunchArgument('my_arg', default_value='default'))",
    "如果参数是可选的，使用条件替换：$(var my_arg 'default_value')来提供默认值。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://docs.ros.org/en/humble/Tutorials/Intermediate/Launch/Launch-system.html",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.88,
  "fix_success_rate": 0.9,
  "resolvable": "true",
  "first_seen": "2023-06-20",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}