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

Function test_timeout

dronekit/test/sitl/test_locations.py:8–69  ·  view source on GitHub ↗
(connpath)

Source from the content-addressed store, hash-verified

6
7@with_sitl
8def test_timeout(connpath):
9 vehicle = connect(connpath, wait_ready=True)
10
11 # NOTE these are *very inappropriate settings*
12 # to make on a real vehicle. They are leveraged
13 # exclusively for simulation. Take heed!!!
14 vehicle.parameters['FS_GCS_ENABLE'] = 0
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)
54
55 # .north, .east, and .down are initialized to None.
56 # Any other value suggests that a LOCAL_POSITION_NED was received and parsed.
57 assert_not_equals(vehicle.location.local_frame.north, None)
58 assert_not_equals(vehicle.location.local_frame.east, None)
59 assert_not_equals(vehicle.location.local_frame.down, None)
60
61 # global_frame
62 assert_not_equals(vehicle.location.global_frame.lat, None)
63 assert_not_equals(vehicle.location.global_frame.lon, None)
64 assert_not_equals(vehicle.location.global_frame.alt, None)
65 assert_equals(type(vehicle.location.global_frame.lat), float)

Callers

nothing calls this directly

Calls 4

connectFunction · 0.90
arm_and_takeoffFunction · 0.70
wait_readyMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected