{"record":{"id":"9f245ea82f6be30d","repo":"AtsushiSakai/PythonRobotics","slug":"robot-type-must-be-an-instance-of-robottype","errorCode":null,"errorMessage":"robot_type must be an instance of RobotType","messagePattern":"robot_type must be an instance of RobotType","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"PathPlanning/DynamicWindowApproach/dynamic_window_approach.py","lineNumber":88,"sourceCode":"                            [5.0, 9.0],\n                            [8.0, 9.0],\n                            [7.0, 9.0],\n                            [8.0, 10.0],\n                            [9.0, 11.0],\n                            [12.0, 13.0],\n                            [12.0, 12.0],\n                            [15.0, 15.0],\n                            [13.0, 13.0]\n                            ])\n\n    @property\n    def robot_type(self):\n        return self._robot_type\n\n    @robot_type.setter\n    def robot_type(self, value):\n        if not isinstance(value, RobotType):\n            raise TypeError(\"robot_type must be an instance of RobotType\")\n        self._robot_type = value\n\n\nconfig = Config()\n\n\ndef motion(x, u, dt):\n    \"\"\"\n    motion model\n    \"\"\"\n\n    x[2] += u[1] * dt\n    x[0] += u[0] * math.cos(x[2]) * dt\n    x[1] += u[0] * math.sin(x[2]) * dt\n    x[3] = u[0]\n    x[4] = u[1]\n\n    return x","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/AtsushiSakai/PythonRobotics/blob/1fe4fb980f6a12fe21c3c33d2b4da97a52c9154d/PathPlanning/DynamicWindowApproach/dynamic_window_approach.py#L70-L106","documentation":"Raised by the robot_type property setter on Config when assigned a value that is not a RobotType enum instance. The config enforces type safety because downstream DWA logic branches on the specific robot type.","triggerScenarios":"Assigning config.robot_type = 'omnidirectional' (string) or config.robot_type = 1 instead of a RobotType member like RobotType.cycle.","commonSituations":"Loading config values from YAML/JSON where enums deserialize as strings, or porting config code that previously used plain strings.","solutions":["Assign the enum: from dynamic_window_approach import RobotType; config.robot_type = RobotType.cycle.","Convert loaded strings: RobotType[value_str] or RobotType(value_str).","Keep config serialization/deserialization enum-aware (e.g. save .value, load by name)."],"exampleFix":"# before\nconfig.robot_type = 'diff'  # string\n\n# after\nconfig.robot_type = RobotType.diff","handlingStrategy":"type-guard","validationCode":"from PathPlanning.DynamicWindowApproach.dynamic_window_approach import RobotType\nassert isinstance(cfg_value, RobotType) or cfg_value in [m.value for m in RobotType]","typeGuard":"from PathPlanning.DynamicWindowApproach.dynamic_window_approach import RobotType\n\ndef to_robot_type(v):\n    return v if isinstance(v, RobotType) else RobotType[v] if v in RobotType.__members__ else RobotType(v)","tryCatchPattern":null,"preventionTips":["Convert config-file strings to enums at load time (RobotType[name]).","Store enum .value when serializing configs."],"tags":["enum","type-validation","config","python"],"backgroundTag":"wrong-type-for-enum-field","analyzedSha":"1fe4fb980f6a12fe21c3c33d2b4da97a52c9154d","analyzedAt":"2026-08-28T13:23:33.733Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}