Is_armable does not change to true

Hi there,
I´m new in drone programming and I tried to test the next code in my phisical drone to do a simple takeoff

vehicle = connect('udp:', wait_ready = False)
def arm_and_takeoff(aTargetAltitude):

  print "Basic pre-arm checks"
  # Don't let the user try to arm until autopilot is ready
  while not vehicle.is_armable:
          print " Waiting for vehicle to initialise..."
  print "Arming motors"
  # Copter should arm in GUIDED mode
  vehicle.mode    = VehicleMode("GUIDED")
  vehicle.armed   = True

  while not vehicle.armed:
         print " Waiting for arming..."

  print "Taking off!"
  vehicle.simple_takeoff(aTargetAltitude) # Take off to target altitude

  # Check that vehicle has reached takeoff altitude
  while True:
         print " Altitude: ", vehicle.location.global_relative_frame.alt 
         #Break and return from function just below target altitude.        
         if vehicle.location.global_relative_frame.alt>=aTargetAltitude*0.95: 
                  print "Reached target altitude"

# Initialize the takeoff sequence to 20m

print("Take off complete")

# Hover for 10 seconds

print("Now let's land")
vehicle.mode = VehicleMode("LAND")

# Close vehicle object

But at the end the program does not pass from Basic pre-arm checks. How Can I correct that??
Hope for your help.

Hi Alex,
you can remove the arming checks within parameter settings. Have you tried this?

If you have issues with any of the basic pre-arm checks your code will remain in that While loop and never move to the other sections of your code.

Arming checks can be completely removed or some omitted. GPS lock or the number of satellites required for passing pre-arm checks could be the issue.

As a test remove arming checks for everything other than GPS. Try it again. All you are performing is a take off to a certain height and then landing, so realistically you could disable all checks, aircraft will drift on you however with this code if you have wind.


Thsnks for your answer @ECain and yes, I removed the pre-arm checks but still the same… it just arms the motors in guided mode just for 5 seconds and then it stops and never takes off and how can I make that it doesn´t drift?

Hi Alex,
do you ever see the “Taking off!” printed? If not you remain in your loop.
Question: your while loops are do-while (boolean) configuration no? Or While loop? I don’t see in your code where the loop begins such as a do statement. Please excuse my ignorance here, but does it work such as:
//your code here
}while (while condition is true);

the second loop I read as a while loop
while(while condition is true)


the loops I need to see what code is encapsulated within the loop. Your second While True: will loop forever until the target altitude is reached. You need another way to exit out of this.
If it does reach the target altitude you immediate ask it to arm_and_takeoff(20). Why? Its already airborne to your aTargetAltitude.
your takeoff in guided mode does not have a waypoint for it to sit at, therefore the drift. Once Armed, you could switch into Loiter and give it an altitude to sit at. This would remove drift.

Interested to see if you were to change setting it to Guided, change that to Stabilize, arm and takeoff.

Hope this helps,

Hi @ECain
Sorry I forget to correct the indent in the lines of the loops, if you could check now the code it´s indented. Yes I can see the the “Taking off” printed but in the prompt says: mode GUIDED unknown… respect the first two loops are technically “do-while loops” then in the While True loop, once the drone has taken off it has tu reach the aTargetAltitude given, once done it breaks the loop, and then I call the function arm_and_takeoff(20)

Hi Alex,
My question is if you are already airborne and reached your aTargetAltitude, why arm_and_takeoff?

You can’t arm because you would already be armed. You can’t take off because you are already airborne.

Hİ Alex;
Can you solve your problem?
Because i have same problem too.