Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added the ability to see command ack #168

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions droneapi/module/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,24 @@ def add(self, cmd):
self.__wp.wploader.add(cmd, comment = 'Added by DroneAPI')
self.__module.vehicle.wpts_dirty = True

def command_ack(self, timeout = 0.5):
#wait indefinitely
if timeout is None:
while self.__module.command_ack is None:
pass
result = self.__module.command_ack
self.__module.command_ack = None #reset cmd_ack
return result

#wait for timeout
start = time.time()
while (time.time() - start) < timeout and self.__module.command_ack is None:
pass
result = self.__module.command_ack
self.__module.command_ack = None #reset cmd_ack
return result


@property
def __wp(self):
return self.__module.module('wp')
Expand Down Expand Up @@ -310,7 +328,6 @@ def __init__(self, module, fn, description):

# DroneAPI might generate many commands, which in turn generate ots of acks and status text, in the interest of speed we ignore processing those messages
try:
self.module.mpstate.rx_blacklist.add('COMMAND_ACK')
self.module.mpstate.rx_blacklist.add('STATUSTEXT')
except:
pass # Silently work with old mavproxies
Expand All @@ -329,7 +346,6 @@ def run(self):
traceback.print_exc()

try:
self.module.mpstate.rx_blacklist.remove('COMMAND_ACK')
self.module.mpstate.rx_blacklist.remove('STATUSTEXT')
except:
pass # Silently work with old mavproxies
Expand Down Expand Up @@ -382,6 +398,8 @@ def __init__(self, mpstate):
self.satellites_visible = None
self.fix_type = None # FIXME support multiple GPSs per vehicle - possibly by using componentId

self.command_ack = None

self.next_thread_num = 0 # Monotonically increasing
self.threads = {} # A map from int ID to thread object

Expand Down Expand Up @@ -472,6 +490,8 @@ def set(chnum, v):
self.mount_roll = m.pointing_b / 100
self.mount_yaw = m.pointing_c / 100
self.__on_change('mount')
elif typ == "COMMAND_ACK":
self.command_ack = m.result


if (self.vehicle is not None) and hasattr(self.vehicle, 'mavrx_callback'):
Expand Down