Skip to content

feat: add support of comma-separated param files with comments and empty lines#402

Draft
flyasky wants to merge 1 commit into
AvyFly:masterfrom
flyasky:feature/ardupilot-file-format-with-comments
Draft

feat: add support of comma-separated param files with comments and empty lines#402
flyasky wants to merge 1 commit into
AvyFly:masterfrom
flyasky:feature/ardupilot-file-format-with-comments

Conversation

@flyasky
Copy link
Copy Markdown

@flyasky flyasky commented Feb 6, 2026

Added support for Mission Planner format with comments and empty lines.
ulog parser is disabled because it is a subset of MissionPlanner format, and we have SyntaxError: Protocol ambiguous, fits more than one parser. exception.

@flyasky flyasky marked this pull request as draft February 6, 2026 12:09
@flyasky flyasky force-pushed the feature/ardupilot-file-format-with-comments branch from 48bef53 to e1e59f3 Compare February 8, 2026 17:50
@flyasky flyasky marked this pull request as ready for review February 8, 2026 17:51
@flyasky
Copy link
Copy Markdown
Author

flyasky commented Mar 31, 2026

@Georacer could you please review this MR?

Copy link
Copy Markdown
Collaborator

@Georacer Georacer left a comment

Choose a reason for hiding this comment

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

Thank you very much for the PR and sorry for the delay.
We'll get this in eventually, one way or another.

But I have a first round of questions here. Perhaps a few more later, when I look at this again.
Could you provide some answers?

Comment thread pyproject.toml Outdated
Comment thread tests/utils.py Outdated
Comment on lines +25 to +26
ARDUPILOT_DEFAULT_PARM = Path(ARDUPILOT_ASSETS_PATH) / "sitl_copter_defaults.parm"
ARDUPILOT_DEFAULT_PARAM = Path(ARDUPILOT_ASSETS_PATH) / "sitl_plane_defaults.param"
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.

Is there any actual reason to add both a copter and a plane parameter file? Do you use both in the autotests?

Also these two names are too similar, they need more appropriate names.

Copy link
Copy Markdown
Author

@flyasky flyasky Apr 12, 2026

Choose a reason for hiding this comment

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

Plane and copter defaults are different. As I generally work on planes, so I only had plane defaults to commit here=).

In the tests we need to cover both .parm (tab separator) and .param (comma separator) file types. Maybe let me replace it with the file for copter. I guess if I replace tabs to commas it will work out

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 in mind that Parasect is meant to be agnostic of the actual parameters meaning, so copter and plane defaults won't and should not make any difference to how they are parsed.
Unless there are syntactic differences, which to my understanding are not, for the moment.

Comment thread tests/test_helpers.py
def test_qgc_rare_types(self):
"""Ensure that value types 2,4,6,9 are correctly read."""
parameter_list = _helpers.read_params(utils.ARDUPILOT_ODD_PARAM_VALUES_FILE)
parameter_list = _helpers.read_params(utils.ARDUPILOT_ODD_PARAMS_VALUES_FILE)
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.

Is there really a need to rename this constant?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I think yes, as it has file type in the name related to .params extension. This is a different type produced by QGroundControl.

image

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.

Ah, now I understand. I did not mean for this variable name to match the extension of the filetype.

I'll consider if this is important in the context of these util attribute names.

Comment thread src/parasect/build_lib.py
Comment on lines +751 to +752
return f"{meal.name}.parm"
elif format == Formats.mp:
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.

You're re-routing the .param format to the Mission Planner one, and throwing .parm to .apm and .apj.
Can you explain this change a bit?

Copy link
Copy Markdown
Author

@flyasky flyasky Apr 12, 2026

Choose a reason for hiding this comment

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

Both apj and mavproxy(apm) use the format key<tab>value (PARM)
This format does not allow comments and empty lines. Kept this part as is.

Mission planner (MP) exports parameters in the format key<comma>value (PARAM).
Also MP is able to read format key<comma>value with any number of empty lines, comments at the end of line, and full-line comments.

Basically I replaced/extended ulog type to more flexible MP format. And made it possible to open for comparison.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

https://ardupilot.org/dev/docs/apjtools-intro.html
maybe apj format should be updated separately, as it supports 4 elements in the row (including @readonly flag).

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.

I'll try to disentangle the definitions of the different extensions, but keep in mind that, AFAIK, there isn't a hard rule for a 1:1 match between extension name and file format.

For example, the ArduPilot apj tool can probably handle .parm and .param files. I haven't tried it and I probably should.

Comment thread src/parasect/build_lib.py Outdated
Comment thread src/parasect/_helpers.py Outdated
Comment on lines +838 to +841
if len(item) < 3:
reasoning = None
else:
reasoning = item[2]
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.

The interface of the function says that the item list should have 3 items. Is there a good reason to assume it doesn't? Perhaps the caller that needs this change should be the one to change?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I see, removed. As I have

    if len(value_reasoning) <= 1:
        params.append("")
    else:
        params.append(value_reasoning[1].strip())

in the split_missionplanner_row() it should provide 3 items

@flyasky flyasky force-pushed the feature/ardupilot-file-format-with-comments branch from e1e59f3 to d7e65ed Compare April 12, 2026 10:21
@flyasky flyasky force-pushed the feature/ardupilot-file-format-with-comments branch from d7e65ed to 6a255d7 Compare April 12, 2026 11:02
@flyasky
Copy link
Copy Markdown
Author

flyasky commented Apr 12, 2026

also fixed some tests

@flyasky
Copy link
Copy Markdown
Author

flyasky commented Apr 30, 2026

@Georacer could you please have another look =)

Copy link
Copy Markdown
Collaborator

@Georacer Georacer left a comment

Choose a reason for hiding this comment

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

You've moved around quite a bit of code and features. Some are not strictly relevant to the spirit of the PR, which is a problem because it makes the review more expansive and it takes longer.

If I understand you correctly, as you mention in the title, what you really want is to add support for comparing and building MP parameter files with comments at the end, comment lines and empty lines.
That's clear and reasonable.

Since you mention that MP is a superset of ULOG, what I'd like to do first is to make a table of all the various parameter formats we have and their related software. Then see where this MP format fits.

I may or may not start from scratch, but for sure I can't merge your PR in its current form. It's a bit too pervasive for my taste. Don't get me wrong, I appreciate your effort immensely and one way or another I'll credit your work.

Thank you!

Comment thread src/parasect/build_lib.py
Comment on lines +751 to +752
return f"{meal.name}.parm"
elif format == Formats.mp:
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.

I'll try to disentangle the definitions of the different extensions, but keep in mind that, AFAIK, there isn't a hard rule for a 1:1 match between extension name and file format.

For example, the ArduPilot apj tool can probably handle .parm and .param files. I haven't tried it and I probably should.

Comment thread src/parasect/_helpers.py
try:
float(params[1])
except ValueError as e:
raise SyntaxError("MP: First row element must be a parameter name string.") from e
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 text is wrong. It should refer to the second element, the parameter value.

Comment thread src/parasect/_helpers.py

try:
with open(filepath) as f:
with open(filepath, encoding='utf-8') as f:
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.

I'm curious why this was necessary.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

for supporting Cyrillic characters in the comments -)

@flyasky flyasky marked this pull request as draft May 2, 2026 19:48
@Georacer
Copy link
Copy Markdown
Collaborator

Georacer commented May 5, 2026

@flyasky I started looking into this.

Here are my findings so far:

Output formats:

GCS Separator Extension
Mission Planner Comma param
QGC QGC-style params
MAVProxy Tab parm
mavparams.py Tab/QGC N/A

Input format compatibility:

Format Mission Planner QGC MAVProxy
Comma Y N Y
Comma with empty lines Y N Y
Comma with inline # Y N N (ignores lines with comments)
Comma with full line # Y N Y
Tab Y N Y
Tab with empty lines Y N Y
Tab with inline # Y N N
Tab with fullline # Y N Y
QGC N Y N
QGC with empty lines N Y N
QGC with inline # N N Buggy, ignores first change N
QGC with fullline # N   N

Next I'll try all of these in Parasect, and then try to add support to whatever's missing.

Maybe there's room for a parameter converter feature here!

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