MCPcopy Index your code
hub / github.com/dronekit/dronekit-python / arm_and_takeoff

Function arm_and_takeoff

examples/mission_basic/mission_basic.py:140–171  ·  view source on GitHub ↗

Arms vehicle and fly to aTargetAltitude.

(aTargetAltitude)

Source from the content-addressed store, hash-verified

138
139
140def arm_and_takeoff(aTargetAltitude):
141 """
142 Arms vehicle and fly to aTargetAltitude.
143 """
144
145 print "Basic pre-arm checks"
146 # Don't let the user try to arm until autopilot is ready
147 while not vehicle.is_armable:
148 print " Waiting for vehicle to initialise..."
149 time.sleep(1)
150
151
152 print "Arming motors"
153 # Copter should arm in GUIDED mode
154 vehicle.mode = VehicleMode("GUIDED")
155 vehicle.armed = True
156
157 while not vehicle.armed:
158 print " Waiting for arming..."
159 time.sleep(1)
160
161 print "Taking off!"
162 vehicle.simple_takeoff(aTargetAltitude) # Take off to target altitude
163
164 # Wait until the vehicle reaches a safe height before processing the goto (otherwise the command
165 # after Vehicle.simple_takeoff will execute immediately).
166 while True:
167 print " Altitude: ", vehicle.location.global_relative_frame.alt
168 if vehicle.location.global_relative_frame.alt>=aTargetAltitude*0.95: #Trigger just below target alt.
169 print "Reached target altitude"
170 break
171 time.sleep(1)
172
173
174print 'Create a new mission (for current location)'

Callers 1

mission_basic.pyFile · 0.70

Calls 2

VehicleModeClass · 0.90
simple_takeoffMethod · 0.80

Tested by

no test coverage detected