提示词分段编排解耦
This commit is contained in:
208
backend_service/src/prompts/partials/scene4_examples.txt
Normal file
208
backend_service/src/prompts/partials/scene4_examples.txt
Normal file
@@ -0,0 +1,208 @@
|
||||
## 四、场景示例(请灵活参考)
|
||||
|
||||
#### 场景 1:线性搜索任务(Sequence + Selector)
|
||||
**指令**:“无人机当前在地面,去研究所正大门,搜索扎辫子女子,找到后拍照。”
|
||||
**思路**:无人机在地面,则需要先自检然后起飞;获取研究所正大门坐标,调用fly_to_waypoint节点到达该地;然后调用rotate_search节点搜索目标女子,再使用object_detected条件节点,这样就可以作为take_photos节点的依据。
|
||||
**结构**:Sequence (按顺序执行)
|
||||
```json
|
||||
{
|
||||
"root": {
|
||||
"type": "Sequence",
|
||||
"name": "MainSearchTask",
|
||||
"children": [
|
||||
{"type":"action","name":"takeoff","params":{"altitude":10.0}},
|
||||
{"type":"action","name":"fly_to_waypoint","params":{"x":100.0,"y":50.0,"z":10.0}},
|
||||
{"type":"action","name":"rotate_search","params":{"target_class":"person","description":"扎辫子女子"}},
|
||||
{
|
||||
"type": "Selector",
|
||||
"name": "CheckAndPhoto",
|
||||
"children": [
|
||||
{
|
||||
"type": "Sequence",
|
||||
"name": "PhotoIfFound",
|
||||
"children": [
|
||||
{"type":"condition","name":"object_detected","params":{"target_class":"person","description":"扎辫子女子"}},
|
||||
{"type":"action","name":"take_photos","params":{"target_class":"person","description":"扎辫子女子","track_time":10.0}}
|
||||
]
|
||||
},
|
||||
{"type":"action","name":"loiter","params":{"duration":5.0}} // 未发现时的备选动作
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### 场景 2:带中断逻辑的巡逻(Selector 示例)
|
||||
**指令**:“无人机当前在地面,飞往航点A。如果途中发现可疑人员,则悬停。”
|
||||
**参考知识**:航点A的坐标(x:100.0,y:50.0)
|
||||
**思路**:无人机在地面,则需要先自检然后起飞;获取航点A的坐标,调用fly_to_waypoint节点到达该地;但同时需要注意看到可疑人员需要悬停,意味着一边进行识别,识别到进行悬停,因此要在object_detect节点后有一个object_detected条件节点,作为悬停的条件。
|
||||
**结构**:
|
||||
```json
|
||||
{
|
||||
"root": {
|
||||
"type": "Sequence",
|
||||
"children": [
|
||||
{"type":"action","name":"system_checks","params":{"check_level":"basic"}},
|
||||
{"type":"action","name":"takeoff","params":{"altitude":10.0}},
|
||||
{
|
||||
"type": "Selector",
|
||||
"name": "FlyOrDetect",
|
||||
"children": [
|
||||
{
|
||||
"type": "Sequence",
|
||||
"name": "InterruptionLogic",
|
||||
"children": [
|
||||
{"type":"action","name":"object_detect","params":{"target_class":"person"}},
|
||||
{"type":"condition","name":"object_detected","params":{"target_class":"person"}},
|
||||
{"type":"action","name":"loiter","params":{"duration":5.0}}
|
||||
]
|
||||
},
|
||||
{"type":"action","name":"fly_to_waypoint","params":{"x":100.0,"y":50.0,"z":10.0}}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### 场景 3:长期监控任务(Parallel 示例)
|
||||
**指令**:“无人机当前在空中,往广场西边飞200米,持续监控5分钟,发现人就拍照告诉我,到时间可以返航。”
|
||||
**参考知识**:广场西边200米的坐标(x:50.0,y:50.0,z:10.0)
|
||||
**思路**:无人机在空中,直接前往目标点;到达后需要并行执行两件事:1. 倒计时5分钟(主控时间);2. 持续检测人并拍照(从属任务)。
|
||||
使用`Parallel`节点并设置策略为`success_on_one`,这样当倒计时(loiter)结束返回成功时,整个并行节点就会成功结束,从而强制停止拍照循环。为了让拍照循环不提前结束Parallel,拍照分支使用`decorator`(SuccessIsFailure)或无限重试逻辑。
|
||||
**结构**:
|
||||
```json
|
||||
{
|
||||
"root": {
|
||||
"type": "Sequence",
|
||||
"name": "MainTask",
|
||||
"children": [
|
||||
{
|
||||
"type": "action",
|
||||
"name": "fly_to_waypoint",
|
||||
"params": {
|
||||
"x": 50.0,
|
||||
"y": 50.0,
|
||||
"z": 10.0
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Parallel",
|
||||
"name": "MonitorAndPhoto",
|
||||
"params": {
|
||||
"policy": "success_on_one"
|
||||
},
|
||||
"children": [
|
||||
{
|
||||
"type": "action",
|
||||
"name": "loiter",
|
||||
"params": {
|
||||
"time": 300
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "decorator",
|
||||
"name": "SuccessIsFailure",
|
||||
"child": {
|
||||
"type": "Sequence",
|
||||
"name": "CheckAndPhoto",
|
||||
"children": [
|
||||
{
|
||||
"type": "action",
|
||||
"name": "object_detect",
|
||||
"params": {
|
||||
"target_class": "person"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "condition",
|
||||
"name": "object_detected",
|
||||
"params": {
|
||||
"target_class": "person"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "action",
|
||||
"name": "take_photos",
|
||||
"params": {
|
||||
"target_class": "person"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "action",
|
||||
"name": "return_emergency",
|
||||
"params": {
|
||||
"reason": "任务完成"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### 场景 4:交互式确认任务(Sequence + Manual Confirmation)
|
||||
**指令**:“无人机当前在空中,搜索小汽车,搜索到了我确认后再决定要不要拍照。”
|
||||
**思路**:无人机已在空中,无需起飞,直接进行搜索。首先使用`rotate_search`主动搜索目标,配合`object_detected`条件节点确认目标是否被检测到。检测到后,执行`manual_confirmation`节点等待用户确认。只有用户确认通过(返回Success),才会继续执行后续的`take_photos`动作。
|
||||
**结构**:Sequence
|
||||
```json
|
||||
{
|
||||
"root": {
|
||||
"type": "Sequence",
|
||||
"name": "SearchConfirmPhoto",
|
||||
"children": [
|
||||
{"type":"action","name":"rotate_search","params":{"target_class":"car","description":"小汽车"}},
|
||||
{"type":"condition","name":"object_detected","params":{"target_class":"car","description":"小汽车"}},
|
||||
{"type":"action","name":"manual_confirmation","params":{}},
|
||||
{"type":"action","name":"take_photos","params":{"target_class":"car","description":"小汽车"}}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### 场景 5:后置确认任务(Sequence + Manual Confirmation)
|
||||
**指令**:“无人机当前在地面,搜索小汽车,搜索到了拍张照,我确认后再决定要不要返航”
|
||||
**思路**:无人机在地面,需起飞。搜索小汽车(`rotate_search` + `object_detected`)。搜索到后,先执行拍照(`take_photos`)。之后执行人工确认(`manual_confirmation`),确认通过后才执行返航(`return_emergency`)。
|
||||
**结构**:Sequence
|
||||
```json
|
||||
{
|
||||
"root": {
|
||||
"type": "Sequence",
|
||||
"name": "SearchPhotoConfirmReturn",
|
||||
"children": [
|
||||
{"type":"action","name":"system_checks","params":{"check_level":"comprehensive"}},
|
||||
{"type":"action","name":"takeoff","params":{"altitude":10.0}},
|
||||
{"type":"action","name":"rotate_search","params":{"target_class":"car","description":"小汽车"}},
|
||||
{"type":"condition","name":"object_detected","params":{"target_class":"car","description":"小汽车"}},
|
||||
{"type":"action","name":"take_photos","params":{"target_class":"car","description":"小汽车"}},
|
||||
{"type":"action","name":"manual_confirmation","params":{}},
|
||||
{"type":"action","name":"return_emergency","params":{"reason":"确认后返航"}}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### 场景 6:移动后条件降落(Sequence)
|
||||
**指令**:“无人机当前在空中,紧急回到广场,看见了红绿灯之后直接降落。”
|
||||
**参考知识**:广场坐标(x:0.0, y:0.0, z:10.0)
|
||||
**思路**:无人机在空中,无需起飞。首先飞往广场(`fly_to_waypoint`),严禁使用`return_emergency`。到达后,为了满足“看见红绿灯”的条件,必须先执行主动搜索(`rotate_search`)。一旦检测到红绿灯(`object_detected`),即执行降落(`land`)。
|
||||
**结构**:Sequence
|
||||
```json
|
||||
{
|
||||
"root": {
|
||||
"type": "Sequence",
|
||||
"name": "FlySearchLand",
|
||||
"children": [
|
||||
{"type":"action","name":"fly_to_waypoint","params":{"x":0.0,"y":0.0,"z":10.0}},
|
||||
{"type":"action","name":"rotate_search","params":{"target_class":"traffic_light","description":"红绿灯"}},
|
||||
{"type":"condition","name":"object_detected","params":{"target_class":"traffic_light","description":"红绿灯"}},
|
||||
{"type":"action","name":"land","params":{"mode":"current"}}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user