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
self.current_task = self.loop.create_task(action(self))
The add action method, simply adds actions to the queue,
def add_action(self, 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.
#signal to the current task to end early
if self.current_task is not None:
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.