Log Analysis Introduced with backend_log_extraction.py#1748
Log Analysis Introduced with backend_log_extraction.py#1748OmkarSarkar204 wants to merge 8 commits into
Conversation
There was a problem hiding this comment.
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.pywith log parsing + extraction helpers (params, firmware version, frame type). - Added package initializer
log_analysis/__init__.py. - Refactored
extract_param_defaults.pyto 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. |
f4b3beb to
b1e5229
Compare
|
The codespell was failing So i just supressed it for now |
c6b4406 to
ace0a54
Compare
Coverage Report for CI Build 28046795869Coverage decreased (-0.7%) to 93.678%Details
Uncovered ChangesNo uncovered changes found. Coverage Regressions6 previously-covered lines in 1 file lost coverage.
Coverage Stats
💛 - Coveralls |
bdf514b to
4239dca
Compare
f5a17b7 to
9c9ba7c
Compare
9c9ba7c to
d056d57
Compare
|
Thanks for this. I reviewed the code and did some improvements. |
d056d57 to
87d50fa
Compare
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. :) |
1e4e8b6 to
2003f98
Compare
|
Extracted till now |
e32105f to
871c7f6
Compare
|
I'll Add more regression test after the quality_checker |
|
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. |
|
The .bin files are "self-contained" they contain all of the information required to decode the file inside the file itself. |
05318c9 to
5861ec9
Compare
|
I'm just not sure abou the return type here |
|
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. |
The return type for |
… 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>
e3a0ed6 to
5aa31a3
Compare
| 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") | ||
|
|
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Keep it around while you test multiple logs.
Mark it for later removal, if it duplicates pymavlink functionality
947215e to
5a75c29
Compare
Signed-off-by: Omkar Sarkar <omkarsarkar24@gmail.com>
5a75c29 to
75352a8
Compare
amilcarlucas
left a comment
There was a problem hiding this comment.
Looks good. By plugins I meant: ARCHITECTURE_battery_monitor.md and ARCHITECTURE_motor_test.md
| @@ -0,0 +1,62 @@ | |||
| { | |||
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
| 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") | ||
|
|
There was a problem hiding this comment.
Keep it around while you test multiple logs.
Mark it for later removal, if it duplicates pymavlink functionality
582b936 to
47ae7f1
Compare
Signed-off-by: Omkar Sarkar <omkarsarkar24@gmail.com>
47ae7f1 to
c70df12
Compare
Description
Pr Introducing the Log_Analysis module for Ardupilot log, which will be used by and with AMC
Checklist
git commit --signoff)Testing
Describe how you tested these changes: