From ab1d76ae7d42592f4ce3f26fc0c964d603ddb85d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Tue, 5 Oct 2021 13:26:52 +0200 Subject: [PATCH] params: use PWM_MAIN_* instead of PWM_FMU_* --- .../airframes/10017_iris_ctrlalloc | 8 +-- .../airframes/6012_typhoon_h480_ctrlalloc | 12 ++-- .../init.d/airframes/4018_s500_ctrlalloc | 8 +-- .../init.d/airframes/6003_hexa_x_ctrlalloc | 12 ++-- Tools/module_config/generate_params.py | 19 +++++-- cmake/kconfig.cmake | 1 + src/drivers/dshot/DShot.h | 7 ++- src/drivers/pwm_out/PWMOut.hpp | 7 ++- src/drivers/pwm_out/module.yaml | 4 +- src/drivers/pwm_out_sim/PWMSim.hpp | 2 +- src/drivers/pwm_out_sim/module.yaml | 4 +- src/lib/parameters/CMakeLists.txt | 5 +- src/lib/pwm/pwm_aux_params.yaml | 57 ------------------- src/lib/pwm/pwm_main_params.yaml | 57 ------------------- validation/module_schema.yaml | 4 +- 15 files changed, 58 insertions(+), 149 deletions(-) diff --git a/ROMFS/px4fmu_common/init.d-posix/airframes/10017_iris_ctrlalloc b/ROMFS/px4fmu_common/init.d-posix/airframes/10017_iris_ctrlalloc index ee2fab09d9..ac0294cacf 100644 --- a/ROMFS/px4fmu_common/init.d-posix/airframes/10017_iris_ctrlalloc +++ b/ROMFS/px4fmu_common/init.d-posix/airframes/10017_iris_ctrlalloc @@ -46,10 +46,10 @@ param set-default CA_MC_R3_PY 0.1875 param set-default CA_MC_R3_CT 6.5 param set-default CA_MC_R3_KM -0.05 -param set-default PWM_FMU_FUNC1 101 -param set-default PWM_FMU_FUNC2 102 -param set-default PWM_FMU_FUNC3 103 -param set-default PWM_FMU_FUNC4 104 +param set-default PWM_MAIN_FUNC1 101 +param set-default PWM_MAIN_FUNC2 102 +param set-default PWM_MAIN_FUNC3 103 +param set-default PWM_MAIN_FUNC4 104 set MIXER skip set MIXER_AUX none diff --git a/ROMFS/px4fmu_common/init.d-posix/airframes/6012_typhoon_h480_ctrlalloc b/ROMFS/px4fmu_common/init.d-posix/airframes/6012_typhoon_h480_ctrlalloc index 8357ce1c67..5517b892d2 100644 --- a/ROMFS/px4fmu_common/init.d-posix/airframes/6012_typhoon_h480_ctrlalloc +++ b/ROMFS/px4fmu_common/init.d-posix/airframes/6012_typhoon_h480_ctrlalloc @@ -76,12 +76,12 @@ param set-default CA_MC_R5_PY -0.5 param set-default CA_MC_R5_CT 9.5 param set-default CA_MC_R5_KM -0.05 -param set-default PWM_FMU_FUNC1 101 -param set-default PWM_FMU_FUNC2 102 -param set-default PWM_FMU_FUNC3 103 -param set-default PWM_FMU_FUNC4 104 -param set-default PWM_FMU_FUNC5 105 -param set-default PWM_FMU_FUNC6 106 +param set-default PWM_MAIN_FUNC1 101 +param set-default PWM_MAIN_FUNC2 102 +param set-default PWM_MAIN_FUNC3 103 +param set-default PWM_MAIN_FUNC4 104 +param set-default PWM_MAIN_FUNC5 105 +param set-default PWM_MAIN_FUNC6 106 set MAV_TYPE 13 diff --git a/ROMFS/px4fmu_common/init.d/airframes/4018_s500_ctrlalloc b/ROMFS/px4fmu_common/init.d/airframes/4018_s500_ctrlalloc index f941f6e9a1..3759c229e6 100644 --- a/ROMFS/px4fmu_common/init.d/airframes/4018_s500_ctrlalloc +++ b/ROMFS/px4fmu_common/init.d/airframes/4018_s500_ctrlalloc @@ -52,8 +52,8 @@ param set-default CA_MC_R3_PY 0.177 param set-default CA_MC_R3_CT 6.5 param set-default CA_MC_R3_KM -0.05 -param set-default PWM_FMU_FUNC1 101 -param set-default PWM_FMU_FUNC2 102 -param set-default PWM_FMU_FUNC3 103 -param set-default PWM_FMU_FUNC4 104 +param set-default PWM_MAIN_FUNC1 101 +param set-default PWM_MAIN_FUNC2 102 +param set-default PWM_MAIN_FUNC3 103 +param set-default PWM_MAIN_FUNC4 104 diff --git a/ROMFS/px4fmu_common/init.d/airframes/6003_hexa_x_ctrlalloc b/ROMFS/px4fmu_common/init.d/airframes/6003_hexa_x_ctrlalloc index c122f51fd2..72ed7f4ebc 100644 --- a/ROMFS/px4fmu_common/init.d/airframes/6003_hexa_x_ctrlalloc +++ b/ROMFS/px4fmu_common/init.d/airframes/6003_hexa_x_ctrlalloc @@ -66,12 +66,12 @@ param set-default CA_MC_R5_PY -0.1375 param set-default CA_MC_R5_CT 6.5 param set-default CA_MC_R5_KM -0.05 -param set-default PWM_FMU_FUNC1 101 -param set-default PWM_FMU_FUNC2 102 -param set-default PWM_FMU_FUNC3 103 -param set-default PWM_FMU_FUNC4 104 -param set-default PWM_FMU_FUNC5 105 -param set-default PWM_FMU_FUNC6 106 +param set-default PWM_MAIN_FUNC1 101 +param set-default PWM_MAIN_FUNC2 102 +param set-default PWM_MAIN_FUNC3 103 +param set-default PWM_MAIN_FUNC4 104 +param set-default PWM_MAIN_FUNC5 105 +param set-default PWM_MAIN_FUNC6 106 set MIXER skip set MIXER_AUX none diff --git a/Tools/module_config/generate_params.py b/Tools/module_config/generate_params.py index a1f7de2a2f..45492f790a 100755 --- a/Tools/module_config/generate_params.py +++ b/Tools/module_config/generate_params.py @@ -31,6 +31,9 @@ parser.add_argument('--ethernet', action='store_true', help='Ethernet support') parser.add_argument('--board', type=str, action='store', help='board name, e.g. ') +parser.add_argument('--board-with-io', dest='board_with_io', action='store_true', + help='Indicate that the board as an IO for extra PWM', + default=False) parser.add_argument('-v', '--verbose', dest='verbose', action='store_true', help='Verbose Output') @@ -40,23 +43,30 @@ verbose = args.verbose params_output_file = args.params_file timer_config_file = args.timer_config ethernet_supported = args.ethernet +board_with_io = args.board_with_io board = args.board root_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)),"../..") output_functions_file = os.path.join(root_dir,"src/lib/mixer_module/output_functions.yaml") def process_param_prefix(param_prefix): - if param_prefix == '${PWM_FMU_OR_HIL}': - if board == 'px4_sitl': return 'PWM_FMU' + if param_prefix == '${PWM_MAIN_OR_HIL}': + if board == 'px4_sitl': return 'PWM_MAIN' return 'HIL_ACT' + if param_prefix == '${PWM_MAIN_OR_AUX}': + if board_with_io: return 'PWM_AUX' + return 'PWM_MAIN' if '${' in param_prefix: raise Exception('unhandled variable in {:}'.format(param_prefix)) return param_prefix def process_channel_label(channel_label): - if channel_label == '${PWM_FMU_OR_HIL}': + if channel_label == '${PWM_MAIN_OR_HIL}': if board == 'px4_sitl': return 'PWM Sim' return 'HIL actuator' + if channel_label == '${PWM_MAIN_OR_AUX}': + if board_with_io: return 'PWM Aux' + return 'PWM Main' if '${' in channel_label: raise Exception('unhandled variable in {:}'.format(channel_label)) return channel_label @@ -171,9 +181,8 @@ def get_actuator_output_params(yaml_config, output_functions, # We do this by extending the output_groups list and parse in a later iteration if 'generator' in group: if group['generator'] == 'pwm': - # We might set these depending on presence of IO in build... param_prefix = process_param_prefix(group['param_prefix']) - channel_labels = group['channel_labels'] + channel_labels = [process_channel_label(label) for label in group['channel_labels']] standard_params = group.get('standard_params', []) extra_function_groups = group.get('extra_function_groups', []) pwm_timer_param = group.get('pwm_timer_param', None) diff --git a/cmake/kconfig.cmake b/cmake/kconfig.cmake index b31e9bdaa4..3b547dc46b 100644 --- a/cmake/kconfig.cmake +++ b/cmake/kconfig.cmake @@ -256,6 +256,7 @@ if(EXISTS ${BOARD_DEFCONFIG}) # IO board (placed in ROMFS) if(IO) set(config_io_board ${IO} CACHE INTERNAL "IO" FORCE) + add_definitions(-DBOARD_WITH_IO) endif() if(UAVCAN_PERIPHERALS) diff --git a/src/drivers/dshot/DShot.h b/src/drivers/dshot/DShot.h index 7fdb6c85b8..ac4cdb1c24 100644 --- a/src/drivers/dshot/DShot.h +++ b/src/drivers/dshot/DShot.h @@ -140,7 +140,12 @@ private: void update_telemetry_num_motors(); - MixingOutput _mixing_output{"PWM_FMU", DIRECT_PWM_OUTPUT_CHANNELS, *this, MixingOutput::SchedulingPolicy::Auto, false, false}; +#ifdef BOARD_WITH_IO +# define PARAM_PREFIX "PWM_AUX" +#else +# define PARAM_PREFIX "PWM_MAIN" +#endif + MixingOutput _mixing_output {PARAM_PREFIX, DIRECT_PWM_OUTPUT_CHANNELS, *this, MixingOutput::SchedulingPolicy::Auto, false, false}; Telemetry *_telemetry{nullptr}; diff --git a/src/drivers/pwm_out/PWMOut.hpp b/src/drivers/pwm_out/PWMOut.hpp index c9a9a42f37..b6167381cc 100644 --- a/src/drivers/pwm_out/PWMOut.hpp +++ b/src/drivers/pwm_out/PWMOut.hpp @@ -130,7 +130,12 @@ private: static const int MAX_PER_INSTANCE{8}; - MixingOutput _mixing_output{"PWM_FMU", FMU_MAX_ACTUATORS, *this, MixingOutput::SchedulingPolicy::Auto, true}; +#ifdef BOARD_WITH_IO +# define PARAM_PREFIX "PWM_AUX" +#else +# define PARAM_PREFIX "PWM_MAIN" +#endif + MixingOutput _mixing_output {PARAM_PREFIX, FMU_MAX_ACTUATORS, *this, MixingOutput::SchedulingPolicy::Auto, true}; uint32_t _backup_schedule_interval_us{1_s}; diff --git a/src/drivers/pwm_out/module.yaml b/src/drivers/pwm_out/module.yaml index 490554edba..bec86df77e 100644 --- a/src/drivers/pwm_out/module.yaml +++ b/src/drivers/pwm_out/module.yaml @@ -2,8 +2,8 @@ module_name: PWM Output actuator_output: output_groups: - generator: pwm - param_prefix: PWM_FMU - channel_labels: ['PWM Main', 'PWM Capture'] + param_prefix: '${PWM_MAIN_OR_AUX}' + channel_labels: ['${PWM_MAIN_OR_AUX}', 'PWM Capture'] standard_params: disarmed: { min: 800, max: 2200, default: 900 } min: { min: 800, max: 1400, default: 1000 } diff --git a/src/drivers/pwm_out_sim/PWMSim.hpp b/src/drivers/pwm_out_sim/PWMSim.hpp index fc25ac68a9..e845def2b9 100644 --- a/src/drivers/pwm_out_sim/PWMSim.hpp +++ b/src/drivers/pwm_out_sim/PWMSim.hpp @@ -45,7 +45,7 @@ #include #if defined(CONFIG_ARCH_BOARD_PX4_SITL) -#define PARAM_PREFIX "PWM_FMU" +#define PARAM_PREFIX "PWM_MAIN" #else #define PARAM_PREFIX "HIL_ACT" #endif diff --git a/src/drivers/pwm_out_sim/module.yaml b/src/drivers/pwm_out_sim/module.yaml index e1a4baa2f4..4a74becf49 100644 --- a/src/drivers/pwm_out_sim/module.yaml +++ b/src/drivers/pwm_out_sim/module.yaml @@ -2,7 +2,7 @@ module_name: PWM Sim actuator_output: output_groups: - - param_prefix: ${PWM_FMU_OR_HIL} - channel_label: ${PWM_FMU_OR_HIL} + - param_prefix: ${PWM_MAIN_OR_HIL} + channel_label: ${PWM_MAIN_OR_HIL} num_channels: 16 diff --git a/src/lib/parameters/CMakeLists.txt b/src/lib/parameters/CMakeLists.txt index bc3c07044c..1813851950 100644 --- a/src/lib/parameters/CMakeLists.txt +++ b/src/lib/parameters/CMakeLists.txt @@ -79,6 +79,9 @@ endif() if(PX4_ETHERNET) set(added_arguments --ethernet) endif() +if(config_io_board) + set(board_with_io_arg --board-with-io) +endif() add_custom_command(OUTPUT ${generated_serial_params_file} ${generated_module_params_file} COMMAND ${CMAKE_COMMAND} -E make_directory ${generated_params_dir} COMMAND ${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/Tools/serial/generate_config.py @@ -87,7 +90,7 @@ add_custom_command(OUTPUT ${generated_serial_params_file} ${generated_module_par --config-files ${module_config_files} #--verbose COMMAND ${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/Tools/module_config/generate_params.py --params-file ${generated_module_params_file} - ${added_arguments} + ${added_arguments} ${board_with_io_arg} --timer-config ${PX4_BOARD_DIR}/src/timer_config.cpp --config-files ${module_config_files} #--verbose --board ${PX4_BOARD} diff --git a/src/lib/pwm/pwm_aux_params.yaml b/src/lib/pwm/pwm_aux_params.yaml index c42ad103e5..2e659c9d41 100644 --- a/src/lib/pwm/pwm_aux_params.yaml +++ b/src/lib/pwm/pwm_aux_params.yaml @@ -63,63 +63,6 @@ parameters: max: 2200 default: 1500 - PWM_AUX_MIN${i}: - description: - short: PWM aux ${i} minimum value - long: | - This is the minimum PWM pulse the autopilot is allowed to output. - When set to -1 the value for PWM_AUX_MIN will be used - type: int32 - unit: us - min: -1 - max: 1600 - num_instances: *max_num_config_instances - instance_start: 1 - default: -1 - - PWM_AUX_MAX${i}: - description: - short: PWM aux ${i} maximum value - long: | - This is the maximum PWM pulse the autopilot is allowed to output. - When set to -1 the value for PWM_AUX_MAX will be used - type: int32 - unit: us - min: -1 - max: 2150 - num_instances: *max_num_config_instances - instance_start: 1 - default: -1 - - PWM_AUX_FAIL${i}: - description: - short: PWM aux ${i} failsafe value - long: | - This is the PWM pulse the autopilot is outputting if in failsafe mode. - When set to -1 the value is set automatically depending if the actuator - is a motor (900us) or a servo (1500us) - type: int32 - unit: us - min: -1 - max: 2150 - num_instances: *max_num_config_instances - instance_start: 1 - default: -1 - - PWM_AUX_DIS${i}: - description: - short: PWM aux ${i} disarmed value - long: | - This is the PWM pulse the autopilot is outputting if not armed. - When set to -1 the value for PWM_AUX_DISARM will be used - type: int32 - unit: us - min: -1 - max: 2150 - num_instances: *max_num_config_instances - instance_start: 1 - default: -1 - PWM_AUX_TRIM${i}: description: short: PWM aux ${i} trim value diff --git a/src/lib/pwm/pwm_main_params.yaml b/src/lib/pwm/pwm_main_params.yaml index ad866f31f2..ec4b5be769 100644 --- a/src/lib/pwm/pwm_main_params.yaml +++ b/src/lib/pwm/pwm_main_params.yaml @@ -63,63 +63,6 @@ parameters: max: 2200 default: 900 - PWM_MAIN_MIN${i}: - description: - short: PWM main ${i} minimum value - long: | - This is the minimum PWM pulse the autopilot is allowed to output. - When set to -1 the value for PWM_MAIN_MIN will be used - type: int32 - unit: us - min: -1 - max: 1600 - num_instances: *max_num_config_instances - instance_start: 1 - default: -1 - - PWM_MAIN_MAX${i}: - description: - short: PWM main ${i} maximum value - long: | - This is the maximum PWM pulse the autopilot is allowed to output. - When set to -1 the value for PWM_MAIN_MAX will be used - type: int32 - unit: us - min: -1 - max: 2150 - num_instances: *max_num_config_instances - instance_start: 1 - default: -1 - - PWM_MAIN_FAIL${i}: - description: - short: PWM main ${i} failsafe value - long: | - This is the PWM pulse the autopilot is outputting if in failsafe mode. - When set to -1 the value is set automatically depending if the actuator - is a motor (900us) or a servo (1500us) - type: int32 - unit: us - min: -1 - max: 2150 - num_instances: *max_num_config_instances - instance_start: 1 - default: -1 - - PWM_MAIN_DIS${i}: - description: - short: PWM main ${i} disarmed value - long: | - This is the PWM pulse the autopilot is outputting if not armed. - When set to -1 the value for PWM_MAIN_DISARM will be used - type: int32 - unit: us - min: -1 - max: 2150 - num_instances: *max_num_config_instances - instance_start: 1 - default: -1 - PWM_MAIN_TRIM${i}: description: short: PWM main ${i} trim value diff --git a/validation/module_schema.yaml b/validation/module_schema.yaml index 47848d96df..87464c17e8 100644 --- a/validation/module_schema.yaml +++ b/validation/module_schema.yaml @@ -240,10 +240,10 @@ actuator_output: type: string allowed: [ pwm ] param_prefix: - # parameter prefix for the min/max/disarmed/func params, e.g. PWM_FMU. + # parameter prefix for the min/max/disarmed/func params, e.g. PWM_MAIN. # This also needs to be specified in the source code. type: string - regex: '([0-9A-Z_]+|\$\{PWM_FMU_OR_HIL\})' + regex: '([0-9A-Z_]+|\$\{PWM_MAIN_OR_AUX\}|\$\{PWM_MAIN_OR_HIL\})' required: true channel_label: # Human-readable per-channel label (index will be added), e.g. 'PWM Main'