-
Notifications
You must be signed in to change notification settings - Fork 14.5k
Parameter migration: code cleanup, migration script, and land_detector trial #19489
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
base: main
Are you sure you want to change the base?
Changes from all commits
108602b
1292fdc
179255b
9e9a087
935d277
0817791
7358465
4b6179f
a5ffbe7
dfbb110
5cad5c2
22ff3b3
7fe65c6
066ac8a
ed941e7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe 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 commentThe 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. |
||
if default_port_str not in serial_ports: | ||
raise Exception("Default Port {:} not found for {:}".format(default_port_str, serial_command['label'])) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
#! /usr/bin/env python3 | ||
""" Script to validate YAML file(s) against a YAML schema file """ | ||
|
||
import argparse | ||
import logging | ||
import pprint | ||
import sys | ||
import os | ||
|
||
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) | ||
|
||
|
||
def load_data_file(file_name: str): | ||
with open(file_name) as stream: | ||
try: | ||
return yaml.safe_load(stream) | ||
except: | ||
raise Exception("Unable to parse schema file: syntax error or unsupported file format") | ||
|
||
|
||
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 commentThe reason will be displayed to describe this comment to others. Learn more. Where is json being handled? |
||
|
||
parser.add_argument('data_file', nargs='+', help='data file(s)') | ||
parser.add_argument('--schema-file', type=str, action='store', | ||
help='schema file', required=True) | ||
parser.add_argument('--skip-if-no-schema', dest='skip_if_no_schema', | ||
action='store_true', | ||
help='Skip test if schema file does not exist') | ||
parser.add_argument('-v', '--verbose', dest='verbose', action='store_true', | ||
help='Verbose Output') | ||
|
||
args = parser.parse_args() | ||
|
||
data_files = args.data_file | ||
schema_file = args.schema_file | ||
|
||
if args.verbose: | ||
logging.basicConfig(level=logging.INFO) | ||
else: | ||
logging.basicConfig(level=logging.ERROR) | ||
|
||
if args.skip_if_no_schema and not os.path.isfile(schema_file): | ||
logging.info(f"Schema file {schema_file} not found, skipping") | ||
sys.exit(0) | ||
|
||
# load the schema | ||
schema = load_data_file(schema_file) | ||
validator = cerberus.Validator(schema, allow_unknown=False) | ||
|
||
# validate the specified data files | ||
for data_file in data_files: | ||
logging.info(f"Validating {data_file}") | ||
|
||
document = load_data_file(data_file) | ||
|
||
# ignore top-level entries prefixed with __ for yaml module definitions | ||
for key in list(document.keys()): | ||
if key.startswith('__'): | ||
del document[key] | ||
|
||
if not validator.validate(document): | ||
logging.error(f"Found validation errors with {data_file}:") | ||
logging.error(pprint.pformat(validator.errors)) | ||
|
||
raise Exception("Validation of {:} failed".format(data_file)) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
argparse | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Oh, I didn't see that. I'll fix. |
||
argcomplete | ||
coverage | ||
cerberus | ||
empy | ||
jinja2 | ||
kconfiglib | ||
matplotlib==3.0.* | ||
numpy | ||
nunavut>=1.1.0 | ||
packaging | ||
pkgconfig | ||
pyros-genmsg | ||
pyulog | ||
pyyaml | ||
requests | ||
serial | ||
six | ||
toml | ||
psutil | ||
wheel | ||
jsonschema | ||
dataclasses | ||
pynacl |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
module_name: modalai_esc | ||
parameters: | ||
- definitions: | ||
UART_ESC_BAUD: | ||
default: 250000 | ||
description: | ||
long: Default rate is 250Kbps, which is used in off-the-shelf MoadalAI ESC products. | ||
short: UART ESC baud rate | ||
type: int32 | ||
unit: bit/s | ||
volatile: false | ||
UART_ESC_CONFIG: | ||
default: 0 | ||
description: | ||
long: Selects what type of UART ESC, if any, is being used. | ||
short: UART ESC configuration | ||
max: 1 | ||
min: 0 | ||
reboot_required: true | ||
type: enum | ||
values: | ||
0: '- Disabled' | ||
1: '- VOXL ESC' | ||
volatile: false | ||
UART_ESC_MODE: | ||
default: 0 | ||
description: | ||
long: Selects what type of mode is enabled, if any | ||
short: UART ESC Mode | ||
max: 2 | ||
min: 0 | ||
reboot_required: true | ||
type: enum | ||
values: | ||
0: '- None' | ||
1: '- Turtle Mode enabled via AUX1' | ||
2: '- Turtle Mode enabled via AUX2' | ||
volatile: false | ||
UART_ESC_MOTOR1: | ||
default: 3 | ||
description: | ||
short: UART ESC Motor 1 Mapping. 1-4 (negative for reversal) | ||
max: 4 | ||
min: -4 | ||
type: int32 | ||
volatile: false | ||
UART_ESC_MOTOR2: | ||
default: 2 | ||
description: | ||
short: UART ESC Motor 2 Mapping. 1-4 (negative for reversal) | ||
max: 4 | ||
min: -4 | ||
type: int32 | ||
volatile: false | ||
UART_ESC_MOTOR3: | ||
default: 4 | ||
description: | ||
short: UART ESC Motor 3 Mapping. 1-4 (negative for reversal) | ||
max: 4 | ||
min: -4 | ||
type: int32 | ||
volatile: false | ||
UART_ESC_MOTOR4: | ||
default: 1 | ||
description: | ||
short: UART ESC Motor 4 Mapping. 1-4 (negative for reversal) | ||
max: 4 | ||
min: -4 | ||
type: int32 | ||
volatile: false | ||
UART_ESC_RPM_MAX: | ||
default: 15000 | ||
description: | ||
long: Maximum RPM for ESC | ||
short: UART ESC RPM Max | ||
type: int32 | ||
unit: RPM | ||
volatile: false | ||
UART_ESC_RPM_MIN: | ||
default: 5500 | ||
description: | ||
long: Minimum RPM for ESC | ||
short: UART ESC RPM Min | ||
type: int32 | ||
unit: RPM | ||
volatile: false | ||
group: UART ESC | ||
- definitions: | ||
UART_ESC_DEAD1: | ||
decimal: 10 | ||
default: 0.3 | ||
description: | ||
long: Must be greater than Deadzone 2. Absolute value of stick position needed to activate a motor. | ||
short: UART ESC Mode Deadzone 1 | ||
increment: 0.01 | ||
max: 0.99 | ||
min: 0.01 | ||
type: float | ||
volatile: false | ||
group: UART ESC Mode Deadzone 1 | ||
- definitions: | ||
UART_ESC_DEAD2: | ||
decimal: 10 | ||
default: 0.02 | ||
description: | ||
long: Must be less than Deadzone 1. Absolute value of stick position considered no longer on the X or Y axis, thus targetting a specific motor (single). | ||
short: UART ESC Mode Deadzone 2 | ||
increment: 0.01 | ||
max: 0.99 | ||
min: 0.01 | ||
type: float | ||
volatile: false | ||
group: UART ESC Mode Deadzone 2 |
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.