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 @@ -66,7 +66,7 @@ jobs:
uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: 'Auto-update vehicle components translatable strings'
commit-message: 'docs(component editor): Auto-update vehicle components translatable strings'
title: 'Update vehicle components translatable strings'
body: |
This PR updates the vehicle_components.py file with new translatable strings.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
SPDX-License-Identifier: GPL-3.0-or-later
"""

import contextlib
from dataclasses import dataclass

# from logging import debug as logging_debug
Expand Down Expand Up @@ -463,7 +462,7 @@ def _set_battery_type_from_fc_parameters(self, fc_parameters: dict[str, float])
final_chemistry = BATTERY_DEFAULT_CHEMISTRY

specs = BatteryVoltageSpecs(
estimated_cell_count=self._estimate_battery_cell_count(fc_parameters),
estimated_cell_count=self._estimate_battery_cell_count(fc_parameters, final_chemistry),
limit_min=BatteryCell.limit_min_voltage(final_chemistry),
limit_max=BatteryCell.limit_max_voltage(final_chemistry),
detected_chemistry=final_chemistry,
Expand Down Expand Up @@ -586,80 +585,82 @@ def _detect_battery_chemistry_from_voltages(

return None

def _estimate_cells_from_voltage_param(
self, param_name: str, param_value: float, volt_per_cell_spec: str
def _estimate_cells_from_voltage_param_default(
self, param_name: str, param_value: float, volt_per_cell_spec: str, chemistry: str
) -> Optional[int]:
"""
Estimate cell count from a voltage parameter.
Estimate cell count from a voltage parameter using the chemistry-specific default per-cell voltages.

Args:
param_name: Name of the parameter for logging
param_value: Value of the voltage parameter
volt_per_cell_spec: Battery specification name (e.g., "Volt per cell max")
chemistry: Battery chemistry to use for default per-cell voltages

Returns:
Estimated cell count or None if estimation failed

"""
volt_per_cell_value = self.get_component_value(("Battery", "Specifications", volt_per_cell_spec))

volt_per_cell = 0.0
if isinstance(volt_per_cell_value, (int, float, str)) and volt_per_cell_value:
with contextlib.suppress(ValueError, TypeError):
volt_per_cell = float(volt_per_cell_value)

if volt_per_cell <= 0:
logging_warning(_("Volt per cell value for %s is zero or invalid: %s"), volt_per_cell_spec, volt_per_cell_value)
# Get default per-cell voltage for this chemistry and spec
volt_per_cell = BatteryCell.recommended_cell_voltage(chemistry, volt_per_cell_spec)
if isnan(volt_per_cell) or volt_per_cell <= 0:
logging_error(_("No recommended voltage for %s %s"), chemistry, volt_per_cell_spec)
return None

try:
voltage = float(param_value)
if voltage > 0:
return round(voltage / volt_per_cell)
except (ValueError, TypeError, ZeroDivisionError) as e:
if voltage <= 0:
logging_warning(_("Voltage value for %s is zero or invalid: %s"), param_name, param_value)
return None
estimated_cells = round(voltage / volt_per_cell)
# Validate reasonable range
if 1 <= estimated_cells <= 50: # Reasonable range for battery packs
return estimated_cells
logging_warning(_("Estimated cell count %d from %s seems unreasonable"), estimated_cells, param_name)
except (ValueError, TypeError) as e:
logging_error(_("Error processing %s parameter: %s"), param_name, str(e))

return None

def _estimate_battery_cell_count(self, fc_parameters: dict[str, float]) -> int:
def _estimate_battery_cell_count(self, fc_parameters: dict[str, float], chemistry: str = BATTERY_DEFAULT_CHEMISTRY) -> int:
"""
Estimate battery cell count from voltage parameters.

Uses MOT_BAT_VOLT_MAX, BATT_LOW_VOLT, BATT_CRT_VOLT, BATT_ARM_VOLT, or MOT_BAT_VOLT_MIN
along with current volt-per-cell values to estimate the number of cells.
along with default volt-per-cell values for the given chemistry to estimate the number of cells.

Args:
fc_parameters: Dictionary of flight controller parameters
chemistry: Battery chemistry to use for default per-cell voltages

"""
# Try to estimate cell count from available voltage parameters
# Priority: MOT_BAT_VOLT_MAX > BATT_LOW_VOLT > BATT_CRT_VOLT > BATT_ARM_VOLT > MOT_BAT_VOLT_MIN
estimated_cells = None

if "MOT_BAT_VOLT_MAX" in fc_parameters:
estimated_cells = self._estimate_cells_from_voltage_param(
"MOT_BAT_VOLT_MAX", fc_parameters["MOT_BAT_VOLT_MAX"], "Volt per cell max"
estimated_cells = self._estimate_cells_from_voltage_param_default(
"MOT_BAT_VOLT_MAX", fc_parameters["MOT_BAT_VOLT_MAX"], "Volt per cell max", chemistry
)

if estimated_cells is None and "BATT_LOW_VOLT" in fc_parameters:
estimated_cells = self._estimate_cells_from_voltage_param(
"BATT_LOW_VOLT", fc_parameters["BATT_LOW_VOLT"], "Volt per cell low"
estimated_cells = self._estimate_cells_from_voltage_param_default(
"BATT_LOW_VOLT", fc_parameters["BATT_LOW_VOLT"], "Volt per cell low", chemistry
)

if estimated_cells is None and "BATT_CRT_VOLT" in fc_parameters:
estimated_cells = self._estimate_cells_from_voltage_param(
"BATT_CRT_VOLT", fc_parameters["BATT_CRT_VOLT"], "Volt per cell crit"
estimated_cells = self._estimate_cells_from_voltage_param_default(
"BATT_CRT_VOLT", fc_parameters["BATT_CRT_VOLT"], "Volt per cell crit", chemistry
)

# lower prio, because less often used
if estimated_cells is None and "BATT_ARM_VOLT" in fc_parameters:
estimated_cells = self._estimate_cells_from_voltage_param(
"BATT_ARM_VOLT", fc_parameters["BATT_ARM_VOLT"], "Volt per cell arm"
estimated_cells = self._estimate_cells_from_voltage_param_default(
"BATT_ARM_VOLT", fc_parameters["BATT_ARM_VOLT"], "Volt per cell arm", chemistry
)

if estimated_cells is None and "MOT_BAT_VOLT_MIN" in fc_parameters:
estimated_cells = self._estimate_cells_from_voltage_param(
"MOT_BAT_VOLT_MIN", fc_parameters["MOT_BAT_VOLT_MIN"], "Volt per cell min"
estimated_cells = self._estimate_cells_from_voltage_param_default(
"MOT_BAT_VOLT_MIN", fc_parameters["MOT_BAT_VOLT_MIN"], "Volt per cell min", chemistry
)

# If no estimation succeeded, all volt per cell values must be invalid
Expand Down
4 changes: 4 additions & 0 deletions ardupilot_methodic_configurator/vehicle_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ def translatable_descriptions() -> None: # noqa: PLR0915 # pylint: disable=too-
_vehicle_components_descriptions = _("Component that monitors battery voltage and current")
_vehicle_components_descriptions = _("Connection type (e.g., UART, I2C, SPI)")
_vehicle_components_descriptions = _("Critical voltage per cell below which damage may occur (e.g., 3.3V)")
_vehicle_components_descriptions = _("Data path from flight controller to ESC")
_vehicle_components_descriptions = _("Details about how a component connects to the flight controller")
_vehicle_components_descriptions = _("ESC firmware information")
_vehicle_components_descriptions = _("Electronic Speed Controller component with (optional) telemetry")
Comment on lines +83 to +86
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vehicle_components.py is auto-generated to provide gettext extraction for strings used in vehicle_components.json. This PR introduces new JSON keys like "FC->ESC Connection" and "ESC->FC Telemetry" (and uses them in the UI/data model), but they are not present in translatable_strings(), so they won’t be extracted for translation. Re-run the generator (or update it) so these new key strings are included in translatable_strings().

Copilot uses AI. Check for mistakes.
_vehicle_components_descriptions = _("Electronic Speed Controller for the motors")
_vehicle_components_descriptions = _("Flight controller component that runs the ArduPilot firmware")
_vehicle_components_descriptions = _("Flight controller firmware information")
Expand Down Expand Up @@ -118,6 +121,7 @@ def translatable_descriptions() -> None: # noqa: PLR0915 # pylint: disable=too-
_vehicle_components_descriptions = _("Technical specifications of the motors")
_vehicle_components_descriptions = _("Technical specifications of the propellers")
_vehicle_components_descriptions = _("Technical specifications of the vehicle frame")
_vehicle_components_descriptions = _("Telemetry path from ESC to flight controller (if applicable)")
_vehicle_components_descriptions = _("Transmitter part of the remote control system")
_vehicle_components_descriptions = _("Type of firmware")
_vehicle_components_descriptions = _("Version number of the firmware")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ BATT_LOW_VOLT,79.2 # Low failsafe voltage x nr. of cells
BATT_MONITOR,4 # Selected in component editor window
BATT_VOLT_MULT,12.17
MOT_BAT_VOLT_MAX,92.4 # Scale the PIDs up when battery voltage is below this threshold
MOT_BAT_VOLT_MIN,78.1 # Scale the PIDs up when battery voltage is above this threshold
MOT_BAT_VOLT_MIN,67.199 # Scale the PIDs up when battery voltage is above this threshold
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"Volt per cell arm": 3.9455,
"Volt per cell low": 3.6,
"Volt per cell crit": 3.55,
"Volt per cell min": 3.55,
"Volt per cell min": 3.0545,
"Number of cells": 22,
"Capacity mAh": 30000
},
Expand All @@ -77,10 +77,14 @@
"Type": "",
"Version": ""
},
"FC Connection": {
"FC->ESC Connection": {
"Type": "Main Out",
"Protocol": "Normal"
},
"ESC->FC Telemetry": {
"Type": "None",
"Protocol": "None"
},
"Notes": ""
},
"Motors": {
Expand Down Expand Up @@ -119,7 +123,7 @@
"Version": "1.13.2"
},
"FC Connection": {
"Type": "SERIAL3",
"Type": "CAN1",
"Protocol": "DroneCAN"
},
"Notes": "uBlox M8P GNSS with a patch antenna."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,14 @@
"Type": "hobbywing",
"Version": ""
},
"FC Connection": {
"FC->ESC Connection": {
"Type": "Main Out",
"Protocol": "Normal"
},
"ESC->FC Telemetry": {
"Type": "None",
"Protocol": "None"
},
"Notes": "ESCs are integrated in the motor arm sets"
},
"Motors": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ BATT_LOW_VOLT,21.6 # Low failsafe voltage x nr. of cells
BATT_MONITOR,4 # Selected in component editor window
BATT_VOLT_MULT,11 # Use a power source with a voltage close to BATT_LOW_VOLT measure with a calibrated voltimeter and adapt this parameter so that the telemetry voltage reading matches it
MOT_BAT_VOLT_MAX,25.2 # Scale the PIDs up when battery voltage is below this threshold
MOT_BAT_VOLT_MIN,21.3 # Scale the PIDs up when battery voltage is above this threshold
MOT_BAT_VOLT_MIN,19.8 # Scale the PIDs up when battery voltage is above this threshold
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
BRD_SAFETY_DEFLT,0 # Matek H743 Slim has no safety switch
GPS_GNSS_MODE,1 # limit the constalations to ensure an update rate higher than 5Hz
GPS_GNSS_MODE,1 # limit the constellations to ensure an update rate higher than 5Hz
GPS_POS1_X,0 # GNSS antenna pahse center location relative to CG
GPS_POS1_Y,0 # GNSS antenna pahse center location relative to CG
GPS_POS1_Z,0 # GNSS antenna pahse center location relative to CG
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"Volt per cell arm": 3.9333,
"Volt per cell low": 3.6,
"Volt per cell crit": 3.55,
"Volt per cell min": 3.55,
"Volt per cell min": 3.3,
"Number of cells": 6,
"Capacity mAh": 3000
},
Expand All @@ -77,10 +77,14 @@
"Type": "BLHeli32",
"Version": "32.10"
},
"FC Connection": {
"FC->ESC Connection": {
"Type": "Main Out",
"Protocol": "DShot600"
},
"ESC->FC Telemetry": {
"Type": "SERIAL5",
"Protocol": "ESC Telemetry"
},
"Notes": "Runs BDshot600 on Main out and uses SERIAL5 as extra connection for low rate telemetry"
},
"Motors": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
BRD_SAFETY_DEFLT,0
CAN_D1_PROTOCOL,1
CAN_D1_UC_ESC_BM,65535
CAN_P1_DRIVER,1
COMPASS_ORIENT,0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,14 @@
"Type": "",
"Version": ""
},
"FC Connection": {
"FC->ESC Connection": {
"Type": "Main Out",
"Protocol": "Normal"
},
"ESC->FC Telemetry": {
"Type": "None",
"Protocol": "None"
},
"Notes": ""
},
"Motors": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ BATT_LOW_MAH,900 # trigger low failsafe just below 33% remaining
BATT_LOW_VOLT,21 # Low failsafe voltage x nr. of cells
BATT_MONITOR,9 # Selected in component editor window
MOT_BAT_VOLT_MAX,25.2 # Scale the PIDs up when battery voltage is below this threshold
MOT_BAT_VOLT_MIN,19.2 # Scale the PIDs up when battery voltage is above this threshold
MOT_BAT_VOLT_MIN,19.8 # Scale the PIDs up when battery voltage is above this threshold
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
BRD_SAFETY_DEFLT,0 # do not use safety switch
CAN_D1_PROTOCOL,1 # 2nd GPS (Here3) is connected via CAN
CAN_P1_DRIVER,1 # Here3
GPS_GNSS_MODE,7 # limit the constalations to ensure an update rate higher than 5Hz
GPS_GNSS_MODE,7 # limit the constellations to ensure an update rate higher than 5Hz
GPS_POS1_X,0 # GNSS antenna pahse center location relative to CG
GPS_POS1_Y,0 # GNSS antenna pahse center location relative to CG
GPS_POS1_Z,0 # GNSS antenna pahse center location relative to CG
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"Volt per cell arm": 3.5833,
"Volt per cell low": 3.5,
"Volt per cell crit": 3.2,
"Volt per cell min": 3.2,
"Volt per cell min": 3.3,
"Number of cells": 6,
"Capacity mAh": 5000
},
Expand All @@ -77,7 +77,11 @@
"Type": "FETtec",
"Version": "10_224"
},
"FC Connection": {
"FC->ESC Connection": {
"Type": "SERIAL1",
"Protocol": "FETtecOneWire"
},
"ESC->FC Telemetry": {
"Type": "SERIAL1",
"Protocol": "FETtecOneWire"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
BATT_AMP_PERVLT,17 # new calibrated value for Mamba F45_128k 4in1 ESC
BATT_ARM_VOLT,15.7 # Only arm above this voltage, to avoid taking off with insufficient battery capacity
BATT_ARM_VOLT,11.775 # Only arm above this voltage, to avoid taking off with insufficient battery capacity
BATT_CAPACITY,1800 # Total battery capacity specified in the component editor
BATT_CRT_MAH,0 # When only 450mAh out of the total 1800mAh remain, trigger critical failsafe
BATT_CRT_VOLT,14.2 # Critical failsafe voltage x nr. of cells
BATT_CRT_VOLT,10.65 # Critical failsafe voltage x nr. of cells
BATT_FS_CRT_ACT,1 # Land ASAP
BATT_FS_LOW_ACT,2 # Return and land at home or rally point
BATT_FS_VOLTSRC,0 # Let the firmware handle the nasty business of variable and battery dependent internal resistance
BATT_I2C_BUS,0 # Selected in component editor window
BATT_LOW_MAH,0 # When only 450mAh out of the total 1800mAh remain, trigger low failsafe
BATT_LOW_VOLT,14.4 # Low failsafe voltage x nr. of cells
BATT_LOW_VOLT,10.8 # Low failsafe voltage x nr. of cells
BATT_MONITOR,4 # Selected in component editor window
BATT_VOLT_MULT,10.1 # Use a power source with a voltage close to BATT_LOW_VOLT measure with a calibrated voltimeter and adapt this parameter so that the telemetry voltage reading matches it
MOT_BAT_VOLT_MAX,16.8 # Scale the PIDs up when battery voltage is below this threshold
MOT_BAT_VOLT_MIN,14.2 # Scale the PIDs up when battery voltage is above this threshold
MOT_BAT_VOLT_MAX,12.8001 # Scale the PIDs up when battery voltage is below this threshold
MOT_BAT_VOLT_MIN,9.6 # Scale the PIDs up when battery voltage is above this threshold
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
BRD_SAFETY_DEFLT,0 # Matek H743 Slim has no safety switch
GPS_GNSS_MODE,7 # limit the constalations to ensure an update rate higher than 5Hz
GPS_GNSS_MODE,7 # limit the constellations to ensure an update rate higher than 5Hz
GPS_POS1_X,0.056 # HX-CH7604A GNSS antenna pahse center location relative to CG
GPS_POS1_Y,0 # HX-CH7604A GNSS antenna pahse center location relative to CG
GPS_POS1_Z,-0.07 # HX-CH7604A GNSS antenna pahse center location relative to CG
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@
"URL": "-"
},
"Specifications": {
"Chemistry": "Lipo",
"Volt per cell max": 4.2,
"Chemistry": "LipoHV",
"Volt per cell max": 4.2667,
"Volt per cell arm": 3.925,
"Volt per cell low": 3.6,
"Volt per cell crit": 3.55,
"Volt per cell min": 3.55,
"Number of cells": 4,
"Volt per cell min": 3.2,
"Number of cells": 3,
"Capacity mAh": 1800
},
"Notes": "A Simulated battery"
Expand All @@ -77,10 +77,14 @@
"Type": "-",
"Version": "-"
},
"FC Connection": {
"FC->ESC Connection": {
"Type": "Main Out",
"Protocol": "Normal"
},
"ESC->FC Telemetry": {
"Type": "None",
"Protocol": "None"
},
"Notes": ""
},
"Motors": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,14 @@
"Type": "",
"Version": ""
},
"FC Connection": {
"FC->ESC Connection": {
"Type": "Main Out",
"Protocol": "Normal"
},
"ESC->FC Telemetry": {
"Type": "None",
"Protocol": "None"
},
"Notes": ""
},
"Motors": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ RC8_TRIM,1000
RC9_MAX,1900
RC9_MIN,1100
RC9_TRIM,1500
SERVO1_FUNCTION,0
SERVO2_FUNCTION,0
SERVO3_FUNCTION,0
SERVO4_FUNCTION,0
SERVO1_FUNCTION,33
SERVO2_FUNCTION,34
SERVO3_FUNCTION,35
SERVO4_FUNCTION,36
Loading
Loading