{
  "id": "ros2/ros2-launch-parameter-substitution-type-mismatch",
  "signature": "ros2 launch: Substitution error: parameter 'my_param' expected type 'double' but got 'integer'",
  "signature_zh": "ros2 launch：替换错误：参数 'my_param' 期望类型 'double' 但得到 'integer'",
  "regex": "Substitution error: parameter '([^']+)' expected type '([^']+)' but got '([^']+)'",
  "domain": "ros2",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "Launch file uses a substitution that evaluates to a type incompatible with the declared parameter type (e.g., integer vs double) due to LaunchConfiguration or Python substitution returning an int instead of float.",
  "root_cause_type": "generic",
  "root_cause_zh": "启动文件使用的替换结果与声明的参数类型不兼容（例如整数 vs 双精度浮点数），因为 LaunchConfiguration 或 Python 替换返回了 int 而非 float。",
  "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"
    },
    {
      "version": "launch:2.0.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Changing the parameter type in the node's declaration to match the substitution type",
      "why_fails": "The node may expect a specific type for correct operation; changing the declaration can cause runtime errors in the node.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    },
    {
      "action": "Wrapping the substitution in str() without converting to the correct numeric type",
      "why_fails": "String substitution will be interpreted as a string, not a number, causing a different type mismatch error.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Explicitly cast the substitution to the expected type using PythonExpression. Example:\nfrom launch.substitutions import PythonExpression\n\nparam_value = PythonExpression(['float(', LaunchConfiguration('my_param'), ')'])\n\nThis forces the substitution to evaluate to a float.",
      "success_rate": 0.9,
      "how": "Explicitly cast the substitution to the expected type using PythonExpression. Example:\nfrom launch.substitutions import PythonExpression\n\nparam_value = PythonExpression(['float(', LaunchConfiguration('my_param'), ')'])\n\nThis forces the substitution to evaluate to a float.",
      "condition": "",
      "sources": []
    },
    {
      "action": "In the launch file, use a typed substitution like FloatSubstitution if available, or ensure the LaunchConfiguration default is a float:\nfrom launch.substitutions import LaunchConfiguration\n\nparam = LaunchConfiguration('my_param', default=0.0)  # default as float",
      "success_rate": 0.85,
      "how": "In the launch file, use a typed substitution like FloatSubstitution if available, or ensure the LaunchConfiguration default is a float:\nfrom launch.substitutions import LaunchConfiguration\n\nparam = LaunchConfiguration('my_param', default=0.0)  # default as float",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "使用 PythonExpression 显式将替换结果转换为期望类型。示例：\nfrom launch.substitutions import PythonExpression\n\nparam_value = PythonExpression(['float(', LaunchConfiguration('my_param'), ')'])\n\n这将强制替换结果为浮点数。",
    "在启动文件中使用类型化替换（如 FloatSubstitution，如果可用），或确保 LaunchConfiguration 默认值为浮点数：\nfrom launch.substitutions import LaunchConfiguration\n\nparam = LaunchConfiguration('my_param', default=0.0)  # 默认值为浮点数"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://docs.ros.org/en/humble/Tutorials/Intermediate/Launch/Using-Substitutions.html",
  "official_doc_section": null,
  "error_code": "ROS2-2001",
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.9,
  "resolvable": "true",
  "first_seen": "2024-01-10",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}