diff --git a/mavctl/messages/Navigator.py b/mavctl/messages/Navigator.py index ebd6b36..6a84586 100644 --- a/mavctl/messages/Navigator.py +++ b/mavctl/messages/Navigator.py @@ -40,13 +40,28 @@ def arm(self): self.mav.motors_armed_wait() print("MAVCTL: Armed!") - def wait_vehicle_armed(self): + def wait_vehicle_armed(self, timeout = None) -> bool: """ Waits for the vehicle to be armed. See samples directory for examples """ + start_time = time.time() print("MAVCTL: Waiting for vehicle to arm") - self.mav.motors_armed_wait() - print("Armed!") + + if timeout is None: + self.mav.motors_armed_wait() + print("MAVCTL: Armed!") + return True + + else: + while True: + if time.time() - start_time >= timeout: + print("MAVCTL: Waiting for vehicle to arm") + return False + + if self.mav.motors_armed_wait(): + print("MAVCTL: Armed!") + return True + def disarm(self): """