Skip to content

Commit f6a1d18

Browse files
committed
core: autopilot-manager: Add flight_controller module
* Move flight controller / flight controller detector to its own module as preparation for platform spliting
1 parent 9502170 commit f6a1d18

File tree

20 files changed

+134
-123
lines changed

20 files changed

+134
-123
lines changed

core/services/ardupilot_manager/api/v1/routers/index.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818

1919
from autopilot_manager import AutoPilotManager
2020
from exceptions import InvalidFirmwareFile
21-
from typedefs import Firmware, FlightController, Parameters, Serial, SITLFrame, Vehicle
21+
from flight_controller import FlightController
22+
from typedefs import Firmware, Parameters, Serial, SITLFrame, Vehicle
2223

2324
index_router_v1 = APIRouter(
2425
tags=["index_v1"],

core/services/ardupilot_manager/autopilot_manager.py

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,19 @@
1818
NoPreferredBoardSet,
1919
)
2020
from firmware.FirmwareManagement import FirmwareManager
21-
from flight_controller_detector.Detector import Detector as BoardDetector
22-
from flight_controller_detector.linux.linux_boards import LinuxFlightController
23-
from mavlink_proxy.Endpoint import Endpoint, EndpointType
24-
from mavlink_proxy.exceptions import EndpointAlreadyExists
25-
from mavlink_proxy.Manager import Manager as MavlinkManager
26-
from settings import Settings
27-
from typedefs import (
28-
Firmware,
21+
from flight_controller import (
2922
FlightController,
3023
FlightControllerFlags,
31-
Parameters,
3224
Platform,
3325
PlatformType,
34-
Serial,
35-
SITLFrame,
36-
Vehicle,
3726
)
27+
from flight_controller.detector import FlightControllerDetector
28+
from flight_controller.detector.linux.linux_boards import LinuxFlightController
29+
from mavlink_proxy.Endpoint import Endpoint, EndpointType
30+
from mavlink_proxy.exceptions import EndpointAlreadyExists
31+
from mavlink_proxy.Manager import Manager as MavlinkManager
32+
from settings import Settings
33+
from typedefs import Firmware, Parameters, Serial, SITLFrame, Vehicle
3834

3935

4036
class AutoPilotManager(metaclass=Singleton):
@@ -309,7 +305,7 @@ def get_available_routers(self) -> List[str]:
309305
return [router.name() for router in self.mavlink_manager.available_interfaces()]
310306

311307
async def start_sitl(self) -> None:
312-
self._current_board = BoardDetector.detect_sitl()
308+
self._current_board = FlightControllerDetector.detect_sitl()
313309
if not self.firmware_manager.is_firmware_installed(self._current_board):
314310
self.firmware_manager.install_firmware_from_params(Vehicle.Sub, self._current_board)
315311
frame = self.load_sitl_frame()
@@ -419,7 +415,7 @@ async def start_mavlink_manager(self, device: Endpoint) -> None:
419415

420416
@staticmethod
421417
async def available_boards(include_bootloaders: bool = False) -> List[FlightController]:
422-
all_boards = await BoardDetector.detect(True)
418+
all_boards = await FlightControllerDetector.detect(True)
423419
if include_bootloaders:
424420
return all_boards
425421
return [board for board in all_boards if FlightControllerFlags.is_bootloader not in board.flags]

core/services/ardupilot_manager/firmware/FirmwareDownload.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
NoCandidate,
2222
NoVersionAvailable,
2323
)
24-
from typedefs import FirmwareFormat, Platform, PlatformType, Vehicle
24+
from flight_controller import Platform, PlatformType
25+
from typedefs import FirmwareFormat, Vehicle
2526

2627
# TODO: This should be not necessary
2728
# Disable SSL verification

core/services/ardupilot_manager/firmware/FirmwareInstall.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
from exceptions import FirmwareInstallFail, InvalidFirmwareFile, UnsupportedPlatform
1414
from firmware.FirmwareDownload import FirmwareDownloader
1515
from firmware.FirmwareUpload import FirmwareUploader
16-
from typedefs import FirmwareFormat, FlightController, Platform, PlatformType
16+
from flight_controller import FlightController, Platform, PlatformType
17+
from typedefs import FirmwareFormat
1718

1819

1920
def get_board_id(platform: Platform) -> int:

core/services/ardupilot_manager/firmware/FirmwareManagement.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,8 @@
1515
)
1616
from firmware.FirmwareDownload import FirmwareDownloader
1717
from firmware.FirmwareInstall import FirmwareInstaller
18-
from typedefs import (
19-
Firmware,
20-
FirmwareFormat,
21-
FlightController,
22-
Parameters,
23-
Platform,
24-
PlatformType,
25-
Vehicle,
26-
)
18+
from flight_controller import FlightController, Platform, PlatformType
19+
from typedefs import Firmware, FirmwareFormat, Parameters, Vehicle
2720

2821

2922
class FirmwareManager:

core/services/ardupilot_manager/firmware/test_FirmwareDownload.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
import pytest
55

66
from firmware.FirmwareDownload import FirmwareDownloader
7-
from typedefs import Platform, Vehicle
7+
from flight_controller import Platform
8+
from typedefs import Vehicle
89

910

1011
def test_static() -> None:

core/services/ardupilot_manager/firmware/test_FirmwareInstall.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
from exceptions import InvalidFirmwareFile
77
from firmware.FirmwareDownload import FirmwareDownloader
88
from firmware.FirmwareInstall import FirmwareInstaller
9-
from typedefs import FlightController, Platform, Vehicle
9+
from flight_controller import FlightController, Platform
10+
from typedefs import Vehicle
1011

1112

1213
def test_firmware_validation() -> None:
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from flight_controller.flight_controller import (
2+
FlightController,
3+
FlightControllerFlags,
4+
Platform,
5+
PlatformType,
6+
)
7+
8+
__all__ = ["FlightController", "FlightControllerFlags", "Platform", "PlatformType"]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from flight_controller.detector.detector import FlightControllerDetector
2+
3+
__all__ = ["FlightControllerDetector"]

core/services/ardupilot_manager/flight_controller_detector/board_identification.py renamed to core/services/ardupilot_manager/flight_controller/detector/board_identification.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
from pydantic import BaseModel
55

6-
from typedefs import Platform
6+
from flight_controller import Platform
77

88

99
class SerialAttr(str, Enum):

0 commit comments

Comments
 (0)