Raspberry Pi data is missing in Mission Planner: check the sysid
Your Raspberry Pi code sends target data over MAVLink but Mission Planner shows not a single line? The Pixhawk filters packets by sysid and compid, and that's the cause.
The code on your Raspberry Pi finds the target, sends the coordinates to the Pixhawk, and the terminal shows not a single error. Yet Mission Planner's Messages tab stays empty and no new value appears on the Quick tab either.
The Pixhawk either doesn't accept the packet at all, or delivers it to Mission Planner as data from a different vehicle. Two numbers in the Pi code decide which.
How the Pixhawk decides whether to forward a packet from the Pi
When you connect the Pi to TELEM2, the Pixhawk acts like a router between two links. Every packet the Pi sends starts with the sender's identity: a system ID (sysid) and a component ID (compid). The autopilot checks this identity and either drops the packet or forwards it to the other ports.
Of the four rows in the figure, only the one that starts with 1 / 191 and has its port open reaches the drone's own screen.
Where a packet from the Pi ends up, based on its identity
If you write 1 / 1, the Pixhawk treats the packet as its own echo and silently drops it without any warning. This rule exists to stop a wrongly wired serial line from echoing its own messages back and creating a loop.
255 / 0 is the value pymavlink uses when you don't set an identity. These packets do reach Mission Planner. The program records them under a separate system numbered 255 and does not put them in the drone's Messages list or the Quick boxes.
The correct identity carries the same sysid as the drone and a compid different from the autopilot's. The component ID reserved for a companion computer is 191.
Example: seeing a lock-on event at the ground station
In a Fighting UAV mission, when the detection code on the Pi frames the opposing UAV, your teammate at the ground station wants to see it at that moment. On every frame, the code can send the target's pixel coordinates as HEDEF_X and HEDEF_Y, and send the lock event as a short text message.
NAMED_VALUE_FLOAT suits continuously changing numbers, and STATUSTEXT suits occasional events. A text message adds a new line to the Messages list. If you send text on every frame, the list becomes unreadable.
The most common mistake
The Pi code copies the sysid of the first HEARTBEAT it catches at startup. The Pixhawk also forwards the ground station's HEARTBEAT to TELEM2. If the first packet caught is Mission Planner's 255, the code mistakes itself for a ground station and its data never reaches the drone's screen.
That's why the code below accepts only a HEARTBEAT whose autopilot field is filled in.
Solution
Don't hard-code the identity; read it from the drone. The code waits for the autopilot's HEARTBEAT, takes its sysid for itself and uses 191 as the component ID. On the Pixhawk side, SERIAL2_PROTOCOL = 2 and SERIAL2_BAUD = 921 must be set for TELEM2.
import time
from pymavlink import mavutil
BAGLANTI = "/dev/serial0" # if connected over USB: "/dev/ttyACM0"
pix = mavutil.mavlink_connection(BAGLANTI, baud=921600,
source_component=mavutil.mavlink.MAV_COMP_ID_ONBOARD_COMPUTER)
# Wait for the autopilot's HEARTBEAT; skip HEARTBEATs forwarded from the GCS
while True:
hb = pix.recv_match(type="HEARTBEAT", blocking=True, timeout=5)
if hb and hb.autopilot != mavutil.mavlink.MAV_AUTOPILOT_INVALID:
break
pix.mav.srcSystem = hb.get_srcSystem() # the drone's sysid (MAV_SYSID)
print("Autopilot sysid:", pix.mav.srcSystem, "| Pi compid:", pix.mav.srcComponent)
def gonder(x, y, guven):
pix.mav.heartbeat_send(mavutil.mavlink.MAV_TYPE_ONBOARD_CONTROLLER,
mavutil.mavlink.MAV_AUTOPILOT_INVALID, 0, 0, 0)
t = int(time.time() * 1000) & 0xFFFFFFFF
pix.mav.named_value_float_send(t, b"HEDEF_X", x) # name is at most 10 characters
pix.mav.named_value_float_send(t, b"HEDEF_Y", y)
yazi = "Target x=%d y=%d conf=%.2f" % (x, y, guven)
pix.mav.statustext_send(mavutil.mavlink.MAV_SEVERITY_INFO, yazi.encode()[:50])
for i in range(5):
gonder(412 + i, 230, 0.87)
time.sleep(1)If the code runs but there's still nothing on screen, these are the next candidates:
- Enter: In Mission Planner, go to Config > Full Parameter List and read the MAV3_OPTIONS value (if TELEM2 is the third MAVLink port). You'll see: 0. If not: set it to 0 and restart the autopilot. A value of 2 closes this port to forwarding.
- Enter: If you use a ground station you wrote yourself instead of Mission Planner, have it send a HEARTBEAT once per second as soon as it connects. You'll see: The Pi's messages start to flow. If not: recheck the line and the identity against the figure above.
The Pixhawk forwards the Pi's stream only to ports that have previously sent it a packet. It sends its own telemetry to every port without this check. That's why a silent ground station receives the drone's data but never sees the Pi's lines.
What you'll see
When you run the code on the Pi, the first line in the terminal is:
Autopilot sysid: 1 | Pi compid: 191In Mission Planner, switch to the Messages tab on the DATA screen. Lines from the Pi start with the component ID:
191 : Target x=412 y=230 conf=0.87For the numbers, double-click a box on the Quick tab. In the list that opens, you'll see the names MAV_HEDEF_X and MAV_HEDEF_Y. Mission Planner adds MAV_ to the start of the name and uppercases the letters.
The name field takes at most 10 characters. If you send hedef_x_piksel, the rest is truncated and MAV_HEDEF_X_PI appears in the list.
If you want the message to appear on the HUD as well, set the severity to MAV_SEVERITY_WARNING. By default, Mission Planner carries only warnings and more serious messages to the HUD. INFO level stays in the Messages list.
Error Messages and Their Meanings
PreArm: SERIAL2_OPTIONS bit 10 ('no forward mavlink') must not be set; use MAVn_OPTIONS bit 1 instead
In ArduPilot 4.7, the setting that disables forwarding moved from the serial port options to MAVn_OPTIONS. When you load a parameter file left over from an older version, bit 10 in SERIAL2_OPTIONS can stay set and the autopilot won't allow arming.
Subtract 1024 from the SERIAL2_OPTIONS value. If you really want to close the port, do it with bit 1 of MAVn_OPTIONS.
Arm: SERIAL2_OPTIONS bit 10 ('no forward mavlink') must not be set; use MAVn_OPTIONS bit 1 instead
The same check returns with the Arm: prefix the moment you send the ARM command, and the command is rejected. The fix is the same as for the previous message.
Building this link end to end
You can study the serial link between the Pi and the Pixhawk, and the order in which a MAVLink packet is filtered in the autopilot, step by step in the Drone Communication Technologies course.
Was this article helpful?
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