Ajout serveur web FastAPI sur port 8765

- wireclaw_core : expose drone comme global, extrait init()
  depuis main() pour permettre l'import par web_server.py ;
  corrige aussi le bug drone_armed manquant global dans init
- web_server.py : FastAPI avec process(text) générique
  (interpret_command → execute_command), routes GET / POST /command
  GET /status, page HTML sobre avec statut temps réel (2s)
  et historique des commandes

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
nicoboy
2026-06-01 13:54:54 +02:00
parent 66f7149d60
commit bcda9cf334
2 changed files with 302 additions and 1 deletions

View File

@ -33,6 +33,7 @@ Nord = lat+, Sud = lat-, Est = lon+, Ouest = lon-
drone_armed = False
current_pos = {"lat": BASE_LAT, "lon": BASE_LON, "alt": 0, "abs_alt": 584}
mav = None
drone = None
def init_pymavlink():
global mav
@ -197,7 +198,9 @@ async def execute_command(drone, cmd):
return "Action inconnue : " + action
async def main():
async def init():
"""Initialise pymavlink, MAVSDK et démarre monitor_armed en tâche de fond."""
global drone, drone_armed
init_pymavlink()
drone = System()
await drone.connect(system_address=MAVLINK_ADDRESS)
@ -212,6 +215,8 @@ async def main():
asyncio.ensure_future(monitor_armed(drone))
break
async def main():
await init()
print("\nWireClaw pret")
print("Commandes : takeoff, goto, orbit, status, position, hover, rtl, land\n")