Skip to content

Project from bin#1549

Merged
amilcarlucas merged 3 commits into
masterfrom
project_from_bin
Apr 27, 2026
Merged

Project from bin#1549
amilcarlucas merged 3 commits into
masterfrom
project_from_bin

Conversation

@amilcarlucas
Copy link
Copy Markdown
Collaborator

@amilcarlucas amilcarlucas commented Apr 23, 2026

Description

Add a "Create a vehicle project from a .bin log file" button to the
New Vehicle panel in the project-opener window.

Business logic additions in data_model_vehicle_project_creator.py:

  • extract_param_files_from_bin_log(): calls extract_parameter_values()
    for both "defaults" and "values" snapshots; wraps results as ParDict
  • template_dir_for_bin_import(): returns the empty_4.6.x template path
  • vehicle_name_from_bin_log(): derives the new vehicle name from the
    .bin file stem
  • next_import_filename(): finds the next available numbered slot for the
    imported parameter file

Orchestration in data_model_vehicle_project.py
(create_new_vehicle_from_bin_log):

  • Scaffolds the project from empty_4.6.x with current FC params used for
    template substitution
  • Replaces the template's 00_default.param with the .bin-extracted
    defaults snapshot (key deviation from normal template-based creation)
  • Exports remaining current parameters into a numbered
    *_imported_bin_log_parameters.param file

GUI additions:

  • BinLogSelectionWidgets reusable widget added to
    frontend_tkinter_directory_selection.py
  • Widget wired into VehicleProjectOpenerWindow.create_option1_widgets()

Checklist

  • Run pre-commit checks locally
  • Verified by a human programmer
  • All commits are signed off (use git commit --signoff)
  • Code follows our coding standards
  • Documentation updated if needed
  • No breaking changes or properly documented

Testing

Describe how you tested these changes:

  • Unit tests pass
  • Integration tests pass
  • Manual testing performed
  • Tested on flight controller hardware

Copilot AI review requested due to automatic review settings April 23, 2026 23:59
Copy link
Copy Markdown
Contributor

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

Note

Copilot was unable to run its full agentic suite in this review.

Adds an end-to-end “create project from ArduPilot .bin log” workflow, including backend helpers, manager orchestration, a Tkinter UI entry point, and unit tests to validate the behavior.

Changes:

  • Introduces .bin log import helpers on VehicleProjectCreator and an orchestration method on VehicleProjectManager.
  • Adds a Tkinter widget/button flow to select a .bin file and trigger project creation.
  • Adds unit tests for helper methods and manager orchestration paths (success, missing params export, error propagation, FC sync).

Reviewed changes

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

Show a summary per file
File Description
tests/test_data_model_vehicle_project_creator.py Adds unit tests for new .bin import helper methods (template path, naming, slot selection, extraction errors).
tests/test_data_model_vehicle_project.py Adds unit tests covering create_new_vehicle_from_bin_log orchestration and side-effects.
ardupilot_methodic_configurator/frontend_tkinter_project_opener.py Surfaces the new .bin import option in the project opener UI.
ardupilot_methodic_configurator/frontend_tkinter_directory_selection.py Adds BinLogSelectionWidgets to select a .bin file and handle import errors.
ardupilot_methodic_configurator/data_model_vehicle_project_creator.py Implements static helpers for .bin imports (template dir, stem, filename slotting, param extraction).
ardupilot_methodic_configurator/data_model_vehicle_project.py Implements create_new_vehicle_from_bin_log workflow and missing-param export logic.

Comment thread ardupilot_methodic_configurator/data_model_vehicle_project.py Outdated
Comment thread ardupilot_methodic_configurator/data_model_vehicle_project_creator.py Outdated
Comment thread ardupilot_methodic_configurator/data_model_vehicle_project.py
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 24, 2026

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
12584 11858 94% 89% 🟢

New Files

No new covered files...

Modified Files

No covered modified files...

updated for commit: 0d21426 by action🐍

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 24, 2026

Test Results

     4 files       4 suites   41m 22s ⏱️
 3 627 tests  3 625 ✅  2 💤 0 ❌
14 300 runs  14 276 ✅ 24 💤 0 ❌

Results for commit 0d21426.

♻️ This comment has been updated with latest results.

Copy link
Copy Markdown
Contributor

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

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Comment thread ardupilot_methodic_configurator/data_model_vehicle_project_creator.py Outdated
Comment thread ardupilot_methodic_configurator/data_model_vehicle_project.py Outdated
Comment thread ardupilot_methodic_configurator/data_model_vehicle_project.py Outdated
@amilcarlucas amilcarlucas force-pushed the project_from_bin branch 2 times, most recently from cf18c07 to 05c293d Compare April 25, 2026 13:29
@amilcarlucas amilcarlucas requested a review from Copilot April 25, 2026 13:29
Copy link
Copy Markdown
Contributor

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

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.

Comment thread ardupilot_methodic_configurator/data_model_vehicle_project.py Outdated
Comment thread USECASES.md Outdated
@amilcarlucas amilcarlucas force-pushed the project_from_bin branch 2 times, most recently from 29afbcd to 7919c22 Compare April 25, 2026 13:52
@amilcarlucas amilcarlucas requested a review from Copilot April 25, 2026 13:52
Copy link
Copy Markdown
Contributor

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

Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.

Comment thread ardupilot_methodic_configurator/backend_filesystem_vehicle_components.py Outdated
Comment on lines +429 to +443
def next_import_filename(vehicle_dir: str) -> str:
"""Return the next available numbered parameter filename for imported log parameters."""
highest_prefix = 0
for file_path in Path(vehicle_dir).iterdir():
if not file_path.is_file() or file_path.suffix != ".param":
continue
prefix = file_path.name[:2]
if prefix.isdigit():
highest_prefix = max(highest_prefix, int(prefix))

next_prefix = highest_prefix + 1
if next_prefix > 99:
msg = _("Could not create an import parameter file because no numbered slot is available in {vehicle_dir}")
raise VehicleProjectCreationError(_("Parameter import"), msg.format(vehicle_dir=vehicle_dir))
return f"{next_prefix:02d}_imported_bin_log_parameters.param"
Copy link

Copilot AI Apr 25, 2026

Choose a reason for hiding this comment

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

Path(vehicle_dir).iterdir()can raiseOSError(e.g., permission issues, missing directory, broken symlink). Right now that would bypass the intendedVehicleProjectCreationError("Parameter import", ...)path and surface as a raw exception. Consider catchingOSErroraround the directory iteration and re-raising asVehicleProjectCreationErrorwith the"Parameter import"title and a message that includesvehicle_dir` and the underlying error text.

Copilot uses AI. Check for mistakes.
Comment thread ardupilot_methodic_configurator/extract_param_defaults.py Outdated
…file

Add a "Create a vehicle project from a .bin log file" button to the
New Vehicle panel in the project-opener window.

Orchestration in data_model_vehicle_project.py
(create_new_vehicle_from_bin_log):
- Scaffolds the project from empty_4.6.x with current FC params used for
  template substitution
- Replaces the template's 00_default.param with the .bin-extracted
  defaults snapshot (key deviation from normal template-based creation)
- Exports remaining current parameters into a numbered
  *_imported_bin_log_parameters.param file

GUI additions:
- BinLogSelectionWidgets reusable widget added to
  frontend_tkinter_directory_selection.py
- Widget wired into VehicleProjectOpenerWindow.create_option1_widgets()

Address Copilot PR review comments for bin log import feature

- Move open_vehicle_directory() to end of create_new_vehicle_from_bin_log() to ensure UI/session operates on authoritative filesystem state after all file modifications (fixes stale state issue)
- Add exception handler for VehicleProjectOpenError in BinLogSelectionWidgets UI to display friendly error dialog instead of crashing
- Extract template directory name to BIN_IMPORT_TEMPLATE_DIR class constant to reduce duplication and ease future maintenance when template version changes
- Add clarifying multi-line comment explaining why infer_comp_specs_and_conn_from_fc_params and use_fc_params flags are reused for log-derived parameters

All 100 tests pass, all code quality checks pass.
Copy link
Copy Markdown
Contributor

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

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

Comment thread ardupilot_methodic_configurator/data_model_vehicle_project_creator.py Outdated
Comment thread ardupilot_methodic_configurator/extract_param_defaults.py
Comment thread ardupilot_methodic_configurator/extract_param_defaults.py
Comment thread ardupilot_methodic_configurator/extract_param_defaults.py
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Amilcar Lucas <amilcar.lucas@iav.de>
@amilcarlucas amilcarlucas merged commit 485ea91 into master Apr 27, 2026
29 of 31 checks passed
@amilcarlucas amilcarlucas deleted the project_from_bin branch April 27, 2026 20:45
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.

2 participants