-
Notifications
You must be signed in to change notification settings - Fork 13.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parameter migration: code cleanup, migration script, and land_detector trial #19489
base: main
Are you sure you want to change the base?
Conversation
c6b3373
to
ae29f90
Compare
@dagar Could you take a look at this please? The only issue I can see so far is MAVROS which is running a bionic container with Python 3.6. I will file a PR to upgrade that to 3.7 or 3.8 as long as there no other side effects of doing so. Also should do a rebase and pass clang tidy, but functionally I think this is complete. If this looks good to you I can continue the work on the other modules. |
As per slack, we're going to go aggressive on this and just migrate the entire codebase + scrap the old junk. In the meantime a sample (land_detector) is pushed. |
|
ecb7465
to
21c6777
Compare
@dagar All of modules and drivers has been migrated. diffing parameters.xml shows no technical changes, only a couple formatting irregularities and a couple strange parameters i had to update (especially the rc_update module). Nonetheless it would be good to get a second eye on it. There are a few remaining files in the libraries and other directories. Will the module.yaml work there as well? (I'll try it tomorrow). Multiple small bugs in the parameter pipeline have been found and fixed. Once we're completely free of C source I'll start simplifying the scripts. Update: something wrong with simulator/battery_simulator, probably because I testing for the fmu-v5x target. Will explore tomorrow. |
14773db
to
bf19ac7
Compare
Everything is now successful except for a new dependency ( @dagar This is ready when you want to take a look. |
Hopefully we can get this in soon to minimize merge conflicts. The tooling will be moved to a separate PR. |
e513654
to
98808e8
Compare
sitl.diff.txt @dagar Here are the diffs |
e1a0de6
to
88dfc98
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for going through this.
try: | ||
import yaml | ||
except ImportError as e: | ||
print("Failed to import yaml: " + str(e)) | ||
print("") | ||
print("You may need to install it using:") | ||
print(" pip3 install --user pyyaml") | ||
print("") | ||
sys.exit(1) | ||
|
||
try: | ||
import cerberus | ||
except ImportError as e: | ||
print("Failed to import cerberus: " + str(e)) | ||
print("") | ||
print("You may need to install it using:") | ||
print(" pip3 install --user cerberus") | ||
print("") | ||
sys.exit(1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you keep these?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, to be honest I find them to be a bit clunky and not super useful. The import statement raises an error if it can't find it and that's pretty readable. Also, pip3 is not the only way to install a package, i.e. system package managers. I feel like its better to just maintain a requirements.txt in the tree that we point to in documentation. What do you think?
@dagar thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know, advanced users will know what to do. We added them when adding new external requirements, for people who updated their branch and it didn't compile anymore.
0d77f38
to
8f4807f
Compare
A little bit of code cleanup in preparation for using srcparser to migrate the c parameter files to yaml definitions. * dataclasses * PEP 8-ish
TODO: not completed, edit commit when finished Migrates all modules to use the new yaml parameter definitions instead of C.
This python script uses the existing parameter build infrastructure to parse c parameter files and generate yaml module definitions.
Fixes a bug where any boolean tag that exists, whether or not the value is actually true, is recorded as true in parameter generation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple more details, generally looks good, but I haven't looked at the param diff.
- can you squash the wip commit (
src/modules: parameter format migration (WIP)
)? - for all the generated commits, can you add the exact shell command(s) to the commit message? This will help for people having merge conflicts.
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser(description='Validate YAML or JSON file(s) against a schema') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is json being handled?
@@ -0,0 +1,24 @@ | |||
argparse |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's already a requirements.txt in https://github.com/PX4/PX4-Autopilot/blob/main/Tools/setup/requirements.txt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I didn't see that. I'll fix.
@@ -17,5 +17,8 @@ jobs: | |||
with: | |||
token: ${{secrets.ACCESS_TOKEN}} | |||
|
|||
- name: install dependencies | |||
run: pip3 install dataclasses |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is this required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
px4params/scrparser.py. When I wrote that I was targeting Python 3.7 compatibility since that's the oldest "supported" Python but I then realized we use 3.6 in some places. This is backwards compatibility for 3.6, dataclasses are built into 3.7+
Daniel and I decided to add it directly here because the bionic docker containers aren't behaving (unrelated to my changes) and I couldn't build a new one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO worth adding a comment in the file or commit message, so we can remove it later on.
@@ -269,7 +269,7 @@ def parse_yaml_serial_config(yaml_config): | |||
else: | |||
default_port_str = port_config['default'] | |||
|
|||
if default_port_str != "": | |||
if default_port_str != "" and default_port_str != 0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When is this a number?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Daniel had used that as a "null" default for the sagetech transponder driver. However I see that just two days back he fixed that. I no longer need this, I'll remove it.
Thanks @bkueng for the review, I will implement your changes in the morning, and squash the WIP commit. If you have time, could you please check the XML and json/md diff on |
I looked at the diff you provided and it looks good. Might be worth checking if QGC doesn't have a problem with the scientific float notation ( |
Hi @coderkalyan , would it help get this PR moving again if we started creating a few smaller |
Hi @mcsauder thanks for pitching in. There are two parts to this PR:
I was talking with the dev team and I am going to try to pull the build system improvements into a separate PR. Merging that will unblock this PR. The main issue with migrating everything here is that we start spending hours on rebasing the generated files all the time. I'm going to additionally split drivers into a new PR, since they don't get updated nearly as often. I think I can get both of those merged soon. Could you please take a couple modules at a time and rebase/create new PRs? I think if you start off with all the *_control modules that would be a good chunk done and we can touch base after that. Please keep in mind that some of the bug fixes I made are required for the system to accept all the new yaml files. If you find any errors building or missing parameters in the generated output, double check with this PR or rebase with my new tooling PR once I push that. Thanks! |
Hi @coderkalyan , just checking in. I'm chipping away on branches to further this PR, but waiting now on #20108 and #20172. I will continue work to get this across the finish line after those PRs. |
Sorry all for the absence. I'm pulling the python tooling updates into a separate PR right now. I'll get this all wrapped up within the next few days. |
Describe problem solved by this pull request
As discussed on Slack, legacy c parameter files can/should be migrated to the newer YAML module definitions.
Describe your solution
This PR:
land_detector
to YAML definitions.Test data / coverage
Not flight tested. Build completes successfully locally, so uploading this to run on CI.