Arms vehicle and fly to aTargetAltitude.
(aTargetAltitude)
| 138 | |
| 139 | |
| 140 | def 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 | |
| 174 | print 'Create a new mission (for current location)' |
no test coverage detected