add changes from all tracke

This commit is contained in:
莲子心
2026-01-24 22:34:58 +08:00
parent 9cb4537528
commit e23371182e
2 changed files with 28 additions and 2 deletions

View File

@@ -15,6 +15,6 @@ REMINDER - Action Input must be valid JSON:
- For multiple parameters: {{"drone_id": "drone-001", "altitude": 15.0}}
- Numbers WITHOUT quotes, strings WITH quotes
- We put your answer to langchain, so if you want to return {{ or }}, return double of the characters.
- When the task is done, simply output "Final Answer:\n[TASK DONE]"
- When the task is done, IMMEDIATELY output ONLY "Final Answer:\n[TASK DONE]" and nothing else after that.
Please try again with proper JSON format."""

View File

@@ -1725,10 +1725,36 @@ def create_uav_tools(client: UAVAPIClient) -> list:
return "Error: Target area is too small or invalid geometry found."
# 3.4 执行探索
# 初始化覆盖率为0防止在没有执行任何移动时变量未定义
current_coverage = 0.0
first_warning = 0
for idx, wp in enumerate(final_path):
if idx < tool_states.explored_count:
continue
# 检查无人机电池电量
drone_status = client.get_drone_status(drone_id)
battery_level = drone_status.get('battery_level', 100.0)
# 如果电量低于30%,则前往最近的充电站
if battery_level < 30.0:
# 查找最近的充电站
try:
waypoints = client.get_all_waypoints()
charging_stations = [wp for wp in waypoints if wp.get('charge_amount', 0) > 0]
if charging_stations:
#返回后交给充电工具处理, 充电完成后会再继续执行
return f" {drone_id} is low on battery ({battery_level:.1f}%)! Please charge at the nearest station. Then continue auto exploring."
else:
if first_warning == 0:
print("Warning: Low battery but no charging stations found!")
first_warning = 1
except Exception as e:
print(f"Error during charging process: {str(e)}")
# 移动无人机
client.move_to(drone_id, wp['x'], wp['y'], current_z)