Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1077,7 +1077,7 @@ def _validate_uploaded_parameters(self, selected_params: dict) -> list[str]:
self._flight_controller.fc_parameters[param_name],
)
param_upload_error.append(param_name)
if param_name not in self._flight_controller.fc_parameters:
if param_name not in self._flight_controller.fc_parameters and param is not None:
logging_error(
_("Parameter %s upload to the flight controller failed. Expected: %f, Actual: N/A"),
param_name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ def update_json_structure(
"Specifications": {
"TOW min Kg": 1,
"TOW max Kg": 1,
"Frame class": "Undefined",
}
},
"Flight Controller": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from typing import Any, Optional

from ardupilot_methodic_configurator import _
from ardupilot_methodic_configurator.backend_flightcontroller_business_logic import get_frame_info
from ardupilot_methodic_configurator.battery_cell_voltages import (
BATTERY_CELL_VOLTAGE_TYPES,
BATTERY_DEFAULT_CHEMISTRY,
Expand All @@ -36,6 +37,7 @@
SERVO_FUNCTION_ESC_CONTROL,
ComponentDataModelValidation,
get_esc_connection_sub_dict,
get_frame_class_sub_dict,
)


Expand Down Expand Up @@ -183,6 +185,14 @@ def process_fc_parameters(
self._verify_dict_is_uptodate(doc, get_esc_connection_sub_dict(fw_type), "MOT_PWM_TYPE", "values")
self._verify_dict_is_uptodate(doc, RC_PROTOCOLS_DICT, "RC_PROTOCOLS", "Bitmask")

# Process frame information if FRAME_CLASS is present in FC parameters
if "FRAME_CLASS" in fc_parameters:
frame_class, _ = get_frame_info(fc_parameters)
self.set_component_value(
("Frame", "Specifications", "Frame class"),
get_frame_class_sub_dict(fw_type).get(frame_class, "Undefined"),
Comment thread
amilcarlucas marked this conversation as resolved.
)

# Process parameters in sequence
self._set_gnss_type_from_fc_parameters(fc_parameters)
esc_is_serial = self._set_serial_type_from_fc_parameters(fc_parameters)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,46 @@ def get_esc_connection_sub_dict(
"65536": {"type": RC_PORTS + SERIAL_PORTS, "protocol": "MAVRadio"}, # Bit 16
}

FRAME_CLASS_DICT: dict[str, dict[int, str]] = {
"ArduCopter": {
0: "Undefined",
1: "Quad",
2: "Hexa",
3: "Octa",
4: "OctaQuad",
5: "Y6",
6: "Heli",
7: "Tri",
8: "SingleCopter",
9: "CoaxCopter",
10: "BiCopter",
11: "Heli_Dual",
12: "DodecaHexa",
13: "HeliQuad",
14: "Deca",
15: "Scripting Matrix",
16: "6DoF Scripting",
17: "Dynamic Scripting Matrix",
},
"Heli": {
6: "Heli",
11: "Heli_Dual",
13: "HeliQuad",
},
"Rover": {
0: "Undefined",
1: "Rover",
2: "Boat",
3: "BalanceBot",
},
"ArduPlane": {},
}
Comment thread
amilcarlucas marked this conversation as resolved.


def get_frame_class_sub_dict(vehicle_type: str) -> dict[int, str]:
"""Return the vehicle-type-specific frame class mapping from FRAME_CLASS_DICT."""
return FRAME_CLASS_DICT.get(vehicle_type, FRAME_CLASS_DICT["ArduCopter"])
Comment on lines +319 to +357


class ComponentDataModelValidation(ComponentDataModelBase):
"""
Expand Down
2 changes: 2 additions & 0 deletions ardupilot_methodic_configurator/vehicle_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def translatable_strings() -> None:
_vehicle_components_strings = _("Flight Controller")
_vehicle_components_strings = _("Format version")
_vehicle_components_strings = _("Frame")
_vehicle_components_strings = _("Frame class")
_vehicle_components_strings = _("GNSS Receiver")
_vehicle_components_strings = _("MCU Series")
_vehicle_components_strings = _("Manufacturer")
Expand Down Expand Up @@ -90,6 +91,7 @@ def translatable_descriptions() -> None: # noqa: PLR0915 # pylint: disable=too-
_vehicle_components_descriptions = _("Flight controller component that runs the ArduPilot firmware")
_vehicle_components_descriptions = _("Flight controller firmware information")
_vehicle_components_descriptions = _("Flight controller that runs ArduPilot firmware")
_vehicle_components_descriptions = _("Frame class/category (e.g., Quad, Hexa, Octa, etc.)")
_vehicle_components_descriptions = _("Global Navigation Satellite System receiver for positioning")
_vehicle_components_descriptions = _("How this component connects to the flight controller")
_vehicle_components_descriptions = _("Information about the firmware running on a component")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@
"TOW max Kg": {
"type": "number",
"description": "Maximum take-off weight in kilograms"
},
"Frame class": {
"type": "string",
"description": "Frame class/category (e.g., Quad, Hexa, Octa, etc.)"
Comment thread
amilcarlucas marked this conversation as resolved.
Comment thread
amilcarlucas marked this conversation as resolved.
}
},
"description": "Technical specifications of the vehicle frame"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
},
"Specifications": {
"TOW min Kg": 320,
"TOW max Kg": 500
"TOW max Kg": 500,
"Frame class": "OctaQuad"
},
"Notes": "Frame is custom, X type frame. Arm length is 2650mm."
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
},
"Specifications": {
"TOW min Kg": 7.0,
"TOW max Kg": 12.0
"TOW max Kg": 12.0,
"Frame class": "Quad"
},
"Notes": ""
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
},
"Specifications": {
"TOW min Kg": 0.9,
"TOW max Kg": 0.9
"TOW max Kg": 0.9,
"Frame class": "Quad"
},
"Notes": ""
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
},
"Specifications": {
"TOW min Kg": 0.1,
"TOW max Kg": 0.1
"TOW max Kg": 0.1,
"Frame class": "Scripting Matrix"
},
"Notes": ""
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
},
"Specifications": {
"TOW min Kg": 1.3,
"TOW max Kg": 2.0
"TOW max Kg": 2.0,
"Frame class": "Quad"
},
"Notes": "5\" Props"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
},
"Specifications": {
"TOW min Kg": 0.6,
"TOW max Kg": 0.6
"TOW max Kg": 0.6,
"Frame class": "Quad"
},
"Notes": "TOW in this case a taken ideal, and not calculated including gimbal."
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
},
"Specifications": {
"TOW min Kg": 1.09,
"TOW max Kg": 2.11
"TOW max Kg": 2.11,
"Frame class": "Quad"
},
"Notes": "Frame is X500 type. Look on holybro site for more specifications"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
},
"Specifications": {
"TOW min Kg": 1.09,
"TOW max Kg": 2.11
"TOW max Kg": 2.11,
"Frame class": "Quad"
},
"Notes": "Frame is X500 V2 type. Look on holybro site for more specifications"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
},
"Specifications": {
"TOW min Kg": 5.6,
"TOW max Kg": 7.6
"TOW max Kg": 7.6,
"Frame class": "Quad"
},
"Notes": "Frame is X650 V2 type. Look on holybro site for more specifications"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
},
"Specifications": {
"TOW min Kg": 35,
"TOW max Kg": 50
"TOW max Kg": 50,
"Frame class": "Quad"
},
"Notes": "customized drone"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
},
"Specifications": {
"TOW min Kg": 56,
"TOW max Kg": 90
"TOW max Kg": 90,
"Frame class": "Quad"
},
"Notes": "z50 eft frame"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
},
"Specifications": {
"TOW min Kg": 0.7,
"TOW max Kg": 0.7
"TOW max Kg": 0.7,
"Frame class": "Quad"
},
"Notes": ""
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
},
"Specifications": {
"TOW min Kg": 2.884,
"TOW max Kg": 2.884
"TOW max Kg": 2.884,
"Frame class": "Quad"
},
"Notes": "10-14\" Props"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
},
"Specifications": {
"TOW min Kg": 1.6,
"TOW max Kg": 5.39
"TOW max Kg": 5.39,
"Frame class": "Hexa"
},
"Notes": "With or without 1 Gallon of water (for spraying my small garden/vineyard)"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
},
"Specifications": {
"TOW min Kg": 5,
"TOW max Kg": 7
"TOW max Kg": 7,
"Frame class": "Quad"
},
"Notes": "A frame with 960mm diameter (motor to notor) using T-Motor MN7005(7206) propulsion sets for 25mm tube arms"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
},
"Specifications": {
"TOW min Kg": 20,
"TOW max Kg": 50
"TOW max Kg": 50,
"Frame class": "Quad"
},
"Notes": "Frame is custom, X type frame, the middle is welded. Arm length is 1950mm."
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
},
"Specifications": {
"TOW min Kg": 0.6,
"TOW max Kg": 0.6
"TOW max Kg": 0.6,
"Frame class": "Quad"
},
"Notes": "A small 3'' ducted frame"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
},
"Specifications": {
"TOW min Kg": 0.6,
"TOW max Kg": 0.6
"TOW max Kg": 0.6,
"Frame class": "Quad"
},
"Notes": "A small 3'' ducted frame"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
},
"Specifications": {
"TOW min Kg": 0.6,
"TOW max Kg": 0.6
"TOW max Kg": 0.6,
"Frame class": "Quad"
},
"Notes": "A small 3'' ducted frame"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
},
"Specifications": {
"TOW min Kg": 0.6,
"TOW max Kg": 0.6
"TOW max Kg": 0.6,
"Frame class": "Quad"
},
"Notes": "A small 3'' ducted frame"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
},
"Specifications": {
"TOW min Kg": 0.1,
"TOW max Kg": 0.1
"TOW max Kg": 0.1,
"Frame class": "Undefined"
},
"Notes": ""
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
},
"Specifications": {
"TOW min Kg": 0.1,
"TOW max Kg": 0.1
"TOW max Kg": 0.1,
"Frame class": "Undefined"
},
"Notes": ""
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
},
"Specifications": {
"TOW min Kg": 5,
"TOW max Kg": 7
"TOW max Kg": 7,
"Frame class": "Undefined"
},
"Notes": ""
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
},
"Specifications": {
"TOW min Kg": 1,
"TOW max Kg": 1
"TOW max Kg": 1,
"Frame class": "Heli"
},
"Notes": "This was done with the Basic M4 Combo kit, not the max"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
},
"Specifications": {
"TOW min Kg": 0.6,
"TOW max Kg": 0.6
"TOW max Kg": 0.6,
"Frame class": "Rover"
},
"Notes": ""
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
},
"Specifications": {
"TOW min Kg": 0.5,
"TOW max Kg": 0.5
"TOW max Kg": 0.5,
"Frame class": "Rover"
},
"Notes": ""
},
Expand Down
11 changes: 11 additions & 0 deletions tests/test_data_model_vehicle_components_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,17 @@ def test_system_imports_esc_aio_configuration(self, realistic_model) -> None:
assert esc_type == "AIO"
assert esc_protocol == "DShot600"

def test_user_can_import_frame_class_from_fc(self, realistic_model) -> None:
"""Given FRAME_CLASS from FC, set Frame.Specifications.Class."""
fc_parameters = {"FRAME_CLASS": 3, "MOT_PWM_TYPE": 6, "SERVO1_FUNCTION": 0}
doc = {"MOT_PWM_TYPE": {"values": {"6": "DShot600"}}}

with patch.object(realistic_model, "_verify_dict_is_uptodate", return_value=True):
realistic_model.process_fc_parameters(fc_parameters, doc)

frame_class = realistic_model.get_component_value(("Frame", "Specifications", "Frame class"))
assert frame_class == "Octa"

def test_user_can_import_esc_connection_and_telemetry_from_serial_fc(self, realistic_model) -> None:
"""
Import ESC serial config into FC->ESC Connection and ESC->FC Telemetry.
Expand Down
Loading
Loading