Created
June 18, 2015 21:44
-
-
Save djnugent/edfbab1b2458d5773490 to your computer and use it in GitHub Desktop.
Using command_ack in dronekit
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 | |
# | |
import time | |
from pymavlink import mavutil | |
def process_result(result): | |
if result is None: | |
print "command_ack timed out" | |
if result == mavutil.mavlink.MAV_RESULT_ACCEPTED: | |
print "accepted" | |
elif result == mavutil.mavlink.MAV_RESULT_TEMPORARILY_REJECTED: | |
print "temporarily rejected" | |
elif result == mavutil.mavlink.MAV_RESULT_DENIED: | |
print "denied" | |
elif result == mavutil.mavlink.MAV_RESULT_UNSUPPORTED: | |
print "unsupported" | |
elif result == mavutil.mavlink.MAV_RESULT_FAILED: | |
print "failed" | |
# First get an instance of the API endpoint | |
api = local_connect() | |
# Get the connected vehicle (currently only one vehicle can be returned). | |
veh = api.get_vehicles()[0] | |
veh.commands.takeoff(20) | |
#should succeed if we are armed, landed, and in GUIDED mode | |
result = veh.commands.command_ack() | |
process_result(result) | |
#should timeout since we never sent a second command | |
result = veh.commands.command_ack(2) #example of a timeout longer than 0.5 seconds | |
process_result(result) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment