Fix takeoff en vol : changer l'altitude au lieu de bloquer

Quand Gemini mappe "monte à Xm" sur takeoff et que le drone est
déjà en vol, on recalcule l'altitude absolue MSL et on utilise
goto_location pour atteindre la nouvelle altitude à position fixe.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
nicoboy
2026-06-01 13:08:31 +02:00
parent f7c4a7221b
commit 32a9713e36

View File

@ -107,7 +107,14 @@ async def execute_command(drone, cmd):
elif action == "takeoff": elif action == "takeoff":
await refresh_position(drone) await refresh_position(drone)
if current_pos["alt"] >= 2.0: if current_pos["alt"] >= 2.0:
return "Deja en vol" # Déjà en vol : changer l'altitude en conservant la position
new_abs_alt = current_pos["abs_alt"] - current_pos["alt"] + 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(alt)
await drone.action.arm() await drone.action.arm()
await drone.action.takeoff() await drone.action.takeoff()