{
  "id": "ros2/rclpy-parameter-override-not-applied",
  "signature": "rclpy.exceptions.ParameterNotSetException: Parameter 'my_param' not set, but override was provided via --ros-args -p",
  "signature_zh": "rclpy.exceptions.ParameterNotSetException：参数 'my_param' 未设置，但通过 --ros-args -p 提供了覆盖",
  "regex": "Parameter '.*' not set, but override was provided via --ros-args -p",
  "domain": "ros2",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "The parameter override is provided before the node is declared, or the node declares the parameter with a different name/type, causing the override to be ignored.",
  "root_cause_type": "generic",
  "root_cause_zh": "参数覆盖在节点声明之前提供，或者节点使用不同的名称/类型声明参数，导致覆盖被忽略。",
  "versions": [
    {
      "version": "Humble",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Iron",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Jazzy",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Add more --ros-args -p arguments with different parameter names",
      "why_fails": "The issue is timing or naming, not the number of overrides; adding more won't fix the mismatch.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "Use a YAML file instead of command-line -p arguments",
      "why_fails": "YAML files have the same timing and naming constraints; the root cause remains.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "Set the parameter in the node's constructor before calling super().__init__()",
      "why_fails": "Parameters must be declared after the node is initialized; doing so before can cause undefined behavior.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Declare the parameter with a default value before using it in the node: self.declare_parameter('my_param', 'default_value'). Then ensure the override is passed in the launch file after the node is started: <node pkg=\"my_pkg\" exec=\"my_node\" name=\"my_node\"><param name=\"my_param\" value=\"override_value\"/></node>",
      "success_rate": 0.9,
      "how": "Declare the parameter with a default value before using it in the node: self.declare_parameter('my_param', 'default_value'). Then ensure the override is passed in the launch file after the node is started: <node pkg=\"my_pkg\" exec=\"my_node\" name=\"my_node\"><param name=\"my_param\" value=\"override_value\"/></node>",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use the 'allow_undeclared_parameters' option in the node's constructor: node = rclpy.create_node('my_node', allow_undeclared_parameters=True). Then overrides will be applied regardless of declaration order.",
      "success_rate": 0.85,
      "how": "Use the 'allow_undeclared_parameters' option in the node's constructor: node = rclpy.create_node('my_node', allow_undeclared_parameters=True). Then overrides will be applied regardless of declaration order.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Move the parameter declaration to the beginning of the __init__ method, before any other node operations, and use the same name as in the override.",
      "success_rate": 0.8,
      "how": "Move the parameter declaration to the beginning of the __init__ method, before any other node operations, and use the same name as in the override.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Declare the parameter with a default value before using it in the node: self.declare_parameter('my_param', 'default_value'). Then ensure the override is passed in the launch file after the node is started: <node pkg=\"my_pkg\" exec=\"my_node\" name=\"my_node\"><param name=\"my_param\" value=\"override_value\"/></node>",
    "Use the 'allow_undeclared_parameters' option in the node's constructor: node = rclpy.create_node('my_node', allow_undeclared_parameters=True). Then overrides will be applied regardless of declaration order.",
    "Move the parameter declaration to the beginning of the __init__ method, before any other node operations, and use the same name as in the override."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://docs.ros.org/en/humble/Tutorials/Intermediate/Parameters.html",
  "official_doc_section": null,
  "error_code": "RCLPY_PARAM_OVERRIDE_001",
  "verification_tier": "ai_generated",
  "confidence": 0.86,
  "fix_success_rate": 0.87,
  "resolvable": "true",
  "first_seen": "2024-01-20",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}