def arm_and_takeoff(aTargetAltitude):
 while (not vehicle.is_armable):
  print ' Waiting for vehicle to initialise...'
  time.sleep(1)
 while (vehicle.mode.name != 'GUIDED'):
  vehicle.mode = VehicleMode('GUIDED')
  time.sleep(0.1)
 while (not vehicle.armed):
  vehicle.armed = True
  print ' Waiting for arming...'
  time.sleep(1)
 print ' Taking off!'
 vehicle.simple_takeoff(aTargetAltitude)
 while True:
  requiredAlt = (aTargetAltitude * 0.95)
  if (vehicle.location.global_relative_frame.alt >= requiredAlt):
   print (' Reached target altitude of ~%f' % aTargetAltitude)
   break
  print (' Altitude: %f < %f' % (vehicle.location.global_relative_frame.alt, requiredAlt))
  time.sleep(1)

def arm_and_takeoff ( aTargetAltitude ) : while ( not vehicle . is_armable ) : print ' Waiting for vehicle to initialise...' time . sleep ( 1 ) while ( vehicle . mode . name != 'GUIDED' ) : vehicle . mode = VehicleMode ( 'GUIDED' ) time . sleep ( 0.1 ) while ( not vehicle . armed ) : vehicle . armed = True print ' Waiting for arming...' time . sleep ( 1 ) print ' Taking off!' vehicle . simple_takeoff ( aTargetAltitude ) while True : requiredAlt = ( aTargetAltitude * 0.95 ) if ( vehicle . location . global_relative_frame . alt >= requiredAlt ) : print ( ' Reached target altitude of ~%f' % aTargetAltitude ) break print ( ' Altitude: %f < %f' % ( vehicle . location . global_relative_frame . alt , requiredAlt ) ) time . sleep ( 1 )
arms vehicle and fly to atargetaltitude .