User-facing documentation: USERMANUAL_motor_test.md

The Motor Test sub-application provides a graphical interface for testing individual motors on ArduPilot vehicles, similar to Mission Plannerβs motor test functionality. It allows users to test motor functionality, verify motor order and direction, and configure motor parameters before flight.
.svg files in the https://ardupilot.org/copter/_images/ directory, converted to PNG for better compatibilityThe motor test sub-application follows the Model-View separation pattern established in the project:
βββββββββββββββββββ ββββββββββββββββββββββββ
β GUI Layer β β Data Model Layer β
β β β β
β frontend_tkinterβββββΊβ data_model_motor β
β _motor_test.py β β _test.py β
β β β β
β - UI Layout β β - Business Logic β
β - Event Handlingβ β - Parameter Mgmt β
β - User Feedback β β - Frame Detection β
βββββββββββββββββββ ββββββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββββ
β Backend Layer β
β β
β βββββββββββββββββββββββββββββββββββββββ€
β β backend_flightcontroller.py β
β β - Motor test commands (individual, β
β β all, sequence, emergency stop) β
β β - Battery monitoring & safety β
β β β - Frame detection & motor count β
β β - MAVLink communication β
β β - Parameter read/write β
β βββββββββββββββββββββββββββββββββββββββ€
β βββββββββββββββββββββββββββββββββββββββ€
β β backend_filesystem.py β
β β - Safety validation logic β
β β - Frame configuration support β
β β - Parameter documentation metadata β
β βββββββββββββββββββββββββββββββββββββββ€
β βββββββββββββββββββββββββββββββββββββββ€
β β backend_filesystem_program_settings.py β
β β - Motor diagram PNG file access β
β β - Settings persistence (test duration)β
β β - Application configuration β
β βββββββββββββββββββββββββββββββββββββββ€
βββββββββββββββββββββββββββββββββββββββββ
data_model_motor_test.py)Primary Responsibilities:
The motor test sub-application implements a robust JSON-driven architecture for motor test order and direction determination:
JSON Data Sources:
AP_Motors_test.json - Authoritative motor layout data from ArduPilot projectAP_Motors_test_schema.json - JSON schema for data structure validationKey Features:
Data Flow:
Key Methods:
def __init__(self, flight_controller: FlightController, filesystem: LocalFilesystem, settings: ProgramSettings) -> None
def get_motor_count(self) -> int
def get_motor_labels(self) -> list[str]
def get_motor_numbers(self) -> list[int]
def get_motor_directions(self) -> list[str] # β
Returns CW/CCW direction labels from AP_Motors_test.json
def get_battery_status(self) -> Optional[tuple[float, float]] # voltage, current or None if BATT_MONITOR == 0
def get_voltage_status(self) -> str # "safe", "critical" "unavailable" or "disabled"
def is_battery_monitoring_enabled(self) -> bool # True if BATT_MONITOR != 0
def is_motor_test_safe(self) -> tuple[bool, str] # (is_safe, reason)
def set_parameter(self, param_name: str, value: float) -> tuple[bool, str] # (success, error_message)
def get_parameter(self, param_name: str) -> Optional[float]
def test_motor(self, test_sequence_nr: int, motor_letters: str, motor_output_nr: int, throttle_percent: int, timeout_seconds: int) -> tuple[bool, str]
def test_all_motors(self, nr_of_motors: int, throttle_percent: int, timeout_seconds: int) -> tuple[bool, str]
def test_motors_in_sequence(self, start_motor: int, motor_count: int, throttle_percent: int, timeout_seconds: int) -> tuple[bool, str]
def stop_all_motors(self) -> tuple[bool, str]
def get_motor_diagram_path(self) -> tuple[str, str] # Returns (filepath, description)
def motor_diagram_exists(self) -> bool
def get_test_duration(self) -> float
def set_test_duration(self, duration: float) -> bool
def get_test_throttle_pct(self) -> int
def set_test_throttle_pct(self, throttle: int) -> bool
def update_frame_configuration(self, frame_class: int, frame_type: int) -> tuple[bool, str]
def get_frame_options(self) -> dict[str, dict[int, str]]
def refresh_connection_status(self) -> bool
def get_voltage_thresholds(self) -> tuple[float, float] # Returns (BATT_ARM_VOLT, MOT_BAT_VOLT_MAX)
def refresh_from_flight_controller(self) -> bool # β
Refresh frame configuration from FC
def _load_motor_data(self) -> None # β
Load motor configuration from AP_Motors_test.json with schema validation
Data Attributes:
flight_controller: Backend flight controller interfacefilesystem: Backend filesystem interfacesettings: Backend program settings interface_frame_class: Detected vehicle frame class_frame_type: Detected vehicle frame type_motor_count: Number of motors for current frame_motor_data_loader: FilesystemJSONWithSchema instance for loading AP_Motors_test.json_motor_data: Loaded motor configuration data from JSON with schema validationThe motor test sub-application backend logic is distributed across three specialized backend modules:
backend_flightcontroller.py - Flight Controller CommunicationResponsibilities:
Key Motor Test Methods:
def test_motor(self, test_sequence_nr: int, motor_letters: str, motor_output_nr: int, throttle_percent: int, timeout_seconds: int) -> tuple[bool, str]
def test_all_motors(self, nr_of_motors: int, throttle_percent: int, timeout_seconds: int) -> tuple[bool, str]
def test_motors_in_sequence(self, start_motor: int, motor_count: int, throttle_percent: int, timeout_seconds: int) -> tuple[bool, str]
def stop_all_motors(self) -> tuple[bool, str]
def get_battery_statuses(self) -> tuple[dict[int, tuple[float, float]] | None, str]
def get_voltage_thresholds(self) -> tuple[float, float]
def is_battery_monitoring_enabled(self) -> bool
def get_frame_info(self) -> tuple[int, int]
def get_motor_count_from_frame(self) -> int
def fetch_param(self, param_name: str, timeout: int = 5) -> Optional[float]
Motor Test Implementation:
Motor safety uses only MAVLink battery ID 0 and battery 1βs voltage thresholds.
When BATT_MONITOR is disabled, testing proceeds with the voltage verification warning even if secondary monitors are enabled.
When battery 1 is enabled, missing telemetry or a critical voltage blocks testing in every UI language.
The motor test functionality uses MAVLink parameter handling:
MAV_CMD_DO_MOTOR_TEST with param1=test_sequence_nr + 1, param5=0 for single motor testsMAV_CMD_DO_MOTOR_TEST commands for each motor to achieve simultaneous effectMAV_CMD_DO_MOTOR_TEST with param1=start_motor, param5=motor_count for sequence testingfetch_param() method for reliable parameter retrieval with timeout handlingbackend_filesystem.py - Safety & Parameter SupportResponsibilities:
backend_filesystem_program_settings.py - Diagrams & SettingsResponsibilities:
motor_test.duration and motor_test.throttle_pctKey Motor Test Methods:
@staticmethod
def motor_diagram_filepath(frame_class: int, frame_type: int) -> tuple[str, str]
@staticmethod
def motor_diagram_exists(frame_class: int, frame_type: int) -> bool
backend_filesystem_json_with_schema.py - Motor Frames & rotation order and directionResponsibilities:
frontend_tkinter_motor_test.py)Primary Responsibilities:
Key UI Components:
Enhanced Features:
Layout Structure:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Information & Safety Warnings β
β β’ PROPELLERS MUST BE REMOVED before proceeding! β
β β’ Ensure the vehicle is properly secured and cannot move. β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β 1. Frame configuration β
β Frame Type: [FRAME_TYPE βΌ] β
β β
β Frame Type PNG diagram β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β 2. Motor order/direction configuration β
β Throttle: [____] % Duration: [____] seconds Battery: 12.4V/2.1A β
β β
β [Test Motor A] Motor 1 CW [Detected: βΌ] [Ready] β
β [Test Motor B] Motor 2 CCW [Detected: βΌ] [Ready] β
β [Test Motor C] Motor 3 CCW [Detected: βΌ] [Ready] β
β [Test Motor D] Motor 4 CW [Detected: βΌ] [Ready] β
β ... β
β β
β [Test All] [Test in Sequence] [π STOP ALL MOTORS] β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β 3. Arm and min throttle configuration β
β [Set Motor Spin Arm] [Set Motor Spin Min] β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
The step-by-step usage instructions, keyboard shortcuts and safety behavior seen by the user are described in the user manual.
MotorTestSafetyError, no motor command is sent
and the GUI shows get_battery_safety_message() in a warning popupException to the explicit-upload rule: FRAME_TYPE, MOT_SPIN_MIN and MOT_SPIN_ARM (and their ArduPlane
Q_M_*equivalents) and the confirmed Detected-motor swap (swap_motor_functions, which exchanges twoSERVOx_FUNCTIONvalues) are written to the flight controller as soon as the user confirms the change, without pressing either of the two parameter-editor upload buttons. Parameter-table edits elsewhere in the application are staged and require an explicit upload. The user-facing explanation is in the user manual. After a MOT_SPIN_MIN, MOT_SPIN_ARM or motor swap change (swap_motor_functionsreturns the written parameter names) the plugin copies the value read back from the flight controller into the parameter table (both the staged value and the FC value, so the row is not flagged as different from the flight controller) viarefresh_parameter_editor_after_calibration(..., redownload=False).
tests/test_data_model_motor_test.py) - β
IMPLEMENTEDStatus: 81 comprehensive BDD pytest tests implemented covering all functionality with 100% code coverage
Test Coverage Areas:
tests/test_frontend_tkinter_motor_test.py) - β
IMPLEMENTEDStatus: 34 comprehensive BDD pytest tests implemented covering frontend functionality with high test coverage
Test Coverage Areas:
Following project pytest guidelines with BDD structure:
@pytest.fixture
def mock_flight_controller() -> MagicMock:
"""Fixture providing mocked flight controller with realistic responses."""
@pytest.fixture
def motor_test_data_model(mock_flight_controller) -> MotorTestDataModel:
"""Fixture providing configured motor test data model with dependency injection support."""
@pytest.fixture
def motor_test_view_setup() -> tuple[MagicMock, ...]:
"""Fixture providing complete mock setup for testing MotorTestView without full window creation."""
@pytest.fixture
def motor_test_window(motor_test_data_model) -> MotorTestWindow:
"""Fixture providing configured motor test GUI window for integration testing."""
def test_user_can_test_individual_motor(self, motor_test_view_setup) -> None:
"""
User can test individual motors safely.
GIVEN: A configured motor test view with mock dependencies
WHEN: User clicks a motor test button
THEN: The corresponding motor should activate with proper validation and feedback
"""
def test_spinbox_values_initialize_from_data_model(self, motor_test_view_setup) -> None:
"""
Spinbox values are properly initialized from the data model.
GIVEN: A motor test view with configured data model
WHEN: The view is updated
THEN: Spinbox values should reflect the current model values
"""
def test_spinbox_changes_update_data_model(self, motor_test_view_setup) -> None:
"""
Spinbox changes properly update the data model.
GIVEN: A motor test view with Spinbox widgets
WHEN: User changes Spinbox values
THEN: The data model should be updated with the new values
"""
Core Functionality:
Enhanced Features:
backend_flightcontroller.py - All required motor test methods verified presentbackend_filesystem.py - Enhanced with get_frame_options() methodbackend_filesystem_program_settings.py - Settings persistence implementedbackend_filesystem_json_with_schema.py - JSON loading with schema validation for motor dataannotate_params.py - Parameter metadata parsing supportardupilot_methodic_configurator/images/motor_diagrams_png/ directory.pdef.xml)_()The motor test sub-application integrates with the main ArduPilot Methodic Configurator through:
The motor test sub-application leverages the existing backend infrastructure without requiring additional backend modules:
backend_flightcontroller.py)backend_filesystem.py)backend_filesystem_program_settings.py)This architecture demonstrates the projectβs modular design - new sub-applications can be implemented by primarily creating frontend and data model layers while leveraging the robust, tested backend infrastructure that already exists.
Communication with ArduPilot flight controller via:
This architecture provides a comprehensive foundation for implementing a safe, reliable, and user-friendly motor test sub-application that integrates seamlessly with the ArduPilot Methodic Configurator while maintaining the highest safety standards for motor testing operations.