MCPcopy
hub / github.com/dronekit/dronekit-python / arm_and_takeoff

Function arm_and_takeoff

dronekit/test/sitl/test_locations.py:17–50  ·  view source on GitHub ↗

Arms vehicle and fly to aTargetAltitude.

(aTargetAltitude)

Source from the content-addressed store, hash-verified

15 vehicle.parameters['FS_EKF_THRESH'] = 100
16
17 def arm_and_takeoff(aTargetAltitude):
18 """
19 Arms vehicle and fly to aTargetAltitude.
20 """
21
22 # Don't let the user try to fly autopilot is booting
23 wait_for(lambda : vehicle.is_armable, 60)
24 assert_equals(vehicle.is_armable, True)
25
26 # Copter should arm in GUIDED mode
27 vehicle.mode = VehicleMode("GUIDED")
28 wait_for(lambda : vehicle.mode.name == 'GUIDED', 60)
29 assert_equals(vehicle.mode.name, 'GUIDED')
30
31 # Arm copter.
32 vehicle.armed = True
33 wait_for(lambda : vehicle.armed, 60)
34 assert_equals(vehicle.armed, True)
35
36 # Take off to target altitude
37 vehicle.simple_takeoff(aTargetAltitude)
38
39 # Wait until the vehicle reaches a safe height before
40 # processing the goto (otherwise the command after
41 # Vehicle.simple_takeoff will execute immediately).
42 while True:
43 # print " Altitude: ", vehicle.location.alt
44 # Test for altitude just below target, in case of undershoot.
45 if vehicle.location.global_frame.alt >= aTargetAltitude * 0.95:
46 # print "Reached target altitude"
47 break
48
49 assert_equals(vehicle.mode.name, 'GUIDED')
50 time.sleep(1)
51
52 arm_and_takeoff(10)
53 vehicle.wait_ready('location.local_frame', timeout=60)

Callers 1

test_timeoutFunction · 0.70

Calls 3

wait_forFunction · 0.90
VehicleModeClass · 0.90
simple_takeoffMethod · 0.80

Tested by

no test coverage detected