From 9c467198bef1b7f7effe961ce54f2617ba4c213b Mon Sep 17 00:00:00 2001 From: SalimTerryLi Date: Sat, 29 Apr 2023 18:57:14 +0800 Subject: [PATCH] module_config: support custom actuators_metadata backed by module-level params --- .../generate_actuators_metadata.py | 13 ++++- validation/module_schema.yaml | 53 ++++++++++--------- 2 files changed, 40 insertions(+), 26 deletions(-) diff --git a/Tools/module_config/generate_actuators_metadata.py b/Tools/module_config/generate_actuators_metadata.py index 089e4585ed..196119259b 100755 --- a/Tools/module_config/generate_actuators_metadata.py +++ b/Tools/module_config/generate_actuators_metadata.py @@ -264,7 +264,18 @@ def get_actuator_output(yaml_config, output_functions, timer_config_file, verbos } per_channel_params.append(param) - # TODO: support non-standard per-channel parameters + custom_params = group.get('custom_params', []) + for custom_param in custom_params: + # Simply pulls all custom params, assuming they are valid ones + param = { + 'name': param_prefix+'_'+custom_param['name'], + } + # TODO: check and match the custom params in output_groups with module-level parameters + del custom_param['name'] + for param_key in custom_param: + # '-' is used in actuators.schema.json, while '_' is used in module_schema.yml + param[param_key.replace('_', '-')] = custom_param[param_key] + per_channel_params.append(param) subgroup['per-channel-parameters'] = per_channel_params diff --git a/validation/module_schema.yaml b/validation/module_schema.yaml index d66b65bf80..6d733a6e51 100644 --- a/validation/module_schema.yaml +++ b/validation/module_schema.yaml @@ -369,6 +369,33 @@ actuator_output: # ui only shows the param if this condition is true type: string regex: *condition_regex + custom_params: + type: list + schema: &mixer_parameter + type: dict + schema: + label: + type: string + name: + # param name + type: string + required: true + show_as: + type: string + allowed: [ 'bitset', 'true-if-positive' ] + show_if: + # condition + type: string + regex: *condition_regex + index_offset: + type: integer + advanced: + type: integer + function: + type: string + identifier: + # for rules + type: string extra_function_groups: # Additional function groups to add, defined in output_functions.yaml type: list @@ -477,31 +504,7 @@ mixer: per_item_parameters: type: list minlength: 1 - schema: &mixer_parameter - type: dict - schema: - label: - type: string - name: - # param name - type: string - required: true - show_as: - type: string - allowed: [ 'bitset', 'true-if-positive' ] - show_if: - # condition - type: string - regex: *condition_regex - index_offset: - type: integer - advanced: - type: integer - function: - type: string - identifier: - # for rules - type: string + schema: *mixer_parameter rules: # mixer rules, validated by the mavlink actuator component information schema type: list