Softivation

Mission Planner shows packet loss while telemetry is flowing

If Mission Planner shows packet loss while telemetry keeps flowing, look at who calculates that percentage, why the autopilot reports zero, and measure the link yourself.

Furkan IŞIKAY 6 min read

The flight is going on. The map is moving, altitude is coming in, and the vehicle responds when you change modes. But the loss percentage in the corner of Mission Planner has climbed and won't come down.

The only place that calculates that percentage is Mission Planner. If you ask the autopilot, it will say zero. Both are telling the truth, because they aren't counting the same thing.

The table on screen

Commands go through, and there's no warning sound. Even so, the link quality hovers below a hundred percent and dips now and then.

Most people's first move is to turn the antenna or swap the radio. It's cheaper to look at what that number measures before you change anything.

Who calculates that percentage

MAVLink puts a sequence number on every message. The counter runs from zero to two hundred fifty-five, then wraps around. The side that stamps the number is the autopilot.

Mission Planner keeps a separate counter for each source it receives from and writes the difference between the number it expected and the number that arrived into the loss field. A source is the pair of the vehicle's ID and the component ID. If two separate components transmit on the same link, their counters are separate too.

The percentage you see is not the total loss. Every five seconds, both the lost and the good counters are multiplied by zero point eight, so old losses fade over time. Ten seconds after the last valid packet, link quality drops straight to zero.

Why the autopilot shows zero

The autopilot's status message has two fields for communication. One of them is sent as a constant zero in the source code and is never calculated.

The second one is calculated, but what it counts isn't sequence gaps; it counts parse errors: a corrupt header, a wrong length, a failed checksum. If intact frames arrive on the link but messages are missing in between, this counter doesn't move.

So the autopilot saying zero doesn't mean the link is clean. That counter simply can't see the gap you're looking for.

Measure your own link

The way to be sure is to build your own counter. The code below connects, requests three streams at four hertz, listens for thirty seconds, and counts how many numbers were skipped for each source.

Python
# Measures seq gaps on the telemetry link.
# Usage: python3 hat_olc.py tcp:127.0.0.1:5760
import sys, time
from pymavlink import mavutil

adres = sys.argv[1] if len(sys.argv) > 1 else 'tcp:127.0.0.1:5760'
sure = 30

baglanti = mavutil.mavlink_connection(adres, source_system=255)
baglanti.wait_heartbeat()
print("connected: sysid=%d" % baglanti.target_system)

for akis in (mavutil.mavlink.MAV_DATA_STREAM_EXTENDED_STATUS,
             mavutil.mavlink.MAV_DATA_STREAM_POSITION,
             mavutil.mavlink.MAV_DATA_STREAM_EXTRA1):
    baglanti.mav.request_data_stream_send(
        baglanti.target_system, baglanti.target_component, akis, 4, 1)

son_seq, bosluk, alinan, bozuk = {}, {}, {}, 0
baslangic = time.time()

while time.time() - baslangic < sure:
    mesaj = baglanti.recv_match(blocking=True, timeout=1)
    if mesaj is None:
        continue
    if mesaj.get_type() == 'BAD_DATA':
        bozuk += 1
        continue
    kaynak = (mesaj.get_srcSystem(), mesaj.get_srcComponent())
    seq = mesaj.get_seq()
    alinan[kaynak] = alinan.get(kaynak, 0) + 1
    if kaynak in son_seq:
        atlanan = (seq - son_seq[kaynak] - 1) % 256
        if atlanan:
            bosluk[kaynak] = bosluk.get(kaynak, 0) + atlanan
    son_seq[kaynak] = seq

gecen = time.time() - baslangic
print("duration %.1f s, corrupt frames %d" % (gecen, bozuk))
for kaynak in sorted(alinan):
    gelen = alinan[kaynak]
    kayip = bosluk.get(kaynak, 0)
    oran = 100.0 * kayip / (gelen + kayip)
    print("sysid=%d compid=%-3d received=%-6d gaps=%-5d loss=%%%.2f (%.1f packets/s)"
          % (kaynak[0], kaynak[1], gelen, kayip, oran, gelen / gecen))

Change the address that connects to your vehicle to match your own setup. If you connect to a serial port from a companion computer, you'll give the port path and the baud rate instead of the address.

If you run it on a lossless link, you get output like this. The bosluk column is zero:

Output
connected: sysid=1
duration 30.0 s, corrupt frames 4
sysid=1 compid=1 received=1307 gaps=0 loss=%0.00 (43.6 packets/s)

If this number comes out above zero on your own link, the gap is real. If it comes out zero, the percentage on screen is the moving average itself, not a fault.

Example: During a rehearsal, link quality hovers below a hundred percent and your teammate wants to swap the radio. Before touching the radio, disconnect Mission Planner and run this code on the same link for thirty seconds. If the bosluk column is zero, the percentage on screen is just the trace of the moving average, and the radio is not to blame. If it's above zero, lower the stream rates and run the counter once more. If the gap closes, the difference comes from the autopilot's buffer, not the radio.

What changes in the field

A zero result is the expected outcome on a wired, uncongested link. When you fly with a radio, three things come into play: range, noise and the radio's own buffer.

The radio reports its free buffer percentage to the autopilot, and when this percentage drops the autopilot shifts its transmit interval. While the slowdown is active, data thins out but no sequence gap forms. Don't start hunting for loss just because data arrives late.

If the autopilot can't fit a message into its own output buffer, it discards that message's bytes and does not take back the sequence number. Follow message number 43 in the figure: it's dropped without ever reaching the radio, yet Mission Planner counts it as lost.

The sequence number is assigned before the message leaves on the link

The autopilot stamps numbers 41 through 46. Number 43 is dropped in the output buffer. Mission Planner sees 44 after 42 and counts one loss
Where to look: message number 43. Although it's dropped without ever reaching the radio, it shows up as a gap in Mission Planner.

In this case the gap comes from the autopilot itself, not the radio. Lowering the stream rates does more good than fiddling with the antenna.

Error Messages and Their Meanings

The strings below are identical to the ones in the Mission Planner source code.

No Heartbeat Packets Received

No heartbeat could be read during the connection attempt. The port is wrong, the baud rate is wrong, or another program is holding the line. This message is not about loss; it means the connection was never established.

Only 1 Heatbeat Received

The spelling is like this in the source. Mission Planner waits for two valid heartbeats to connect, and only one arrived. The line is open but weak, or foreign data is mixed in.

WARNING No Data for ... Seconds

It appears when no valid packet arrives for more than three seconds while the vehicle is armed. It's suppressed during the first thirty seconds after connecting and doesn't repeat more often than every five seconds. The number replacing the dots is the seconds of silence.

A line written to the log file. A frame arrived but its checksum didn't match. If you see this, bytes really are being corrupted. Look at range, noise or a baud rate mismatch.

mav ... seqno ... exp ... pkts lost ...

The line written to the log file at the moment of loss. From it you can work out which source, which number and how many packets wide the gap is. Verifying the on-screen percentage with these lines beats guessing.

More on this topic

You can find the course that covers setting up, duplicating and measuring a telemetry link from start to finish on the Drone Communication Technologies page. The in-depth version of this article is in that course too.

Was this article helpful?

Free resourcePixhawk and ArduPilot error message glossaryThe 5 messages in this article and similar ones are in the glossary: what they mean, why they appear, what to check first.

Learn this topic from start to finish

Season plan: all six courses for 9 months, ₺790 a month. ₺390 a month for high school and university students, ₺351 the first month with your member code. You can stop in any month you like. Start the Season plan · I'm a student