Skip to content

Instantly share code, notes, and snippets.

@djnugent
Last active June 17, 2016 10:25
Show Gist options
  • Save djnugent/847b9cc80f69de2d6129 to your computer and use it in GitHub Desktop.
Save djnugent/847b9cc80f69de2d6129 to your computer and use it in GitHub Desktop.
Dronekit: Change alt in GUIDED mode
#
# 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