/simpleMission.py Secret
Last active
August 19, 2021 16:24
Star
You must be signed in to star a gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Import Necessary Packages | |
from dronekit import connect, VehicleMode,LocationGlobalRelative | |
import time | |
def basicTakeOff(altitude): | |
""" | |
Simple function which returns the distance and bearing between two geographic location | |
Inputs: | |
1. altitude - TakeOff Altitude | |
""" | |
vehicle.mode = VehicleMode("GUIDED") | |
vehicle.armed = True | |
time.sleep(2) | |
vehicle.simple_takeoff(altitude) | |
while True: | |
print("Reached Height = ", vehicle.location.global_relative_frame.alt) | |
if vehicle.location.global_relative_frame.alt >= (altitude - 1.5): | |
break | |
time.sleep(1) | |
# Connecting the Vehicle | |
vehicle = connect('udpin:127.0.0.1:14551', baud=115200) | |
# Takeoff the Vehicle | |
takeOffAltitude = 10 | |
basicTakeOff(takeOffAltitude) | |
print("Reached:", takeOffAltitude, " m") | |
# Landing the Vehicle | |
vehicle.mode=VehicleMode('LAND') | |
print("Landing the Vehicle!!!") | |
time.sleep(1) | |
print("Exiting the Code!!!") | |
time.sleep(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment