Compare commits
8 Commits
6276c1dac5
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 01b9e0bca9 | |||
| 07b0b8c1b5 | |||
| d32ad8c94e | |||
| c5cba6a318 | |||
| f978bf31dd | |||
| 84527b9820 | |||
| b7625a883c | |||
| 43ef4d47fc |
25
CLAUDE.md
25
CLAUDE.md
@ -11,6 +11,31 @@ un LLM les interprète et génère des commandes MAVLink vers ArduPilot.
|
|||||||
- **Pi Zero 2W** : IP 192.168.1.132 — flux vidéo H.264 UDP → Jetson (câblé, arrêté pour l'instant)
|
- **Pi Zero 2W** : IP 192.168.1.132 — flux vidéo H.264 UDP → Jetson (câblé, arrêté pour l'instant)
|
||||||
- **Matek H743** : à venir — contrôleur de vol ArduPilot réel
|
- **Matek H743** : à venir — contrôleur de vol ArduPilot réel
|
||||||
|
|
||||||
|
## Renommage du dossier (20 juillet 2026)
|
||||||
|
|
||||||
|
Ce dossier s'appelait `~/wireclaw`, renommé en `~/wireclaw-jetson` pour clarté : le repo `wireclaw-pizero` (config du drone) est maintenant aussi cloné localement sur le Jetson (voir ci-dessous), donc les deux noms de dossier doivent être distincts.
|
||||||
|
|
||||||
|
**Le dépôt distant Gitea reste `wireclaw.git`** (inchangé) — seul le nom du dossier local sur le Jetson a changé. Ne pas confondre les deux : `git remote -v` continuera d'afficher `wireclaw.git`, c'est normal.
|
||||||
|
|
||||||
|
Services systemd mis à jour en conséquence (`WorkingDirectory`/`ExecStart` pointent vers `/home/nicoboy/wireclaw-jetson`) :
|
||||||
|
- `wireclaw.service` (tests SITL ArduPilot, carte MAV+GPS)
|
||||||
|
- `receive-cam.service` (réception vidéo/YOLO/MJPEG)
|
||||||
|
|
||||||
|
## Organisation des deux repos sur le Jetson
|
||||||
|
|
||||||
|
Depuis le 20 juillet 2026, les deux dépôts du projet sont clonés localement sur le Jetson, pour permettre au script `switch_band.sh` (voir ci-dessous) de lire les deux profils de config radio sans dépendre du réseau vers un PC distant :
|
||||||
|
|
||||||
|
- `~/wireclaw-jetson/` — ce repo, code Jetson (réception vidéo, config radio ground station)
|
||||||
|
- `~/wireclaw-pizero/` — code Pi Zero (émission caméra, config radio drone). **Ce repo reste normalement édité depuis le PC habituel** — le clone Jetson sert uniquement de source pour le déploiement des profils radio, pas de zone d'édition principale. Toujours faire `git pull` avant toute édition, où que ce soit, pour éviter une divergence entre les deux clones.
|
||||||
|
|
||||||
|
## Profils radio versionnés (5GHz / 2.4GHz)
|
||||||
|
|
||||||
|
Deux profils complets et testés existent dans `config/` de chaque repo :
|
||||||
|
- `wifibroadcast_gs_5ghz.cfg` / `wifibroadcast_drone_5ghz.cfg` — canal 149, bande opérationnelle par défaut du projet
|
||||||
|
- `wifibroadcast_gs_24ghz.cfg` / `wifibroadcast_drone_24ghz.cfg` — canal 6, **usage diagnostic/comparatif uniquement** : confirmé sujet à interférence domestique sévère (freeze disparaît en mode auto Freebox, revient sur canal chevauchant — cf 20260720_wireclaw_avancement_v17.md §6)
|
||||||
|
|
||||||
|
Bascule via `scripts/switch_band.sh 5ghz` ou `scripts/switch_band.sh 2.4ghz` (voir le script pour le détail — copie directe des profils, pas de patch, backup unique `.bak_last` écrasé à chaque bascule).
|
||||||
|
|
||||||
## Stack logicielle
|
## Stack logicielle
|
||||||
- Python 3.10, asyncio
|
- Python 3.10, asyncio
|
||||||
- MAVSDK Python (udp://:14551)
|
- MAVSDK Python (udp://:14551)
|
||||||
|
|||||||
@ -23,6 +23,7 @@ peer = 'connect://127.0.0.1:14550' # outgoing connection
|
|||||||
[gs_video]
|
[gs_video]
|
||||||
peer = 'connect://127.0.0.1:5600' # outgoing connection
|
peer = 'connect://127.0.0.1:5600' # outgoing connection
|
||||||
bandwidth = 40 # Test HT40, aligné avec drone_video
|
bandwidth = 40 # Test HT40, aligné avec drone_video
|
||||||
|
mcs_index = 0 # Valeur par défaut (override master.cfg defaut=1)
|
||||||
|
|
||||||
[gs_tunnel]
|
[gs_tunnel]
|
||||||
fec_delay = 35000 # µs — décorrèle les 2 copies FEC (k=1/n=2) pour
|
fec_delay = 35000 # µs — décorrèle les 2 copies FEC (k=1/n=2) pour
|
||||||
20
config/wifibroadcast_gs_5ghz.cfg
Normal file
20
config/wifibroadcast_gs_5ghz.cfg
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
[common]
|
||||||
|
wifi_channel = 149 # 149 = 5GHz (DFS/UNII) | 1 = 2.4GHz
|
||||||
|
wifi_region = 'FR' # Réglementation CRDA — FR par défaut ici,
|
||||||
|
# PAS 'BO'/'GY' (max tx power, hors cadre FR)
|
||||||
|
|
||||||
|
[gs_mavlink]
|
||||||
|
fec_delay = 20000 # us -- meme mecanisme que gs_tunnel, valeur adaptee a MCS3. Validation formelle en attente (trafic MAVLink vivant requis). Cf v16.
|
||||||
|
peer = 'connect://127.0.0.1:14550' # outgoing connection
|
||||||
|
|
||||||
|
[gs_video]
|
||||||
|
peer = 'connect://127.0.0.1:5600' # outgoing connection
|
||||||
|
bandwidth = 40 # HT40, jamais testé sur 5GHz avant ce profil
|
||||||
|
mcs_index = 0 # Valeur par défaut (override master.cfg defaut=1)
|
||||||
|
|
||||||
|
[gs_tunnel]
|
||||||
|
fec_delay = 35000 # µs — décorrèle les 2 copies FEC (k=1/n=2) pour
|
||||||
|
# échapper aux fenêtres de surdité half-duplex.
|
||||||
|
# Cf. 20260718_wireclaw_avancement_v15.md / méthode Fable.
|
||||||
|
# Plafonne le débit tunnel à ~300 kbps (OK ping/
|
||||||
|
# sideband/SSH interactif, PAS pour scp/gros transferts).
|
||||||
@ -62,6 +62,7 @@ _pi_stats: dict | None = None
|
|||||||
# RSSI du flux vidéo dédié WFB-NG reçu via API JSON 127.0.0.1:8103
|
# RSSI du flux vidéo dédié WFB-NG reçu via API JSON 127.0.0.1:8103
|
||||||
_rssi_lock = threading.Lock()
|
_rssi_lock = threading.Lock()
|
||||||
_rssi_data: dict | None = None # {"rssi_avg": -63, "snr_avg": 17}
|
_rssi_data: dict | None = None # {"rssi_avg": -63, "snr_avg": 17}
|
||||||
|
_band_label: str = "?" # "2.4GHz" ou "5GHz", déterminé au démarrage
|
||||||
RSSI_API_PORT = 8103
|
RSSI_API_PORT = 8103
|
||||||
|
|
||||||
|
|
||||||
@ -90,6 +91,29 @@ def sideband_loop() -> None:
|
|||||||
print("[SIDEBAND] Arrêt.")
|
print("[SIDEBAND] Arrêt.")
|
||||||
|
|
||||||
|
|
||||||
|
def band_label_loop() -> None:
|
||||||
|
"""Relit /etc/wifibroadcast.cfg toutes les 10s pour détecter un
|
||||||
|
changement de bande (ex: après switch_band.sh) sans jamais avoir
|
||||||
|
besoin de redémarrer ce service."""
|
||||||
|
global _band_label
|
||||||
|
while _running:
|
||||||
|
try:
|
||||||
|
with open("/etc/wifibroadcast.cfg") as f:
|
||||||
|
for line in f:
|
||||||
|
line = line.strip()
|
||||||
|
if line.startswith("wifi_channel"):
|
||||||
|
val = line.split("=", 1)[1].split("#")[0].strip()
|
||||||
|
ch = int(val)
|
||||||
|
new_label = "2.4GHz" if ch <= 14 else "5GHz"
|
||||||
|
if new_label != _band_label:
|
||||||
|
print(f"[BAND] Changement détecté : {_band_label} -> {new_label}")
|
||||||
|
_band_label = new_label
|
||||||
|
break
|
||||||
|
except (FileNotFoundError, ValueError, IndexError) as e:
|
||||||
|
print(f"[BAND] Impossible de lire wifi_channel : {e}")
|
||||||
|
time.sleep(10)
|
||||||
|
|
||||||
|
|
||||||
def rssi_loop() -> None:
|
def rssi_loop() -> None:
|
||||||
"""Écoute l'API JSON wfb-ng locale (127.0.0.1:8103), extrait le RSSI
|
"""Écoute l'API JSON wfb-ng locale (127.0.0.1:8103), extrait le RSSI
|
||||||
du flux vidéo dédié (id="video rx") et le stocke pour l'overlay.
|
du flux vidéo dédié (id="video rx") et le stocke pour l'overlay.
|
||||||
@ -200,6 +224,7 @@ def draw_rssi_pyramid(frame: np.ndarray) -> np.ndarray:
|
|||||||
|
|
||||||
def draw_overlay(frame: np.ndarray) -> np.ndarray:
|
def draw_overlay(frame: np.ndarray) -> np.ndarray:
|
||||||
"""Dessine l'overlay stats Pi Zero (fond noir semi-transparent) sur le frame."""
|
"""Dessine l'overlay stats Pi Zero (fond noir semi-transparent) sur le frame."""
|
||||||
|
global _band_label
|
||||||
with _stats_lock:
|
with _stats_lock:
|
||||||
stats = _pi_stats
|
stats = _pi_stats
|
||||||
if stats is None:
|
if stats is None:
|
||||||
@ -212,10 +237,11 @@ def draw_overlay(frame: np.ndarray) -> np.ndarray:
|
|||||||
temp = stats.get("temp_c", "?")
|
temp = stats.get("temp_c", "?")
|
||||||
cpu = stats.get("cpu_pct", "?")
|
cpu = stats.get("cpu_pct", "?")
|
||||||
throttled = stats.get("throttled", False)
|
throttled = stats.get("throttled", False)
|
||||||
throttle_str = "THROTTLED" if throttled else "ok"
|
|
||||||
|
|
||||||
line1 = f"{w_res}x{h_res} | {fps}fps | {enc} | {temp}C"
|
line1 = f"{w_res}x{h_res} | {fps}fps | {enc} | {temp}C"
|
||||||
line2 = f"CPU {cpu}% | {throttle_str}"
|
line2 = f"CPU {cpu}% | {_band_label}"
|
||||||
|
if throttled:
|
||||||
|
line2 += " | THROTTLED"
|
||||||
|
|
||||||
font = cv2.FONT_HERSHEY_SIMPLEX
|
font = cv2.FONT_HERSHEY_SIMPLEX
|
||||||
scale = 0.55
|
scale = 0.55
|
||||||
@ -399,6 +425,10 @@ def main():
|
|||||||
tr = threading.Thread(target=rssi_loop, daemon=True)
|
tr = threading.Thread(target=rssi_loop, daemon=True)
|
||||||
tr.start()
|
tr.start()
|
||||||
|
|
||||||
|
# Thread bande : relit wifi_channel toutes les 10s pour détecter les changements
|
||||||
|
tb = threading.Thread(target=band_label_loop, daemon=True)
|
||||||
|
tb.start()
|
||||||
|
|
||||||
# Thread de fond : connexion/reconnexion continue au flux GStreamer réel
|
# Thread de fond : connexion/reconnexion continue au flux GStreamer réel
|
||||||
tg = threading.Thread(target=gstreamer_watcher, daemon=True)
|
tg = threading.Thread(target=gstreamer_watcher, daemon=True)
|
||||||
tg.start()
|
tg.start()
|
||||||
|
|||||||
83
scripts/switch_band.sh
Executable file
83
scripts/switch_band.sh
Executable file
@ -0,0 +1,83 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# switch_band.sh — Bascule entre les deux profils radio complets et
|
||||||
|
# testés (5GHz canal 149 / 2.4GHz canal 6), Jetson + Pi Zero synchronisés.
|
||||||
|
#
|
||||||
|
# Les deux profils vivent en dur dans les repos (config/wifibroadcast_gs_*.cfg
|
||||||
|
# ici, config/wifibroadcast_drone_*.cfg dans wireclaw-pizero, cloné
|
||||||
|
# localement sur le Jetson) — ce script les copie tels quels, il ne
|
||||||
|
# patche rien. Pour modifier un profil, édite le fichier de référence
|
||||||
|
# correspondant dans le repo concerné, commit/push, puis relance ce
|
||||||
|
# script pour le déployer.
|
||||||
|
#
|
||||||
|
# 5GHz = bande opérationnelle par défaut (cf v17 §6 — 2.4GHz sujet à
|
||||||
|
# interférence domestique confirmée, usage diagnostic/comparatif
|
||||||
|
# uniquement).
|
||||||
|
#
|
||||||
|
# USAGE : ./switch_band.sh 5ghz | 2.4ghz
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||||
|
PIZERO_REPO="${HOME}/wireclaw-pizero"
|
||||||
|
CFG_JETSON="/etc/wifibroadcast.cfg"
|
||||||
|
SSH_PI="jetson-pi"
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
echo "Usage: $0 {5ghz|2.4ghz}"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
[ $# -eq 1 ] || usage
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
5ghz)
|
||||||
|
GS_PROFILE="${REPO_DIR}/config/wifibroadcast_gs_5ghz.cfg"
|
||||||
|
DRONE_PROFILE="${PIZERO_REPO}/config/wifibroadcast_drone_5ghz.cfg"
|
||||||
|
BAND_LABEL="5GHz (canal 149) — bande opérationnelle"
|
||||||
|
;;
|
||||||
|
2.4ghz)
|
||||||
|
GS_PROFILE="${REPO_DIR}/config/wifibroadcast_gs_24ghz.cfg"
|
||||||
|
DRONE_PROFILE="${PIZERO_REPO}/config/wifibroadcast_drone_24ghz.cfg"
|
||||||
|
BAND_LABEL="2.4GHz (canal 6) — ⚠️ interférence domestique possible, usage diagnostic uniquement"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
usage
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
[ -f "$GS_PROFILE" ] || { echo "Profil introuvable : $GS_PROFILE"; exit 1; }
|
||||||
|
[ -f "$DRONE_PROFILE" ] || { echo "Profil introuvable : $DRONE_PROFILE (pense à faire git pull dans wireclaw-pizero)"; exit 1; }
|
||||||
|
|
||||||
|
echo "=== Bascule vers $BAND_LABEL ==="
|
||||||
|
echo
|
||||||
|
echo "--- Diff profil Jetson (système actuel vs cible) ---"
|
||||||
|
diff -u "$CFG_JETSON" "$GS_PROFILE" || true
|
||||||
|
echo
|
||||||
|
read -r -p "Appliquer ce profil sur les deux machines ? [y/N] " confirm
|
||||||
|
[[ "$confirm" =~ ^[yY]([eE][sS])?$ ]] || { echo "Annulé."; exit 0; }
|
||||||
|
|
||||||
|
# Backup unique (écrasé à chaque bascule, pas d'accumulation de .bak)
|
||||||
|
sudo cp "$CFG_JETSON" "${CFG_JETSON}.bak_last"
|
||||||
|
ssh "$SSH_PI" "sudo cp /etc/wifibroadcast.cfg /etc/wifibroadcast.cfg.bak_last"
|
||||||
|
|
||||||
|
# Application — copie directe du profil complet, pas de patch
|
||||||
|
sudo cp "$GS_PROFILE" "$CFG_JETSON"
|
||||||
|
scp "$DRONE_PROFILE" "${SSH_PI}:/tmp/wifibroadcast_new.cfg"
|
||||||
|
ssh "$SSH_PI" "sudo cp /tmp/wifibroadcast_new.cfg /etc/wifibroadcast.cfg && rm /tmp/wifibroadcast_new.cfg"
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "Redémarrage des services..."
|
||||||
|
sudo systemctl restart wfb-server-gs.service
|
||||||
|
ssh "$SSH_PI" "sudo systemctl restart wfb-server-drone.service"
|
||||||
|
sleep 5
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "--- Vérification PHY (Jetson) ---"
|
||||||
|
iw dev wlx54c9ff02f26e info | grep -E "channel|width" || echo "⚠️ Lecture PHY échouée"
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "--- Vérification config chargée (API JSON sol) ---"
|
||||||
|
timeout 2 nc 127.0.0.1 8103 | head -1 | python3 -m json.tool | grep -A5 '"common"' || echo "⚠️ API 8103 non accessible"
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "✅ Bascule vers $BAND_LABEL terminée."
|
||||||
Reference in New Issue
Block a user