Skip to content

Commit

Permalink
ArdupilotManager: add navigator64 support
Browse files Browse the repository at this point in the history
  • Loading branch information
Williangalvani committed Oct 3, 2024
1 parent 08f7e38 commit e61b602
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 3 deletions.
5 changes: 5 additions & 0 deletions core/services/ardupilot_manager/ArduPilotManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,11 @@ async def start_linux_board(self, board: LinuxFlightController) -> None:
pathlib.Path("/root/blueos-files/ardupilot-manager/default/ardupilot_navigator"),
board,
)
elif board.platform == Platform.Navigator64:
self.firmware_manager.install_firmware_from_file(
pathlib.Path("/root/blueos-files/ardupilot-manager/default/ardupilot_navigator64"),
board,
)
else:
raise NoDefaultFirmwareAvailable(
f"No firmware installed for '{board.platform}' and no default firmware available. Please install the firmware manually."
Expand Down
5 changes: 5 additions & 0 deletions core/services/ardupilot_manager/firmware/FirmwareInstall.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from ardupilot_fw_decoder import BoardSubType, BoardType, Decoder
from elftools.elf.elffile import ELFFile
from loguru import logger

from exceptions import FirmwareInstallFail, InvalidFirmwareFile, UnsupportedPlatform
from firmware.FirmwareDownload import FirmwareDownloader
Expand Down Expand Up @@ -43,6 +44,7 @@ def get_correspondent_decoder_platform(current_platform: Platform) -> Union[Boar
Platform.SITL: BoardType.SITL,
Platform.Navigator: BoardSubType.LINUX_NAVIGATOR,
Platform.Argonot: BoardSubType.LINUX_NAVIGATOR,
Platform.Navigator64: BoardSubType.LINUX_NAVIGATOR,
}
return correspondent_decoder_platform.get(current_platform, BoardType.EMPTY)

Expand Down Expand Up @@ -97,6 +99,9 @@ def _validate_elf(firmware_path: pathlib.Path, platform: Platform) -> None:
firm_board = BoardType(firm_decoder.fwversion.board_type)
firm_sub_board = BoardSubType(firm_decoder.fwversion.board_subtype)
current_decoder_platform = get_correspondent_decoder_platform(platform)
logger.debug(
f"firm_board: {firm_board}, firm_sub_board: {firm_sub_board}, current_decoder_platform: {current_decoder_platform}"
)
if current_decoder_platform not in [firm_board, firm_sub_board]:
raise InvalidFirmwareFile(
(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import List
import platform
from typing import Any, List

from commonwealth.utils.commands import load_file

Expand All @@ -7,9 +8,15 @@


class Navigator(LinuxFlightController):
name = "Navigator"
manufacturer = "Blue Robotics"
platform = Platform.Navigator

def __init__(self, **data: Any) -> None:
name = "Navigator"
plat = Platform.Navigator
if platform.machine() == "aarch64":
name = "Navigator64"
plat = Platform.Navigator64
super().__init__(**data, name=name, platform=plat)

def is_pi5(self) -> bool:
with open("/proc/cpuinfo", "r", encoding="utf-8") as f:
Expand Down
5 changes: 5 additions & 0 deletions core/services/ardupilot_manager/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
"ardupilot_navigator",
"https://firmware.ardupilot.org/Sub/stable-4.1.2/navigator/ardusub",
),
StaticFile(
defaults_folder,
"ardupilot_navigator",
"https://firmware.ardupilot.org/Sub/latest/navigator64/ardusub",
),
StaticFile(defaults_folder, "ardupilot_pixhawk1", "https://firmware.ardupilot.org/Sub/latest/Pixhawk1/ardusub.apj"),
StaticFile(defaults_folder, "ardupilot_pixhawk4", "https://firmware.ardupilot.org/Sub/latest/Pixhawk4/ardusub.apj"),
]
Expand Down
2 changes: 2 additions & 0 deletions core/services/ardupilot_manager/typedefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ class Platform(str, Enum):
CubeOrange = "CubeOrange"
GenericSerial = "GenericSerial"
Navigator = "navigator"
Navigator64 = "navigator64"
Argonot = "argonot"
SITL = get_sitl_platform_name(machine())

Expand All @@ -123,6 +124,7 @@ def type(self) -> PlatformType:
Platform.CubeOrange: PlatformType.Serial,
Platform.GenericSerial: PlatformType.Serial,
Platform.Navigator: PlatformType.Linux,
Platform.Navigator64: PlatformType.Linux,
Platform.Argonot: PlatformType.Linux,
Platform.SITL: PlatformType.SITL,
}
Expand Down

0 comments on commit e61b602

Please sign in to comment.