-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
core: autopilot-manager: Add flight_controller module
* Move flight controller / flight controller detector to its own module as preparation for platform spliting
- Loading branch information
1 parent
05c99de
commit b941c8f
Showing
20 changed files
with
134 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
core/services/ardupilot_manager/flight_controller/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from flight_controller.flight_controller import ( | ||
FlightController, | ||
FlightControllerFlags, | ||
Platform, | ||
PlatformType, | ||
) | ||
|
||
__all__ = ["FlightController", "FlightControllerFlags", "Platform", "PlatformType"] |
3 changes: 3 additions & 0 deletions
3
core/services/ardupilot_manager/flight_controller/detector/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from flight_controller.detector.detector import FlightControllerDetector | ||
|
||
__all__ = ["FlightControllerDetector"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
...ight_controller_detector/linux/argonot.py → ...ight_controller/detector/linux/argonot.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
core/services/ardupilot_manager/flight_controller/flight_controller.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
from enum import Enum, auto | ||
from platform import machine | ||
from typing import List, Optional | ||
|
||
from pydantic import BaseModel | ||
|
||
|
||
def get_sitl_platform_name(machine_arch: str) -> str: | ||
"""Get SITL platform name based on machine architecture.""" | ||
|
||
if "arm" not in machine_arch.lower() and "aarch" not in machine_arch.lower(): | ||
return "SITL_x86_64_linux_gnu" | ||
return "SITL_arm_linux_gnueabihf" | ||
|
||
|
||
# TODO: This class can be deprecated once we move to Python 3.11, which introduces the equivalent StrEnum | ||
class LowerStringEnum(str, Enum): | ||
def __str__(self) -> str: | ||
return self.name.lower() | ||
|
||
|
||
class PlatformType(LowerStringEnum): | ||
Serial = auto() | ||
Linux = auto() | ||
SITL = auto() | ||
Unknown = auto() | ||
|
||
|
||
class Platform(str, Enum): | ||
"""Valid Ardupilot platform types. | ||
The Enum values are 1:1 representations of the platforms available on the ArduPilot manifest.""" | ||
|
||
Pixhawk1 = "Pixhawk1" | ||
Pixhawk4 = "Pixhawk4" | ||
Pixhawk6X = "Pixhawk6X" | ||
Pixhawk6C = "Pixhawk6C" | ||
CubeOrange = "CubeOrange" | ||
GenericSerial = "GenericSerial" | ||
Navigator = "navigator" | ||
Argonot = "argonot" | ||
SITL = get_sitl_platform_name(machine()) | ||
|
||
@property | ||
def type(self) -> PlatformType: | ||
platform_types = { | ||
Platform.Pixhawk1: PlatformType.Serial, | ||
Platform.Pixhawk4: PlatformType.Serial, | ||
Platform.Pixhawk6X: PlatformType.Serial, | ||
Platform.Pixhawk6C: PlatformType.Serial, | ||
Platform.CubeOrange: PlatformType.Serial, | ||
Platform.GenericSerial: PlatformType.Serial, | ||
Platform.Navigator: PlatformType.Linux, | ||
Platform.Argonot: PlatformType.Linux, | ||
Platform.SITL: PlatformType.SITL, | ||
} | ||
return platform_types.get(self, PlatformType.Unknown) | ||
|
||
|
||
class FlightControllerFlags(str, Enum): | ||
"""Flags for the Flight-controller class.""" | ||
|
||
is_bootloader = "is_bootloader" | ||
|
||
|
||
class FlightController(BaseModel): | ||
"""Flight-controller board.""" | ||
|
||
name: str | ||
manufacturer: Optional[str] | ||
platform: Platform | ||
path: Optional[str] | ||
flags: List[FlightControllerFlags] = [] | ||
|
||
@property | ||
def type(self) -> PlatformType: | ||
return self.platform.type |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.