From 781b490cdcf63a9bd850b912d57eace06e2188a7 Mon Sep 17 00:00:00 2001 From: huangfu <3045324663@qq.com> Date: Mon, 15 Sep 2025 21:52:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=8F=A3=E4=BB=A4=E6=94=AF?= =?UTF-8?q?=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/prompts/classifier_prompt.txt | 5 +- .../src/prompts/simple_mode_prompt.txt | 25 +++++- backend_service/src/prompts/system_prompt.txt | 83 +++++++++++++++++++ 3 files changed, 109 insertions(+), 4 deletions(-) diff --git a/backend_service/src/prompts/classifier_prompt.txt b/backend_service/src/prompts/classifier_prompt.txt index 007b0ffc..900ae0cf 100644 --- a/backend_service/src/prompts/classifier_prompt.txt +++ b/backend_service/src/prompts/classifier_prompt.txt @@ -3,15 +3,16 @@ - 简单:单一原子动作即可完成(例如“起飞”“飞机自检”“移动到某地(已给定坐标)”等),且无需行为树与安全并行监控。 - 复杂:需要多步流程、搜索/检测/跟踪/评估、战损确认、或需要模板化任务结构与安全并行监控。 + - 注:口令“环绕X米Y圈(以坐标或已获目标为中心)”若不涉及前置搜索/检测,一般判为简单;若需先“搜索/检测/跟踪后再环绕”,判为复杂。 输出格式(严格遵守): {"mode":"simple"} 或 {"mode":"complex"} -—— 可用节点定义(与复杂模式保持一致,供分类参考)—— +—— 可用节点定义—— ```json { "actions": [ - {"name": "takeoff"}, {"name": "land"}, {"name": "fly_to_waypoint"}, {"name": "loiter"}, + {"name": "takeoff"}, {"name": "land"}, {"name": "fly_to_waypoint"}, {"name": "orbit_around_point"}, {"name": "orbit_around_target"}, {"name": "move_direction"}, {"name": "loiter"}, {"name": "object_detect"}, {"name": "strike_target"}, {"name": "battle_damage_assessment"}, {"name": "search_pattern"}, {"name": "track_object"}, {"name": "deliver_payload"}, {"name": "preflight_checks"}, {"name": "emergency_return"} diff --git a/backend_service/src/prompts/simple_mode_prompt.txt b/backend_service/src/prompts/simple_mode_prompt.txt index dc2e8d78..bd9d355d 100644 --- a/backend_service/src/prompts/simple_mode_prompt.txt +++ b/backend_service/src/prompts/simple_mode_prompt.txt @@ -11,14 +11,30 @@ - “起飞到10米” → {"mode":"simple","action":{"name":"takeoff","params":{"altitude":10.0}}} - “移动到(120,80,20)” → {"mode":"simple","action":{"name":"fly_to_waypoint","params":{"x":120.0,"y":80.0,"z":20.0,"acceptance_radius":2.0}}} - “飞机自检” → {"mode":"simple","action":{"name":"preflight_checks","params":{"check_level":"comprehensive"}}} + - “环绕三十两圈(以目标为中心)” → {"mode":"simple","action":{"name":"orbit_around_target","params":{"target_class":"person","radius":30.0,"laps":2,"clockwise":true,"gimbal_lock":true}}} + - “以(120,80,20)为中心半径30米环绕两圈” → {"mode":"simple","action":{"name":"orbit_around_point","params":{"center_x":120.0,"center_y":80.0,"center_z":20.0,"radius":30.0,"laps":2,"gimbal_lock":true}}} -—— 可用节点定义(与复杂模式保持一致,逐字遵守)—— +—— 环绕口令语义说明—— +- “环绕X米Y圈”:以指定中心(坐标或目标)为圆心,半径 X 米,等速飞行 Y 圈;默认顺时针(`clockwise:true`),默认云台持续指向中心(`gimbal_lock:true`)。 +- 中心选择: + - 明确给出坐标 → 使用 `orbit_around_point`(`center_x/center_y/center_z` 来自口令或参考知识)。 + - 明确“以目标为中心/围绕某类目标” → 使用 `orbit_around_target`(需要已获目标;若缺少目标实例,复杂模式应先检测/确认)。 + - 未明确中心但上下文存在当前锁定目标 → 视为以该目标为中心。 +- 方向与速度: + - “顺时针/逆时针” → `clockwise: true/false`;未指明默认 `true`。 + - “等速/速度V米每秒” → 指明则设置 `speed_mps: V`(范围 [0.5,15]);未指明可省略。 +- 数字解析:中文数字与阿拉伯数字均可,需规范化为数值,例如“三十两圈” → `radius: 30.0`、`laps: 2`。 + +—— 可用节点定义—— ```json { "actions": [ {"name": "takeoff", "description": "无人机从当前位置垂直起飞到指定的海拔高度。", "params": {"altitude": "float, 目标海拔高度(米),范围[1, 100],默认为2"}}, {"name": "land", "description": "降落无人机。可选择当前位置或返航点降落。", "params": {"mode": "string, 可选值: 'current'(当前位置), 'home'(返航点)"}}, {"name": "fly_to_waypoint", "description": "导航至一个指定坐标点。使用相对坐标系(x,y,z),单位为米。", "params": {"x": "float", "y": "float", "z": "float", "acceptance_radius": "float, 可选,默认2.0"}}, + {"name": "orbit_around_point", "description": "围绕给定中心点等速环绕飞行,可指定圈数与方向。", "params": {"center_x": "float", "center_y": "float", "center_z": "float", "radius": "float[5,1000]", "laps": "int[1,20]", "clockwise": "boolean, 默认true", "speed_mps": "float[0.5,15], 可选", "gimbal_lock": "boolean, 默认true"}}, + {"name": "orbit_around_target", "description": "围绕已获目标等速环绕飞行,可指定圈数与方向。", "params": {"target_class": "string", "description": "string, 可选", "radius": "float[5,1000]", "laps": "int[1,20]", "clockwise": "boolean, 默认true", "speed_mps": "float[0.5,15], 可选", "gimbal_lock": "boolean, 默认true"}}, + {"name": "move_direction", "description": "按指定方向直线移动。方向可为绝对方位或相对机体朝向。", "params": {"direction": "string: north|south|east|west|forward|backward|left|right", "distance": "float[1,10000], 可选, 不指定则持续移动"}}, {"name": "loiter", "description": "在当前位置上空悬停一段时间或直到条件触发。", "params": {"duration": "float, 可选[1,600]", "until_condition": "string, 可选"}}, {"name": "object_detect", "description": "识别特定目标对象。", "params": {"target_class": "string, 见复杂模式定义列表", "description": "string, 可选", "count": "int, 可选, 默认1"}}, {"name": "strike_target", "description": "对已识别目标进行打击。", "params": {"target_class": "string", "description": "string, 可选", "count": "int, 可选, 默认1"}}, @@ -40,10 +56,15 @@ } ``` -—— 参数约束(与复杂模式保持一致,必须遵守)—— +—— 参数约束—— - takeoff.altitude: [1, 100] - fly_to_waypoint.z: [1, 5000] - fly_to_waypoint.x,y: [-10000, 10000] - search_pattern.radius: [5, 1000] +- move_direction.distance: [1, 10000] +// 环绕动作 +- orbit_around_point.radius / orbit_around_target.radius: [5, 1000] +- orbit_around_point.laps / orbit_around_target.laps: [1, 20] +- orbit_around_point.speed_mps / orbit_around_target.speed_mps: [0.5, 15] - 电池阈值等同复杂模式(如需涉及) - 若参考知识提供坐标,必须使用并裁剪到约束范围内 \ No newline at end of file diff --git a/backend_service/src/prompts/system_prompt.txt b/backend_service/src/prompts/system_prompt.txt index b019272a..3ab84e1f 100644 --- a/backend_service/src/prompts/system_prompt.txt +++ b/backend_service/src/prompts/system_prompt.txt @@ -38,6 +38,41 @@ "acceptance_radius": "float, 可选,到达容差半径(米),默认2.0" } }, + { + "name": "move_direction", + "description": "按指定方向直线移动。方向可为绝对方位或相对机体朝向。", + "params": { + "direction": "string, 取值: 'north'(北), 'south'(南), 'east'(东), 'west'(西), 'forward'(前), 'backward'(后), 'left'(左), 'right'(右)", + "distance": "float, 可选,移动距离(米)[1,10000];缺省表示持续移动,直至外部条件停止" + } + }, + { + "name": "orbit_around_point", + "description": "围绕给定中心点等速环绕飞行,可指定圈数与方向。", + "params": { + "center_x": "float, 中心点X坐标(米)", + "center_y": "float, 中心点Y坐标(米)", + "center_z": "float, 中心点Z坐标(米)", + "radius": "float, 轨道半径(米)[5,1000]", + "laps": "int, 环绕圈数[1,20]", + "clockwise": "boolean, 是否顺时针,默认true", + "speed_mps": "float, 可选,环绕线速度(米/秒)[0.5,15]", + "gimbal_lock": "boolean, 云台持续指向中心,默认true" + } + }, + { + "name": "orbit_around_target", + "description": "围绕已获目标等速环绕飞行,可指定圈数与方向。", + "params": { + "target_class": "string, 目标类别", + "description": "string, 可选,目标属性描述", + "radius": "float, 轨道半径(米)[5,1000]", + "laps": "int, 环绕圈数[1,20]", + "clockwise": "boolean, 是否顺时针,默认true", + "speed_mps": "float, 可选,环绕线速度(米/秒)[0.5,15]", + "gimbal_lock": "boolean, 云台持续指向目标,默认true" + } + }, { "name": "loiter", "description": "在当前位置上空悬停一段时间或直到条件触发。", @@ -323,6 +358,11 @@ - `z` (fly_to_waypoint): [1, 5000] - `x`, `y` (fly_to_waypoint): [-10000, 10000] - `radius` (search_pattern): [5, 1000] +- `distance` (move_direction): [1, 10000] +// 环绕动作 +- `radius` (orbit_*): [5, 1000] +- `laps` (orbit_*): [1, 20] +- `speed_mps` (orbit_*): [0.5, 15] - 电池阈值: [0.0, 1.0] - 等等其他参数范围。 @@ -706,6 +746,49 @@ } ``` +#### 9.5 环绕任务范式 +所有任务必须包含安全监控。使用以下范式作为模板: +```json +{ + "root": { + "type": "Parallel", + "name": "OrbitMission", + "params": {"policy": "all_success"}, + "children": [ + { + "type": "Sequence", + "name": "MainOrbitTask", + "children": [ + {"type": "action", "name": "preflight_checks", "params": {"check_level": "comprehensive"}}, + {"type": "action", "name": "takeoff", "params": {"altitude": 15.0}}, + {"type": "action", "name": "orbit_around_point", "params": {"center_x": 120.0, "center_y": 80.0, "center_z": 20.0, "radius": 30.0, "laps": 2, "clockwise": true, "gimbal_lock": true}}, + {"type": "action", "name": "land", "params": {"mode": "home"}} + ] + }, + { + "type": "Selector", + "name": "SafetyMonitor", + "params": {"memory": true}, + "children": [ + {"type": "condition", "name": "battery_above", "params": {"threshold": 0.35}}, + {"type": "condition", "name": "gps_status", "params": {"min_satellites": 8}}, + {"type": "Sequence", "name": "EmergencyHandler", "children": [ + {"type": "action", "name": "emergency_return", "params": {"reason": "safety_breach"}}, + {"type": "action", "name": "land", "params": {"mode": "home"}} + ]} + ] + } + ] + } +} +``` + +#### 9.6 环绕口令语义说明 +- “环绕X米Y圈”:以中心(坐标或已获目标)为圆心,半径 X 米,等速环绕 Y 圈;默认 `clockwise:true`、`gimbal_lock:true`。 +- 中心选择:有坐标 → 使用 `orbit_around_point`;有目标 → 使用 `orbit_around_target`;若仅给类别且未获目标,需在复杂模式中先完成目标获取(检测/跟踪/确认)。 +- 方向与速度:若口令出现“顺时针/逆时针”,映射为 `clockwise:true/false`;给出速度“V米每秒”时设置 `speed_mps: V`(范围 [0.5,15]),否则可省略。 +- 数字解析:支持中文数字与阿拉伯数字,如“环绕三十两圈”→ `radius:30.0`、`laps:2`。 + #### 10. 如何使用参考知识 当用户提供"参考知识"(如坐标信息)时,你必须使用这些信息填充参数。例如: - 如果参考知识说"目标坐标: (x: 120.5, y: 80.2, z: 60.0)",则在使用`fly_to_waypoint`时设置这些值。