Skip to content

Log Analysis Introduced with backend_log_extraction.py#1748

Open
OmkarSarkar204 wants to merge 8 commits into
ArduPilot:masterfrom
OmkarSarkar204:log_analysis_feats
Open

Log Analysis Introduced with backend_log_extraction.py#1748
OmkarSarkar204 wants to merge 8 commits into
ArduPilot:masterfrom
OmkarSarkar204:log_analysis_feats

Conversation

@OmkarSarkar204

@OmkarSarkar204 OmkarSarkar204 commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Description

Pr Introducing the Log_Analysis module for Ardupilot log, which will be used by and with AMC

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( for existing files not real files)
  • Integration tests pass
  • Manual testing performed
  • Tested on flight controller hardware

Copilot AI review requested due to automatic review settings June 19, 2026 06:18
@OmkarSarkar204 OmkarSarkar204 marked this pull request as draft June 19, 2026 06:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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.

Introduces a new log_analysis module to parse ArduPilot .bin logs, extracting parameter values/defaults, firmware version info, message counts, and frame type, and reuses that logic from extract_param_defaults.py.

Changes:

  • Added log_analysis/backend_log_extraction.py with log parsing + extraction helpers (params, firmware version, frame type).
  • Added package initializer log_analysis/__init__.py.
  • Refactored extract_param_defaults.py to reuse shared validation/version-parsing helpers from the new module.

Reviewed changes

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

File Description
ardupilot_methodic_configurator/log_analysis/backend_log_extraction.py New backend log extraction implementation (open/close log, parse messages, extract params/firmware/frame type).
ardupilot_methodic_configurator/log_analysis/init.py Initializes the new log_analysis package with a module docstring.
ardupilot_methodic_configurator/extract_param_defaults.py Replaces in-file regex/version parsing with imports from backend_log_extraction.

Comment thread ardupilot_methodic_configurator/extract_param_defaults.py Outdated
Comment thread ardupilot_methodic_configurator/log_analysis/backend_log_extraction.py Outdated
Comment thread ardupilot_methodic_configurator/log_analysis/backend_log_extraction.py Outdated
Comment thread ardupilot_methodic_configurator/log_analysis/backend_log_extraction.py Outdated
Comment thread ardupilot_methodic_configurator/log_analysis/backend_log_extraction.py Outdated
Comment thread ardupilot_methodic_configurator/log_analysis/backend_log_extraction.py Outdated
Comment thread ardupilot_methodic_configurator/log_analysis/backend_log_extraction.py Outdated
Comment thread ardupilot_methodic_configurator/log_analysis/__init__.py
Comment thread ardupilot_methodic_configurator/log_analysis/backend_log_extraction.py Outdated
@OmkarSarkar204 OmkarSarkar204 force-pushed the log_analysis_feats branch 5 times, most recently from f4b3beb to b1e5229 Compare June 19, 2026 07:44
@OmkarSarkar204

Copy link
Copy Markdown
Contributor Author

The codespell was failing

codespell................................................................Failed
- hook id: codespell
- exit code: 65

ardupilot_methodic_configurator/data_model_configuration_step.py:351: SER ==> SET

So i just supressed it for now

Comment thread ardupilot_methodic_configurator/log_analysis/backend_log_extraction.py Outdated
@coveralls

coveralls commented Jun 19, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 28046795869

Coverage decreased (-0.7%) to 93.678%

Details

  • Coverage decreased (-0.7%) from the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • 6 coverage regressions across 1 file.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

6 previously-covered lines in 1 file lost coverage.

File Lines Losing Coverage Coverage
extract_param_defaults.py 6 95.88%

Coverage Stats

Coverage Status
Relevant Lines: 13651
Covered Lines: 12788
Line Coverage: 93.68%
Relevant Branches: 2096
Covered Branches: 2014
Branch Coverage: 96.09%
Branches in Coverage %: No
Coverage Strength: 2.8 hits per line

💛 - Coveralls

@OmkarSarkar204 OmkarSarkar204 force-pushed the log_analysis_feats branch 2 times, most recently from bdf514b to 4239dca Compare June 19, 2026 14:39
@OmkarSarkar204 OmkarSarkar204 changed the title Log Analysis Introduced with ardupilot_log_extraction.py Log Analysis Introduced with backend_log_extraction.py Jun 20, 2026
@OmkarSarkar204 OmkarSarkar204 force-pushed the log_analysis_feats branch 4 times, most recently from f5a17b7 to 9c9ba7c Compare June 20, 2026 05:32
@amilcarlucas

Copy link
Copy Markdown
Collaborator

Thanks for this. I reviewed the code and did some improvements.

@OmkarSarkar204

OmkarSarkar204 commented Jun 20, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for this. I reviewed the code and did some improvements.

I was thinking of adding the test once ive finished the basic signals, but Thank You , Im working on the PM, IMU , VIBE and ERR messages and will try to do it by today midnight. :)

@OmkarSarkar204

Copy link
Copy Markdown
Contributor Author

Extracted till now
PARM ,VER, MSG (version fallback), BAT, PM, IMU, VIBE, GPS, ERR, ARM, MODE

@OmkarSarkar204 OmkarSarkar204 force-pushed the log_analysis_feats branch 3 times, most recently from e32105f to 871c7f6 Compare June 22, 2026 07:37
@OmkarSarkar204 OmkarSarkar204 marked this pull request as ready for review June 22, 2026 09:02
@OmkarSarkar204

OmkarSarkar204 commented Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

I'll Add more regression test after the quality_checker

@amilcarlucas

Copy link
Copy Markdown
Collaborator

All test pass, this looks good. But the ArduPilot .bin log format is self contained, meaning the the msages define themselves in the file first, before they get stored, meaning that the parser can be built that parses all messages, without knowing what is inside.
This way a parser can be written once, and never touched again. I think pymavlink does that.

@amilcarlucas

Copy link
Copy Markdown
Collaborator

The .bin files are "self-contained" they contain all of the information required to decode the file inside the file itself.
The FMT messages in the beginning of the file do exactly that.

@OmkarSarkar204 OmkarSarkar204 force-pushed the log_analysis_feats branch 2 times, most recently from 05318c9 to 5861ec9 Compare June 23, 2026 18:08
@OmkarSarkar204

OmkarSarkar204 commented Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

@amilcarlucas

Copy link
Copy Markdown
Collaborator

Sorry, Can you give a concrete file and line number?

This is what I meant: https://github.com/averyanalex/ardupilot-binlog but it is written in Rust. Should be straigtforward to convert it to python using AI.

@OmkarSarkar204

OmkarSarkar204 commented Jun 24, 2026

Copy link
Copy Markdown
Contributor Author

Sorry, Can you give a concrete file and line number?

The return type for

def parse_log(logfile: str) -> Any:  # noqa: ANN401
    """
    Open a log and yield each DataFlash message.

OmkarSarkar204 and others added 6 commits June 26, 2026 23:07
… param_default to remove code duplication.

Signed-off-by: Omkar Sarkar <omkarsarkar24@gmail.com>
Signed-off-by: Omkar Sarkar <omkarsarkar24@gmail.com>
Signed-off-by: Omkar Sarkar <omkarsarkar24@gmail.com>
Signed-off-by: Omkar Sarkar <omkarsarkar24@gmail.com>
Signed-off-by: Omkar Sarkar <omkarsarkar24@gmail.com>
@OmkarSarkar204 OmkarSarkar204 force-pushed the log_analysis_feats branch 3 times, most recently from e3a0ed6 to 5aa31a3 Compare June 26, 2026 17:48
Comment on lines +77 to +87
if not schema.fields:
issues.append("Missing field definitions")
if not schema.format:
issues.append("Missing format string")
if schema.length <= 0:
issues.append("Invalid message length")
if schema.units and len(schema.units) != len(schema.fields):
issues.append("Unit count mismatch")
if schema.multipliers and len(schema.multipliers) != len(schema.fields):
issues.append("Multiplier count mismatch")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Im sceptical is these checks are necessary or not ,as pymavlink already handles these i think, but if by any chance a log gets malformed midway, it will be usefull maybe?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Keep it around while you test multiple logs.

Mark it for later removal, if it duplicates pymavlink functionality

@OmkarSarkar204 OmkarSarkar204 force-pushed the log_analysis_feats branch 2 times, most recently from 947215e to 5a75c29 Compare June 27, 2026 03:31
Signed-off-by: Omkar Sarkar <omkarsarkar24@gmail.com>

@amilcarlucas amilcarlucas left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good. By plugins I meant: ARCHITECTURE_battery_monitor.md and ARCHITECTURE_motor_test.md

@@ -0,0 +1,62 @@
{

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This should be done the other way around. The configuration_steps_*.json file should define something like:

        "10_battery_monitor.param": {
            "why": "The battery monitor must be configured to match the hardware connection type so that the autopilot correctly reads battery voltage and current",
            "why_now": "After the battery voltage and failsafe thresholds are set, the monitor hardware connection parameters can be configured",
            "blog_text": "Configure the battery monitor hardware connection type, protocol and calibration values",
            "blog_url": "https://ardupilot.github.io/MethodicConfigurator/TUNING_GUIDE_ArduCopter#65-configure-the-primary-battery-monitor",
            "wiki_text": "Battery Monitors (aka Power Monitors/Modules) - BATT_* parameters",
            "wiki_url": "https://ardupilot.org/copter/docs/common-powermodule-landingpage.html",
            "external_tool_text": "",
            "external_tool_url": "",
            "mandatory_text": "100% mandatory (0% optional)",
            "component": "Battery Monitor",
            "auto_changed_by": "",
            "derived_parameters": {
                "BATT_MONITOR": { "New Value": "vehicle_components['Battery Monitor']['FC Connection']['Protocol']", "Change Reason": "Selected in component editor window" },
                "BATT_I2C_BUS": { "if": "vehicle_components['Battery Monitor']['FC Connection']['Type'] in ['I2C1', 'I2C2', 'I2C3', 'I2C4']", "New Value": "1 if vehicle_components['Battery Monitor']['FC Connection']['Type'] == 'I2C2' else 2 if vehicle_components['Battery Monitor']['FC Connection']['Type'] == 'I2C3' else 3 if vehicle_components['Battery Monitor']['FC Connection']['Type'] == 'I2C4' else 0", "Change Reason": "Selected in component editor window" }
            },
            "delete_parameters": {
                "BATT_I2C_BUS": { "if": "vehicle_components['Battery Monitor']['FC Connection']['Type'] not in ['I2C1', 'I2C2', 'I2C3', 'I2C4']" },
                "BATT_AMP_OFFSET": { "if": "vehicle_components['Battery Monitor']['FC Connection']['Type'] != 'Analog' or vehicle_components['Battery Monitor']['FC Connection']['Protocol'] in ['Analog Voltage Only', 'FuelLevelAnalog']" },
                "BATT_AMP_PERVLT": { "if": "vehicle_components['Battery Monitor']['FC Connection']['Type'] != 'Analog' or vehicle_components['Battery Monitor']['FC Connection']['Protocol'] in ['Analog Voltage Only', 'FuelLevelAnalog']" },
                "BATT_VOLT_MULT": { "if": "vehicle_components['Battery Monitor']['FC Connection']['Type'] != 'Analog'" }
            },
            "old_filenames": [],
            "plugin": {
                "name": "battery_monitor",
                "placement": "left"
            },
            "related_bin_log_messages": {
                 "BAT": { "name": "Battery" }
             }
        },

This way we can support multiple vehicles, and reduce maintenance effort.

@OmkarSarkar204 OmkarSarkar204 Jun 27, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sure that was just temporary, ill do in configuration_steps_copter.json only , and ill start by the 100% mandatory mesasges. But im doing the categorisation based on some docs so it might be wrong. Ill update soon

Comment on lines +77 to +87
if not schema.fields:
issues.append("Missing field definitions")
if not schema.format:
issues.append("Missing format string")
if schema.length <= 0:
issues.append("Invalid message length")
if schema.units and len(schema.units) != len(schema.fields):
issues.append("Unit count mismatch")
if schema.multipliers and len(schema.multipliers) != len(schema.fields):
issues.append("Multiplier count mismatch")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Keep it around while you test multiple logs.

Mark it for later removal, if it duplicates pymavlink functionality

Signed-off-by: Omkar Sarkar <omkarsarkar24@gmail.com>
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.

4 participants