Last active
June 17, 2016 10:25
-
-
Save djnugent/847b9cc80f69de2d6129 to your computer and use it in GitHub Desktop.
Dronekit: Change alt in GUIDED mode
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
# | |
# This example shows how to use DroneKit-Python to change the vehicles altitude | |
#Usage: api start ChangeAlt.py | |
from pymavlink import mavutil | |
# First get an instance of the API endpoint | |
api = local_connect() | |
# Get the connected vehicle (currently only one vehicle can be returned). | |
v = api.get_vehicles()[0] | |
if(v.mode.name == 'GUIDED' and v.armed == True): | |
loc = v.location #get current location | |
loc.alt = loc.alt + 10 #add 10 meters | |
v.commands.goto(loc) # send command | |
v.flush() #make sure it gets sent | |
else: | |
print "Not armed or in GUIDED mode" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment