Drone won't arm (GPS and satellites are normal)
The Pixhawk has a GPS fix and enough satellites, but the drone won't ARM. Which message does ArduPilot use to report the block, and how do you read it? Step by step with a short Python script.
The code is ready, but the drone won't ARM
Field day. The battery is in, the GPS light is on, Mission Planner says "10 satellites". You press ARM, and nothing happens.
The team wiggles the cable, reboots the board, calibrates the compass again. Fifteen minutes go by, then the drone suddenly arms on its own and nobody knows why.
Yet ArduPilot knew all along what the block was. The short Python script in this article reads the block and prints its reason on screen.
The autopilot reports the block in two separate places
The autopilot tells you two things. One is a flag that shows whether the drone is ready to ARM. This flag is carried inside the autopilot's status message. The other is a short text explaining the reason for the block.
The text doesn't stream continuously. ArduPilot repeats it every thirty seconds, and also sends it the moment you try to ARM. If you only listen passively, you may hear no reason at all for several seconds.
Don't assume it will ARM once GPS is ready
Even with a GPS fix and 10 satellites, ARM can be refused. The cause often isn't GPS: the gyros may not have reached thermal equilibrium yet, and the autopilot reports this with the gyros inconsistent message.
Waiting for GPS is necessary but not enough. To see which sensor is holding things up, you need to read the reason from the autopilot.
Code that reads the block and its reason
The code does two things in order. First it checks bit 0x10000000 in the SYS_STATUS message. This bit answers "is there a block?" without needing an ARM attempt. Then it sends a single ARM attempt and listens to the STATUSTEXT messages that follow for three seconds.
Look at the red arrows in the figure: the reason texts arrive right after the ARM command.
Getting the block and its reason from the autopilot, in order
import time
from pymavlink import mavutil
mav = mavutil.mavlink
PREARM_BIT = 0x10000000 # the "did prearm pass" bit in SYS_STATUS
arac = mavutil.mavlink_connection('tcp:127.0.0.1:5760')
arac.wait_heartbeat()
# SYS_STATUS may not stream by default - explicitly ask for 2 Hz
arac.mav.command_long_send(
arac.target_system, arac.target_component,
mav.MAV_CMD_SET_MESSAGE_INTERVAL,
0, mav.MAVLINK_MSG_ID_SYS_STATUS, 500_000, 0, 0, 0, 0, 0)
time.sleep(1)
def armlanabilir_mi(arac):
"""The only reliable indicator. Does not require an ARM attempt."""
s = arac.recv_match(type='SYS_STATUS', blocking=True, timeout=5)
return bool(s.onboard_control_sensors_health & PREARM_BIT) if s else None
def neden_bloke(arac, bekleme=3.0):
"""
To learn the REASON without waiting, send a single ARM attempt.
While disarmed, ArduPilot also reports the PreArm reason itself every 30 s
but an ARM attempt makes it send the reason immediately.
"""
arac.mav.command_long_send(
arac.target_system, arac.target_component,
mav.MAV_CMD_COMPONENT_ARM_DISARM, 0, 1, 0, 0, 0, 0, 0, 0)
sebepler = []
bitis = time.time() + bekleme
while time.time() < bitis:
m = arac.recv_match(type='STATUSTEXT', blocking=True, timeout=1)
if m and m.text.strip().startswith(('PreArm:', 'Arm:')):
sebepler.append(m.text.strip())
return sebepler
print(f"armlanabilir : {armlanabilir_mi(arac)}")
for s in neden_bloke(arac):
print(f" > {s}")By default the code connects to the simulator. If your board is on a USB or telemetry port, put that port in the connection line.
If the drone isn't with you, try it in SITL
If you want to try the code before going to the field, you can run the ArduCopter simulator (SITL) on your own computer. The commands below download and start the simulator. Then run the Python script in a separate terminal.
mkdir -p ~/sitl && cd ~/sitl
curl -sL -o arducopter \
https://firmware.ardupilot.org/Copter/stable/SITL_x86_64_linux_gnu/arducopter
chmod +x arducopter
curl -sL -o copter.parm \
https://raw.githubusercontent.com/ArduPilot/ardupilot/master/Tools/autotest/default_params/copter.parm
pip install pymavlink
./arducopter -S -I0 --model + --speedup 1 --defaults copter.parm \
--sysid 1 --home 37.1591,38.7969,500,0What you see when you run it
If you run it right after powering on the drone, on ArduCopter 4.7.0 you get output similar to this:
$ python3 prearm_mini.py
armlanabilir : False
> Arm: Accels inconsistent
> Arm: EKF attitude is bad
> Arm: AHRS: not using configured AHRS typeThree reasons arrive at once. None of them is about cables, and none is GPS. All three say "wait a bit longer". With this output in hand, you wouldn't have wasted those fifteen minutes.
Example: While waiting in line, run this code as soon as you power on the drone. If all three lines say "wait", don't touch the cables or the calibration; run the code again after a while. Once the armlanabilir (armable) line shows True, go ahead and ARM. If a line remains that doesn't clear with waiting, pass the reason text to the team exactly as it is; that's when calibration or cables come into play.
Error Messages
Arm: Gyros inconsistent
The gyros disagree with each other. It can appear even when GPS is ready. Usually the gyros haven't reached thermal equilibrium yet. Wait and try again.
Arm: Accels inconsistent
The accelerometers disagree with each other. If it appears right after power-on, wait a bit and try ARM again.
Arm: EKF attitude is bad
The autopilot's attitude estimate hasn't settled yet. It appears at startup; you need to wait.
Arm: AHRS: not using configured AHRS type
The autopilot hasn't switched to the configured estimator type yet. This is another message that appears right after power-on and should clear with waiting.
More in the course
The code above sees the block and tells you the reason. Which PreArm message corresponds to which connector, the differences between board families, and which messages clear with waiting and which don't are covered in the course.
For readers of this article: Basic Drone Course: From Sensors to Flight
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