Mostrar en vivo la posición y la trayectoria de vuelo de un dron de inspección en un tablero
Traducido del English por IA ·
Inspeccionamos campos solares con un pequeño cuadricóptero y el cliente pidió “seguir el vuelo” desde su oficina, además de ver después qué filas se cubrieron. El dron usa un piloto automático de código abierto habitual (MAVLink 2) y ya tiene una Raspberry Pi Zero 2 W como computadora auxiliar con un módem 4G para el enlace de vídeo.Me gustaría mostrar posición, altitud y batería en un tablero Hermetry con un mapa, en directo, y una reproducción de la trayectoria tras el vuelo. ¿Cómo se extraen datos de una controladora de vuelo? Nunca he trabajado con MAVLink, normalmente hago inversores y medidores.
We inspect solar fields with a small quadcopter and the client asked to «watch the flight» from their office, plus see afterwards which rows were covered. The drone runs a common open-source autopilot (MAVLink 2), and has a Raspberry Pi Zero 2 W as companion computer with a 4G stick for the video link already.
I’d like position, altitude and battery on a Hermetry board with a map, live, and a replay of the path after the flight. How do you even get data out of a flight controller? I’ve never touched MAVLink, I usually do inverters and meters.
Traducido del English por IA ·
¿Qué firmware de autopiloto se usa y qué puerto está libre en él? La mayoría tiene un segundo puerto de telemetría pensado para un ordenador acompañante.
Which autopilot firmware and which port is free on it? Most have a second telemetry port meant for a companion computer.
Traducido del English por IA ·
Pregunta aparte: ¿estás siquiera autorizado a enviar telemetría por 4G desde un dron donde estás? Algunos lugares tienen normas al respecto.
Side question, are you even allowed to send telemetry over 4G from a drone where you are? Some places have rules about that.
Traducido del English por IA ·
TELEM2 está libre, la Pi ya está conectada en él a 921600 para la herramienta de vídeo. Y sí, tenemos los permisos para los sitios en los que volamos.
TELEM2 is free, the Pi is already on it at 921600 for the video tool. And yes, we have the permissions for the sites we fly.
Traducido del English por IA ·
Hice esto para un dron de inspección de tejados, así que aquí tienes lo que terminé usando.En la Pi, pymavlink lee el flujo MAVLink desde TELEM2. Solo necesitas dos mensajes: GLOBAL_POSITION_INT (lat/lon en 1e7 grados, altitud relativa en mm) y SYS_STATUS (voltaje de batería en mV). Una vez por segundo, publica un objeto plano por MQTT con TLS:
from pymavlink import mavutil
m = mavutil.mavlink_connection("/dev/serial0", baud=921600)
state = {}
while True:
msg = m.recv_match(type=["GLOBAL_POSITION_INT", "SYS_STATUS"], blocking=True)
if msg.get_type() == "GLOBAL_POSITION_INT":
state.update(lat=msg.lat / 1e7, lng=msg.lon / 1e7, alt_m=msg.relative_alt / 1000)
else:
state["batt_v"] = msg.voltage_battery / 1000
if time.time() - last >= 1:
client.publish("v1/telemetry", json.dumps(state), qos=1); last = time.time()
Nombra las claves lat y lng, que es lo que busca la tarjeta Map por defecto.En el panel, una tarjeta Map. Vincula Points a los últimos valores del dron (lat, lng) y tendrás el marcador en vivo. Vincula Routes a las lecturas del dispositivo a lo largo del tiempo con las claves lat,lng, y activa los controles de reproducción. El cliente puede reproducir el vuelo de 1x a 10x y desplazarse por él. Añade al lado una tarjeta de valor para la batería y la altitud. El estilo de mapa satélite ayuda a ver las filas del panel.1 mensaje por segundo está muy por debajo de los límites predeterminados por dispositivo. Y mantenlo de solo lectura: nada de comandos desde el panel al dron, el piloto es quien lo vuela.
Did this for a roof inspection drone, so here’s what I ended up with.
On the Pi, pymavlink reads the MAVLink stream from TELEM2. You only need two messages: GLOBAL_POSITION_INT (lat/lon in 1e7 degrees, relative altitude in mm) and SYS_STATUS (battery voltage in mV). Once a second, publish a flat object over MQTT with TLS:
from pymavlink import mavutil
m = mavutil.mavlink_connection("/dev/serial0", baud=921600)
state = {}
while True:
msg = m.recv_match(type=["GLOBAL_POSITION_INT", "SYS_STATUS"], blocking=True)
if msg.get_type() == "GLOBAL_POSITION_INT":
state.update(lat=msg.lat / 1e7, lng=msg.lon / 1e7, alt_m=msg.relative_alt / 1000)
else:
state["batt_v"] = msg.voltage_battery / 1000
if time.time() - last >= 1:
client.publish("v1/telemetry", json.dumps(state), qos=1); last = time.time()
Name the keys lat and lng, that’s what the Map card looks for by default.
On the board, a Map card. Bind Points to the drone’s latest values (lat, lng), and that’s your live marker. Bind Routes to Device readings over time with the keys lat,lng, and turn on Replay controls. The client can play the flight back at 1x to 10x and scrub. Add a value card for battery and altitude next to it. Satellite map style helps them see the panel rows.
1 message a second is far inside the default per-device limits. And keep it read-only: no commands from the board to the drone, the pilot flies it.
Traducido del English por IA ·
Hecho el primer vuelo de prueba. El marcador en vivo se mueve, y la reproducción tras el aterrizaje mostró exactamente qué filas cubrimos; al cliente le encantó el scrubbing. Al principio tenía lat/lon como clave y el mapa decía «No hay filas con coordenadas válidas»; lo renombré a lng y apareció.
Worked on the first test flight. Live marker moves, and the replay after landing showed exactly which rows we covered, the client loved the scrubbing. Had lat/lon as the key at first and the map said «No rows with valid coordinates», renamed to lng and it appeared.
Traducido del English por IA ·
La parte de reproducción es realmente genial, no sabía que el mapa podía hacer eso.
The replay part is really nice, I didn’t know the map could do that.
- Debes estar registrado para responder a este debate.
Únete a la conversación
Inicia sesión para preguntar y responder, dar me gusta a las publicaciones útiles y marcar la respuesta que resolvió tu problema. Cada aportación suma puntos y niveles.

