From f7a096c6a7c6c53543c140c3b973b1a4c872ea01 Mon Sep 17 00:00:00 2001 From: nicoboy Date: Mon, 1 Jun 2026 14:46:28 +0200 Subject: [PATCH] Fix langue et altitude relative dans SYSTEM_PROMPT MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Ajout instruction explicite : message toujours en français - Nouveau champ delta dans le schéma JSON : "monte de 5m" → delta=5, "descend de 3m" → delta=-3, null pour altitude absolue - takeoff et altitude calculent target_alt = current_alt + delta quand delta est présent, sinon utilisent altitude absolue Co-Authored-By: Claude Sonnet 4.6 --- wireclaw_core.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/wireclaw_core.py b/wireclaw_core.py index 7d62fa7..abafb63 100644 --- a/wireclaw_core.py +++ b/wireclaw_core.py @@ -14,15 +14,17 @@ client = genai.Client(api_key=GEMINI_API_KEY) SYSTEM_PROMPT = f"""Tu es WireClaw, cerveau d'un drone d'inspection autonome. Reponds UNIQUEMENT avec un objet JSON valide, sans markdown. +Le champ "message" est TOUJOURS en francais. Format : {{ "action": "takeoff|land|rtl|hover|goto|orbit|status|position|altitude|position_gps", - "altitude": , + "altitude": , + "delta": , "lat": , "lon": , "radius": , "speed": , - "message": "" + "message": "" }} Position de base : lat={BASE_LAT}, lon={BASE_LON}. Pour goto, calcule des coordonnees proches (max 500m en test). @@ -114,16 +116,17 @@ async def execute_command(drone, cmd): elif action == "takeoff": await refresh_position(drone) + delta = cmd.get("delta") + target_alt = current_pos["alt"] + float(delta) if delta is not None else alt if current_pos["alt"] >= 2.0: - # Déjà en vol : changer l'altitude en conservant la position - new_abs_alt = current_pos["abs_alt"] - current_pos["alt"] + alt + new_abs_alt = current_pos["abs_alt"] - current_pos["alt"] + target_alt await drone.action.goto_location( current_pos["lat"], current_pos["lon"], new_abs_alt, float('nan') ) await asyncio.sleep(6) await refresh_position(drone) return f"OK {msg} — altitude {current_pos['alt']:.1f}m" - await drone.action.set_takeoff_altitude(alt) + await drone.action.set_takeoff_altitude(target_alt) await drone.action.arm() await drone.action.takeoff() await asyncio.sleep(8) @@ -193,20 +196,22 @@ async def execute_command(drone, cmd): elif action == "altitude": await refresh_position(drone) + delta = cmd.get("delta") + target_alt = current_pos["alt"] + float(delta) if delta is not None else alt if current_pos["alt"] < 2.0: - await drone.action.set_takeoff_altitude(alt) + await drone.action.set_takeoff_altitude(target_alt) await drone.action.arm() await drone.action.takeoff() await asyncio.sleep(8) await refresh_position(drone) return f"OK {msg} — altitude {current_pos['alt']:.1f}m" - new_abs_alt = current_pos["abs_alt"] - current_pos["alt"] + alt + new_abs_alt = current_pos["abs_alt"] - current_pos["alt"] + target_alt await drone.action.goto_location( current_pos["lat"], current_pos["lon"], new_abs_alt, float('nan') ) await asyncio.sleep(6) await refresh_position(drone) - return f"OK {msg} — altitude {current_pos['alt']:.1f}m (cible {alt}m)" + return f"OK {msg} — altitude {current_pos['alt']:.1f}m (cible {target_alt:.1f}m)" elif action == "position_gps": import datetime