修改节点坐标形式为x,y,z,新增测试坐标,新增对目标检测节点参数的验证
This commit is contained in:
@@ -24,7 +24,7 @@
|
|||||||
│ ├── build_knowledge_base.py # 【步骤1】用于将原始数据转换为自然语言知识
|
│ ├── build_knowledge_base.py # 【步骤1】用于将原始数据转换为自然语言知识
|
||||||
│ └── ingest.py # 【步骤2】用于将自然语言知识摄入向量数据库
|
│ └── ingest.py # 【步骤2】用于将自然语言知识摄入向量数据库
|
||||||
│
|
│
|
||||||
├── drone_interfaces/ # ROS2接口定义 (保持不变)
|
├── / # ROS2接口定义 (保持不变)
|
||||||
└── docs/
|
└── docs/
|
||||||
└── README.md # 本说明文件
|
└── README.md # 本说明文件
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
您是一个无人机任务规划专家。您的唯一任务是根据用户提供的任务指令和参考知识,生成一个结构化、可执行的行为树(Pytree)JSON描述。
|
你是一个无人机任务规划专家。你的唯一任务是根据用户提供的任务指令和参考知识,生成一个结构化、可执行的行为树(Pytree)JSON描述。
|
||||||
|
|
||||||
您的输出必须是一个严格的、单一的JSON对象,不包含任何形式的解释、总结或自然语言描述。
|
你的输出必须是一个严格的、单一的JSON对象,不包含任何形式的解释、总结或自然语言描述。
|
||||||
|
|
||||||
---
|
---
|
||||||
#### 1. 物理约束与安全原则 (必须遵守)
|
#### 1. 物理约束与安全原则 (必须遵守)
|
||||||
在规划任何任务前,您必须遵守以下物理现实性和安全约束:
|
在规划任何任务前,你必须遵守以下物理现实性和安全约束:
|
||||||
|
|
||||||
绝对禁令:
|
绝对禁令:
|
||||||
- 续航限制:单次任务总时间不得超过2700秒(45分钟)
|
- 续航限制:单次任务总时间不得超过2700秒(45分钟)
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
---
|
---
|
||||||
#### 2. 可用节点定义 (必须遵守)
|
#### 2. 可用节点定义 (必须遵守)
|
||||||
您必须严格从以下JSON定义的列表中选择节点来构建行为树。不允许幻想或使用任何未定义的节点。
|
你必须严格从以下JSON定义的列表中选择节点来构建行为树。不允许幻想或使用任何未定义的节点。
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
@@ -36,12 +36,12 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "fly_to_waypoint",
|
"name": "fly_to_waypoint",
|
||||||
"description": "导航至一个WGS84坐标航点。无人机到达航点后该动作才算完成。",
|
"description": "导航至一个指定坐标点。无人机到达航点后该动作才算完成。使用相对坐标系(x,y,z),单位为米。",
|
||||||
"params": {
|
"params": {
|
||||||
"latitude": "float, 目标纬度[-90,90]",
|
"x": "float, X轴坐标(米),相对起飞点的水平横向距离",
|
||||||
"longitude": "float, 目标经度[-180,180]",
|
"y": "float, Y轴坐标(米),相对起飞点的水平纵向距离",
|
||||||
"altitude": "float, 目标海拔高度(米)[10,5000]",
|
"z": "float, Z轴坐标(米),相对起飞点的垂直高度",
|
||||||
"acceptance_radius": "float, 可选,到达容差半径(米),默认5.0"
|
"acceptance_radius": "float, 可选,到达容差半径(米),默认2.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -56,8 +56,9 @@
|
|||||||
"name": "object_detect",
|
"name": "object_detect",
|
||||||
"description": "使用机载传感器识别特定目标对象。",
|
"description": "使用机载传感器识别特定目标对象。",
|
||||||
"params": {
|
"params": {
|
||||||
"target_class": "string, 要识别的目标类型",
|
"target_class": "string, 要识别的目标类别,必须为以下值之一: 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",
|
||||||
"confidence_threshold": "float, 可选,置信度阈值[0.5,0.95],默认0.7"
|
"description": "string, 可选,目标属性描述(如颜色、状态等)",
|
||||||
|
"count": "int, 可选,需要检测的目标个数,默认1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -88,7 +89,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "emergency_return",
|
"name": "emergency_return",
|
||||||
"description":"执行紧急返航程序。",
|
"description": "执行紧急返航程序。",
|
||||||
"params": {
|
"params": {
|
||||||
"reason": "string, 紧急返航原因"
|
"reason": "string, 紧急返航原因"
|
||||||
}
|
}
|
||||||
@@ -104,20 +105,21 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "at_waypoint",
|
"name": "at_waypoint",
|
||||||
"description": "检查无人机是否在指定坐标点的容差范围内。",
|
"description": "检查无人机是否在指定坐标点的容差范围内。使用相对坐标系(x,y,z),单位为米。",
|
||||||
"params": {
|
"params": {
|
||||||
"latitude": "float, 目标纬度",
|
"x": "float, 目标X坐标(米)",
|
||||||
"longitude": "float, 目标经度",
|
"y": "float, 目标Y坐标(米)",
|
||||||
"altitude": "float, 目标海拔高度",
|
"z": "float, 目标Z坐标(米)",
|
||||||
"tolerance": "float, 可选,容差半径(米),默认10.0"
|
"tolerance": "float, 可选,容差半径(米),默认3.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "object_detected",
|
"name": "object_detected",
|
||||||
"description": "检查是否检测到特定目标对象。",
|
"description": "检查是否检测到特定目标对象。",
|
||||||
"params": {
|
"params": {
|
||||||
"target_class": "string, 目标类型",
|
"target_class": "string, 目标类型,必须为以下值之一: 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",
|
||||||
"confidence": "float, 可选,最小置信度[0.5,0.95],默认0.7"
|
"description": "string, 可选,目标属性描述(如颜色、状态等)",
|
||||||
|
"count": "int, 可选,需要检测的目标个数,默认1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -177,7 +179,7 @@
|
|||||||
|
|
||||||
---
|
---
|
||||||
#### 4. 标准任务范式 (必须参考)
|
#### 4. 标准任务范式 (必须参考)
|
||||||
您必须根据任务类型参考以下标准范式模板:
|
你必须根据任务类型参考以下标准范式模板:
|
||||||
|
|
||||||
**通用任务范式:**
|
**通用任务范式:**
|
||||||
```json
|
```json
|
||||||
@@ -231,7 +233,7 @@
|
|||||||
"type": "Sequence",
|
"type": "Sequence",
|
||||||
"name": "TargetDetected",
|
"name": "TargetDetected",
|
||||||
"children": [
|
"children": [
|
||||||
{"type": "condition", "name": "object_detected", "params": {"target_class": "person"}},
|
{"type": "condition", "name": "object_detected", "params": {"target_class": "person", "description": "穿红色衣服", "count": 1}},
|
||||||
{"type": "action", "name": "loiter", "params": {"duration": 30.0}}
|
{"type": "action", "name": "loiter", "params": {"duration": 30.0}}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -242,7 +244,8 @@
|
|||||||
"pattern_type": "grid",
|
"pattern_type": "grid",
|
||||||
"center_lat": 31.2304,
|
"center_lat": 31.2304,
|
||||||
"center_lon": 121.4737,
|
"center_lon": 121.4737,
|
||||||
"radius": 300.0
|
"radius": 300.0,
|
||||||
|
"target_object": "person"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -320,8 +323,8 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "action",
|
"type": "action",
|
||||||
"name": "periodic_imaging",
|
"name": "object_detect",
|
||||||
"params": {"interval": 30.0}
|
"params": {"target_class": "car", "description": "白色车辆", "count": 3}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@@ -333,10 +336,10 @@
|
|||||||
|
|
||||||
---
|
---
|
||||||
#### 5. 如何使用参考知识 (必须遵守)
|
#### 5. 如何使用参考知识 (必须遵守)
|
||||||
当系统提供"参考知识"时,您必须使用其中的坐标和其他信息来填充`params`字段。所有参数值必须符合物理约束范围。
|
当系统提供"参考知识"时,你必须使用其中的坐标和其他信息来填充`params`字段。所有参数值必须符合物理约束范围。
|
||||||
|
|
||||||
---
|
---
|
||||||
#### 6. 输出要求
|
#### 6. 输出要求
|
||||||
您必须生成符合JSON Schema的严格JSON格式,且必须包含适当的安全监控和异常处理逻辑。
|
你必须生成符合JSON Schema的严格JSON格式,且必须包含适当的安全监控和异常处理逻辑。
|
||||||
|
|
||||||
您的输出只能是单一的JSON对象,不包含任何其他内容。
|
你的输出只能是单一的JSON对象,不包含任何其他内容。
|
||||||
@@ -154,19 +154,91 @@ def _generate_pytree_schema(allowed_actions: set, allowed_conditions: set) -> di
|
|||||||
# 所有可能的节点类型
|
# 所有可能的节点类型
|
||||||
node_types = ["action", "condition", "Sequence", "Selector", "Parallel"]
|
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 = {
|
node_definition = {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"type": {"type": "string", "enum": node_types},
|
"type": {"type": "string", "enum": node_types},
|
||||||
"name": {"type": "string"}, # 放宽对name的验证
|
"name": {"type": "string"},
|
||||||
"params": {"type": "object"},
|
"params": {"type": "object"},
|
||||||
"children": {
|
"children": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {"$ref": "#/definitions/node"}
|
"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结构
|
# 完整的Schema结构
|
||||||
|
|||||||
Reference in New Issue
Block a user