增加环绕侦察场景适配
This commit is contained in:
BIN
backend_service/src/__pycache__/__init__.cpython-312.pyc
Normal file
BIN
backend_service/src/__pycache__/__init__.cpython-312.pyc
Normal file
Binary file not shown.
Binary file not shown.
BIN
backend_service/src/__pycache__/main.cpython-312.pyc
Normal file
BIN
backend_service/src/__pycache__/main.cpython-312.pyc
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -11,11 +11,9 @@
|
||||
{"name":"fly_to_waypoint","params":{"x":"±10000","y":"±10000","z":"[1,5000]","acceptance_radius":"默认2.0"}},
|
||||
{"name":"move_direction","params":{"direction":"north/south/east/west/forward/backward/left/right","distance":"[1,10000],缺省持续移动","speed":"float,可选"}},
|
||||
{"name":"approach_target","params":{"target_class":"string,要趋近的目标类别","description":"string,可选,目标属性描述","stop_distance":"float,期望的最终停止距离","speed":"float,可选,期望的逼近速度"}},
|
||||
{"name":"rotate","params":{"angle":"float,旋转角度(正数逆时针,负数顺时针)","angular_velocity":"rad/s,旋转角速度"}},
|
||||
{"name":"rotate","params":{"angle":"float,无人机自身旋转角度(正数逆时针,负数顺时针)","angular_velocity":"rad/s,旋转角速度"}},
|
||||
{"name":"rotate_search","params":{"target_class":"string,要搜寻的目标类别","description":"string,可选,目标属性描述","step_angle":"float,可选,每一步旋转的角度","total_rotation":"float,可选,总共旋转搜索的角度"}},
|
||||
{"name":"manual_confirmation","params":{}},
|
||||
{"name":"orbit_around_point","params":{"center_x":"±10000","center_y":"±10000","center_z":"[1,5000]","radius":"[5,1000]","laps":"[1,20]","clockwise":"默认true","speed_mps":"[0.5,15]","gimbal_lock":"默认true"}},
|
||||
{"name":"orbit_around_target","params":{"target_class":"见object_detect列表","description":"可选,目标属性","radius":"[5,1000]","laps":"[1,20]","clockwise":"默认true","speed_mps":"[0.5,15]","gimbal_lock":"默认true"}},
|
||||
{"name":"loiter","params":{"duration":"[1,600]秒/until_condition:可选"}},
|
||||
{"name":"object_detect","params":{"target_class":"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","description":"可选,","count":"默认1"}},
|
||||
{"name":"strike_target","params":{"target_class":"同object_detect","description":"可选,目标属性","count":"默认1"}},
|
||||
@@ -71,7 +69,7 @@
|
||||
{"type":"action","name":"rotate_search","params":{"target_class":"person","description":"目标描述"}},
|
||||
{"type":"action","name":"object_detect","params":{"target_class":"person","description":"目标描述"}},
|
||||
// -------------------------------
|
||||
{"type":"action","name":"land","params":{"mode":"home"}}
|
||||
// 默认不需要降落节点,除非用户明确要求
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -105,8 +103,7 @@
|
||||
},
|
||||
{"type":"action","name":"loiter","params":{"duration":5.0}} // 未发现时的备选动作
|
||||
]
|
||||
},
|
||||
{"type":"action","name":"land","params":{"mode":"home"}}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -141,6 +138,134 @@
|
||||
}
|
||||
```
|
||||
|
||||
#### 场景 3:环绕侦察类任务
|
||||
**指令**:“去面前的大楼三层/12米高,绕着外围看有没有打开的窗户,发现则进行拍照。”
|
||||
**参考知识**:{"text": "面前的大楼外围四个点坐标:A(-24.00, 241.80),B(-108.50, 241.80),C(-108.50, 289.80),D(-24.00, 292.80)。"}
|
||||
**结构**:Sequence (按顺序执行)
|
||||
```json
|
||||
{
|
||||
"root": {
|
||||
"type": "Sequence",
|
||||
"name": "SurroundAndInspect",
|
||||
"children": [
|
||||
{"type":"action","name":"takeoff","params":{"altitude":12.0}},
|
||||
// 移动到A点,并在此过程中持续检测
|
||||
{
|
||||
"type": "Parallel",
|
||||
"name": "FlyAndInspectToA",
|
||||
"children": [
|
||||
{"type":"action","name":"fly_to_waypoint","params":{"x":-24.0,"y":241.8,"z":12.0}},
|
||||
{
|
||||
"type": "Selector",
|
||||
"name": "OpportunisticPhoto",
|
||||
"children": [
|
||||
{
|
||||
"type": "decorator",
|
||||
"name": "SuccessIsFailure",
|
||||
"child": {
|
||||
"type": "Sequence",
|
||||
"name": "DetectAndCapture",
|
||||
"children": [
|
||||
{"type":"action","name":"object_detect","params":{"target_class":"window","description":"open window"}},
|
||||
{"type":"condition","name":"object_detected","params":{"target_class":"window","description":"open window"}},
|
||||
{"type":"action","name":"take_photos","params":{"target_class":"window","description":"open window","track_time":5.0}}
|
||||
]
|
||||
}
|
||||
},
|
||||
{"type":"action","name":"loiter","params":{"duration":0.1}} // 占位动作
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
// 移动到B点...
|
||||
{
|
||||
"type": "Parallel",
|
||||
"name": "FlyAndInspectToB",
|
||||
"children": [
|
||||
{"type":"action","name":"fly_to_waypoint","params":{"x":-108.5,"y":241.8,"z":12.0}},
|
||||
{
|
||||
"type": "Selector",
|
||||
"name": "OpportunisticPhoto",
|
||||
"children": [
|
||||
{
|
||||
"type": "decorator",
|
||||
"name": "SuccessIsFailure",
|
||||
"child": {
|
||||
"type": "Sequence",
|
||||
"name": "DetectAndCapture",
|
||||
"children": [
|
||||
{"type":"action","name":"object_detect","params":{"target_class":"window","description":"open window"}},
|
||||
{"type":"condition","name":"object_detected","params":{"target_class":"window","description":"open window"}},
|
||||
{"type":"action","name":"take_photos","params":{"target_class":"window","description":"open window","track_time":5.0}}
|
||||
]
|
||||
}
|
||||
},
|
||||
{"type":"action","name":"loiter","params":{"duration":0.1}}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
// 移动到C点...
|
||||
{
|
||||
"type": "Parallel",
|
||||
"name": "FlyAndInspectToC",
|
||||
"children": [
|
||||
{"type":"action","name":"fly_to_waypoint","params":{"x":-108.5,"y":289.8,"z":12.0}},
|
||||
{
|
||||
"type": "Selector",
|
||||
"name": "OpportunisticPhoto",
|
||||
"children": [
|
||||
{
|
||||
"type": "decorator",
|
||||
"name": "SuccessIsFailure",
|
||||
"child": {
|
||||
"type": "Sequence",
|
||||
"name": "DetectAndCapture",
|
||||
"children": [
|
||||
{"type":"action","name":"object_detect","params":{"target_class":"window","description":"open window"}},
|
||||
{"type":"condition","name":"object_detected","params":{"target_class":"window","description":"open window"}},
|
||||
{"type":"action","name":"take_photos","params":{"target_class":"window","description":"open window","track_time":5.0}}
|
||||
]
|
||||
}
|
||||
},
|
||||
{"type":"action","name":"loiter","params":{"duration":0.1}}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
// 移动到D点...
|
||||
{
|
||||
"type": "Parallel",
|
||||
"name": "FlyAndInspectToD",
|
||||
"children": [
|
||||
{"type":"action","name":"fly_to_waypoint","params":{"x":-24.0,"y":292.8,"z":12.0}},
|
||||
{
|
||||
"type": "Selector",
|
||||
"name": "OpportunisticPhoto",
|
||||
"children": [
|
||||
{
|
||||
"type": "decorator",
|
||||
"name": "SuccessIsFailure",
|
||||
"child": {
|
||||
"type": "Sequence",
|
||||
"name": "DetectAndCapture",
|
||||
"children": [
|
||||
{"type":"action","name":"object_detect","params":{"target_class":"window","description":"open window"}},
|
||||
{"type":"condition","name":"object_detected","params":{"target_class":"window","description":"open window"}},
|
||||
{"type":"action","name":"take_photos","params":{"target_class":"window","description":"open window","track_time":5.0}}
|
||||
]
|
||||
}
|
||||
},
|
||||
{"type":"action","name":"loiter","params":{"duration":0.1}}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 五、优先级排序任务通用示例
|
||||
当用户指令中明确提出有多个待考察且具有优先级关系的物体时,节点描述须为优先级关系。
|
||||
| 用户指令场景 | `target_class` | `description` |
|
||||
@@ -154,7 +279,8 @@
|
||||
3. `gps_status`的`min_satellites`必须在6-15之间;
|
||||
4. 严禁输出 markdown 代码块标记,直接输出 JSON 纯文本;
|
||||
5. 控制流节点的 `type` 必须是 `"Sequence"`, `"Selector"` 或 `"Parallel"`;
|
||||
6. 当用户指令中要求执行动作前增加人工确认时,比如“我确认后拍照”,则必须在拍照动作前增加manual_confirmation节点
|
||||
6. rotate与rotate_search动作节点意思是无人机以自身为原点旋转,而非围绕外部点旋转
|
||||
7. 当用户指令中要求执行动作前增加人工确认时,比如“我确认后拍照”,则必须在拍照动作前增加manual_confirmation节点
|
||||
|
||||
## 七、输出要求
|
||||
仅输出1个严格符合上述所有规则的JSON对象。
|
||||
|
||||
@@ -485,6 +485,11 @@ def _add_nodes_and_edges(node: dict, dot, parent_id: str | None = None) -> str:
|
||||
|
||||
# 递归处理子节点 (Sequence, Selector, Parallel 等)
|
||||
children = node.get("children", [])
|
||||
|
||||
# 兼容 decorator 类型的 child 字段 (处理为单元素列表以便统一逻辑)
|
||||
if node_type == 'decorator' and 'child' in node:
|
||||
children = [node['child']]
|
||||
|
||||
if children:
|
||||
# 记录所有子节点的ID
|
||||
child_ids = []
|
||||
@@ -501,10 +506,10 @@ def _add_nodes_and_edges(node: dict, dot, parent_id: str | None = None) -> str:
|
||||
for cid in child_ids:
|
||||
s.node(cid)
|
||||
|
||||
# 递归处理单子节点 (Decorator)
|
||||
child = node.get("child")
|
||||
if child:
|
||||
_add_nodes_and_edges(child, dot, current_id)
|
||||
# 递归处理单子节点 (Decorator) - 已合并到 children 处理逻辑中,此处删除旧逻辑
|
||||
# child = node.get("child")
|
||||
# if child:
|
||||
# _add_nodes_and_edges(child, dot, current_id)
|
||||
|
||||
return current_id
|
||||
|
||||
|
||||
Reference in New Issue
Block a user