修改节点坐标形式为x,y,z,新增测试坐标,新增对目标检测节点参数的验证
This commit is contained in:
@@ -154,19 +154,91 @@ def _generate_pytree_schema(allowed_actions: set, allowed_conditions: set) -> di
|
||||
# 所有可能的节点类型
|
||||
node_types = ["action", "condition", "Sequence", "Selector", "Parallel"]
|
||||
|
||||
# 目标检测相关的类别枚举
|
||||
target_classes = [
|
||||
"person", "bicycle", "car", "motorcycle", "airplane", "bus", "train", "truck", "boat",
|
||||
"traffic_light", "fire_hydrant", "stop_sign", "parking_meter", "bench", "bird", "cat",
|
||||
"dog", "horse", "sheep", "cow", "elephant", "bear", "zebra", "giraffe", "backpack",
|
||||
"umbrella", "handbag", "tie", "suitcase", "frisbee", "skis", "snowboard", "sports_ball",
|
||||
"kite", "baseball_bat", "baseball_glove", "skateboard", "surfboard", "tennis_racket",
|
||||
"bottle", "wine_glass", "cup", "fork", "knife", "spoon", "bowl", "banana", "apple",
|
||||
"sandwich", "orange", "broccoli", "carrot", "hot_dog", "pizza", "donut", "cake", "chair",
|
||||
"couch", "potted_plant", "bed", "dining_table", "toilet", "tv", "laptop", "mouse", "remote",
|
||||
"keyboard", "cell_phone", "microwave", "oven", "toaster", "sink", "refrigerator", "book",
|
||||
"clock", "vase", "scissors", "teddy_bear", "hair_drier", "toothbrush"
|
||||
]
|
||||
|
||||
# 递归节点定义
|
||||
node_definition = {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"type": {"type": "string", "enum": node_types},
|
||||
"name": {"type": "string"}, # 放宽对name的验证
|
||||
"name": {"type": "string"},
|
||||
"params": {"type": "object"},
|
||||
"children": {
|
||||
"type": "array",
|
||||
"items": {"$ref": "#/definitions/node"}
|
||||
}
|
||||
},
|
||||
"required": ["type", "name"]
|
||||
"required": ["type", "name"],
|
||||
"allOf": [
|
||||
# 动作节点验证
|
||||
{
|
||||
"if": {"properties": {"type": {"const": "action"}}},
|
||||
"then": {"properties": {"name": {"enum": sorted(list(allowed_actions))}}}
|
||||
},
|
||||
# 条件节点验证
|
||||
{
|
||||
"if": {"properties": {"type": {"const": "condition"}}},
|
||||
"then": {"properties": {"name": {"enum": sorted(list(allowed_conditions))}}}
|
||||
},
|
||||
# 目标检测动作节点的参数验证
|
||||
{
|
||||
"if": {
|
||||
"properties": {
|
||||
"type": {"const": "action"},
|
||||
"name": {"const": "object_detect"}
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"properties": {
|
||||
"params": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"target_class": {"type": "string", "enum": target_classes},
|
||||
"description": {"type": "string"},
|
||||
"count": {"type": "integer", "minimum": 1}
|
||||
},
|
||||
"required": ["target_class"],
|
||||
"additionalProperties": False
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
# 目标检测条件节点的参数验证
|
||||
{
|
||||
"if": {
|
||||
"properties": {
|
||||
"type": {"const": "condition"},
|
||||
"name": {"const": "object_detected"}
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"properties": {
|
||||
"params": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"target_class": {"type": "string", "enum": target_classes},
|
||||
"description": {"type": "string"},
|
||||
"count": {"type": "integer", "minimum": 1}
|
||||
},
|
||||
"required": ["target_class"],
|
||||
"additionalProperties": False
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
# 完整的Schema结构
|
||||
|
||||
Reference in New Issue
Block a user