Skip to content

Conversation

amilcarlucas
Copy link
Collaborator

No description provided.

It now raises exceptions that the frontend should catch and display to the user.
The motor diagrams are all png now, I've given up on svg. They're to hard to render correctly
@Copilot Copilot AI review requested due to automatic review settings September 25, 2025 17:15
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a comprehensive motor test frontend for the ArduPilot Methodic Configurator project. The implementation provides a complete GUI solution for testing motor functionality, validating motor order and direction, and managing critical safety parameters.

Key changes:

  • Complete motor test data model with 30+ methods and comprehensive exception handling using custom exception classes
  • Full Tkinter GUI implementation with real-time feedback, safety warnings, and keyboard shortcuts
  • Enhanced motor diagram download and conversion scripts with improved error handling and automatic PNG conversion

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/test_data_model_motor_test.py Updated tests to handle new exception-based API with proper exception assertions and improved error handling
scripts/download_motor_diagrams.py Enhanced with automatic PNG conversion integration and improved logging/error handling
scripts/batch_convert_motor_diagrams.py Improved Firefox service setup with Windows path handling and enhanced debugging
ardupilot_methodic_configurator/frontend_tkinter_motor_test.py New comprehensive motor test GUI with safety features, real-time feedback, and keyboard shortcuts
ardupilot_methodic_configurator/data_model_motor_test.py Complete data model implementation with exception-based API and comprehensive parameter validation
ardupilot_methodic_configurator/backend_flightcontroller.py Added fetch_param method for real-time parameter verification
ardupilot_methodic_configurator/backend_filesystem_program_settings.py Updated to support PNG diagrams and hierarchical motor test settings
ARCHITECTURE_motor_test.md Comprehensive documentation update reflecting implemented features and architecture decisions
.vscode/launch.json Added debug configuration for motor test frontend development

if os.name == "nt": # Windows
# Replace backslashes with forward slashes and handle drive letter
svg_abs_path = svg_abs_path.replace("\\", "/")
svg_abs_path = f"file:///{svg_abs_path}" if svg_abs_path[1] == ":" else f"file://{svg_abs_path}"
Copy link
Preview

Copilot AI Sep 25, 2025

Choose a reason for hiding this comment

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

This code assumes Windows paths have a drive letter at position 1, but this could cause an IndexError if svg_abs_path is less than 2 characters long. Add a length check: if len(svg_abs_path) > 1 and svg_abs_path[1] == \":\":

Suggested change
svg_abs_path = f"file:///{svg_abs_path}" if svg_abs_path[1] == ":" else f"file://{svg_abs_path}"
svg_abs_path = f"file:///{svg_abs_path}" if len(svg_abs_path) > 1 and svg_abs_path[1] == ":" else f"file://{svg_abs_path}"

Copilot uses AI. Check for mistakes.

Comment on lines +519 to +526
raise ValidationError(
_("Invalid throttle percentage %(throttle)d (valid range: %(min)d-%(max)d")
% {
"throttle": throttle_percent,
"min": THROTTLE_PCT_MIN,
"max": THROTTLE_PCT_MAX,
}
)
Copy link
Preview

Copilot AI Sep 25, 2025

Choose a reason for hiding this comment

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

The error message format string is missing the closing parenthesis. It should be \"Invalid throttle percentage %(throttle)d (valid range: %(min)d-%(max)d)\"

Copilot uses AI. Check for mistakes.

Comment on lines +532 to +537
% {"duration": timeout_seconds, "min": DURATION_S_MIN, "max": DURATION_S_MAX}
)
if timeout_seconds > DURATION_S_MAX:
raise ValidationError(
_("Invalid test duration %(duration)d (valid range: %(min)d-%(max)d)")
% {"duration": timeout_seconds, "min": DURATION_S_MIN, "max": DURATION_S_MAX}
Copy link
Preview

Copilot AI Sep 25, 2025

Choose a reason for hiding this comment

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

Similar issue - using %(duration)d format specifier for timeout_seconds parameter, but timeout_seconds might be a float. Either change the format to %(duration)g or ensure the parameter is cast to int.

Suggested change
% {"duration": timeout_seconds, "min": DURATION_S_MIN, "max": DURATION_S_MAX}
)
if timeout_seconds > DURATION_S_MAX:
raise ValidationError(
_("Invalid test duration %(duration)d (valid range: %(min)d-%(max)d)")
% {"duration": timeout_seconds, "min": DURATION_S_MIN, "max": DURATION_S_MAX}
% {"duration": int(timeout_seconds), "min": DURATION_S_MIN, "max": DURATION_S_MAX}
)
if timeout_seconds > DURATION_S_MAX:
raise ValidationError(
_("Invalid test duration %(duration)d (valid range: %(min)d-%(max)d)")
% {"duration": int(timeout_seconds), "min": DURATION_S_MIN, "max": DURATION_S_MAX}

Copilot uses AI. Check for mistakes.

Comment on lines +531 to +536
_("Invalid test duration %(duration)d (valid range: %(min)d-%(max)d)")
% {"duration": timeout_seconds, "min": DURATION_S_MIN, "max": DURATION_S_MAX}
)
if timeout_seconds > DURATION_S_MAX:
raise ValidationError(
_("Invalid test duration %(duration)d (valid range: %(min)d-%(max)d)")
Copy link
Preview

Copilot AI Sep 25, 2025

Choose a reason for hiding this comment

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

Same issue as above - using %(duration)d format specifier but constants DURATION_S_MIN and DURATION_S_MAX are defined as floats (1.0, 60.0). Use %(duration)g and %(min)g, %(max)g format specifiers instead.

Suggested change
_("Invalid test duration %(duration)d (valid range: %(min)d-%(max)d)")
% {"duration": timeout_seconds, "min": DURATION_S_MIN, "max": DURATION_S_MAX}
)
if timeout_seconds > DURATION_S_MAX:
raise ValidationError(
_("Invalid test duration %(duration)d (valid range: %(min)d-%(max)d)")
_("Invalid test duration %(duration)g (valid range: %(min)g-%(max)g)")
% {"duration": timeout_seconds, "min": DURATION_S_MIN, "max": DURATION_S_MAX}
)
if timeout_seconds > DURATION_S_MAX:
raise ValidationError(
_("Invalid test duration %(duration)g (valid range: %(min)g-%(max)g)")

Copilot uses AI. Check for mistakes.

Copy link
Contributor

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
8742 6600 76% 73% 🟢

New Files

File Coverage Status
ardupilot_methodic_configurator/frontend_tkinter_motor_test.py 0% 🟢
TOTAL 0% 🟢

Modified Files

File Coverage Status
ardupilot_methodic_configurator/backend_filesystem_program_settings.py 100% 🟢
ardupilot_methodic_configurator/backend_flightcontroller.py 34% 🟢
ardupilot_methodic_configurator/data_model_motor_test.py 70% 🟢
TOTAL 68% 🟢

updated for commit: 7bad852 by action🐍

Copy link
Contributor

Test Results

    2 files      2 suites   1m 42s ⏱️
1 805 tests 1 790 ✅ 1 💤 14 ❌
3 610 runs  3 580 ✅ 2 💤 28 ❌

For more details on these failures, see this check.

Results for commit 7bad852.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant