Of course!
The queue gets created in the construtor for the craft class. Each aircraft is run in it’s own thread to allow for simultaneous control.
The “run” function will connect to the aircraft, then runs an infinite loop (with an exit parameter that can be passed to exit cleanly)
Still in the run function (lines 42 -45 of craft,py) it grabs the thread lock, grabs the action from the queue and then attempts to run it
with self.current_task_lock:
self.current_task = self.loop.create_task(action(self))
try:
self.loop.run_until_complete(self.current_task)
The add action method, simply adds actions to the queue,
def add_action(self, action):
self.tasking.put(action)
and the override action should grab the thread lock, clear the queue, put the emergency action in the queue and then cancel the current action.
def override_action(self,action):
with self.current_task_lock:
self.tasking.queue.clear()
self.tasking.put(action)
#signal to the current task to end early
if self.current_task is not None:
self.current_task.cancel()
The check for None is for the edge case that the queue is empty.
I plan on having a button in my ground control station that when tripped, will tell all the aircraft to land as a safety feature.
Probably and arduino and some prompt tool kit /pyserial magic.