コード例 #1
0
 async def change_board(self, board: FlightController) -> None:
     logger.info(f"Trying to run with '{board.name}'.")
     if not board in BoardDetector.detect():
         raise ValueError(f"Cannot use '{board.name}'. Board not detected.")
     self.set_preferred_board(board)
     await self.kill_ardupilot()
     await self.start_ardupilot()
コード例 #2
0
    async def start_ardupilot(self) -> None:
        try:
            available_boards = BoardDetector.detect()
            if not available_boards:
                raise RuntimeError("No boards available.")
            if len(available_boards) > 1:
                logger.warning(f"More than a single board detected: {available_boards}")

            flight_controller = self.get_board_to_be_used(available_boards)
            logger.info(f"Using {flight_controller.name} flight-controller.")

            if flight_controller.platform == Platform.Navigator:
                self.start_navigator(flight_controller)
            elif flight_controller.platform.type == PlatformType.Serial:
                self.start_serial(flight_controller)
            elif flight_controller.platform == Platform.SITL:
                self.start_sitl(self.current_sitl_frame)
            else:
                raise RuntimeError(f"Invalid board type: {flight_controller}")
        finally:
            self.should_be_running = True
コード例 #3
0
 def run_with_board(self) -> None:
     if not self.start_board(BoardDetector.detect()):
         logger.warning("Flight controller board not detected.")
コード例 #4
0
    def run(self) -> None:
        ArduPilotManager.check_running_as_root()

        while not self.start_board(BoardDetector.detect()):
            print("Flight controller board not detected, will try again.")
            time.sleep(2)
コード例 #5
0
def available_boards() -> Any:
    return BoardDetector.detect()