feat: add support of comma-separated param files with comments and empty lines#402
feat: add support of comma-separated param files with comments and empty lines#402flyasky wants to merge 1 commit into
Conversation
48bef53 to
e1e59f3
Compare
|
@Georacer could you please review this MR? |
Georacer
left a comment
There was a problem hiding this comment.
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?
| ARDUPILOT_DEFAULT_PARM = Path(ARDUPILOT_ASSETS_PATH) / "sitl_copter_defaults.parm" | ||
| ARDUPILOT_DEFAULT_PARAM = Path(ARDUPILOT_ASSETS_PATH) / "sitl_plane_defaults.param" |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
| 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) |
There was a problem hiding this comment.
Is there really a need to rename this constant?
There was a problem hiding this comment.
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.
| return f"{meal.name}.parm" | ||
| elif format == Formats.mp: |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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.
| if len(item) < 3: | ||
| reasoning = None | ||
| else: | ||
| reasoning = item[2] |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
e1e59f3 to
d7e65ed
Compare
d7e65ed to
6a255d7
Compare
|
also fixed some tests |
|
@Georacer could you please have another look =) |
Georacer
left a comment
There was a problem hiding this comment.
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!
| return f"{meal.name}.parm" | ||
| elif format == Formats.mp: |
There was a problem hiding this comment.
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.
| try: | ||
| float(params[1]) | ||
| except ValueError as e: | ||
| raise SyntaxError("MP: First row element must be a parameter name string.") from e |
There was a problem hiding this comment.
This text is wrong. It should refer to the second element, the parameter value.
|
|
||
| try: | ||
| with open(filepath) as f: | ||
| with open(filepath, encoding='utf-8') as f: |
There was a problem hiding this comment.
I'm curious why this was necessary.
There was a problem hiding this comment.
for supporting Cyrillic characters in the comments -)
|
@flyasky I started looking into this. Here are my findings so far: Output formats:
Input format compatibility:
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! |

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