{
  "id": "ros2/launch-argument-type-mismatch",
  "signature": "ros2 launch: argument 'my_arg': expected type 'int' but got 'string'",
  "signature_zh": "ros2 launch：参数'my_arg'：期望类型'int'但收到'string'",
  "regex": "argument '.*?': expected type '.*?' but got '.*?'",
  "domain": "ros2",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "Launch file declares a launch argument with a specific type (e.g., LaunchConfiguration('my_arg', data_type='int')) but the user passes a string value on the command line or via a launch file that cannot be implicitly converted.",
  "root_cause_type": "generic",
  "root_cause_zh": "启动文件声明了一个具有特定类型的启动参数（如LaunchConfiguration('my_arg', data_type='int')），但用户通过命令行或另一个启动文件传递了无法隐式转换的字符串值。",
  "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 Jazzy",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Adding quotes around the integer value (e.g., 'ros2 launch my_pkg my_launch.py my_arg:=5' becomes 'my_arg:=\"5\"')",
      "why_fails": "Quotes force the value to be a string, which is exactly what causes the type mismatch.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "Changing the launch file to remove type checking entirely",
      "why_fails": "Type checking is a safety feature; removing it may cause runtime errors if downstream nodes expect a specific type.",
      "fail_rate": 0.4,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Ensure the argument is passed without quotes: 'ros2 launch my_pkg my_launch.py my_arg:=5' (not 'my_arg:=\"5\"'). If using a YAML file, specify the value as an integer (e.g., 'my_arg: 5').",
      "success_rate": 0.95,
      "how": "Ensure the argument is passed without quotes: 'ros2 launch my_pkg my_launch.py my_arg:=5' (not 'my_arg:=\"5\"'). If using a YAML file, specify the value as an integer (e.g., 'my_arg: 5').",
      "condition": "",
      "sources": []
    },
    {
      "action": "Modify the launch file to accept a string and convert it to int inside the launch file using Python's int() function: 'int(LaunchConfiguration('my_arg'))'.",
      "success_rate": 0.9,
      "how": "Modify the launch file to accept a string and convert it to int inside the launch file using Python's int() function: 'int(LaunchConfiguration('my_arg'))'.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "确保参数不加引号传递：'ros2 launch my_pkg my_launch.py my_arg:=5'（而不是'my_arg:=\"5\"'）。如果使用YAML文件，将值指定为整数（如'my_arg: 5'）。",
    "修改启动文件以接受字符串，并在启动文件内部使用Python的int()函数转换为整数：'int(LaunchConfiguration('my_arg'))'。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://docs.ros.org/en/humble/Tutorials/Intermediate/Launch/Using-Launch-Arguments.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-11-20",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}