forked from Archive/PX4-Autopilot
actuator params: use module_name as prefix to channel label
This commit is contained in:
parent
6537f480b1
commit
2ff6baa250
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/env python3
|
||||
""" Script to params from module.yaml config file(s)
|
||||
""" Script to generate params from module.yaml config file(s)
|
||||
Note: serial params are handled in Tools/serial/generate_config.py
|
||||
"""
|
||||
|
||||
|
@ -50,6 +50,14 @@ 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_module_name(module_name):
|
||||
if module_name == '${PWM_MAIN_OR_AUX}':
|
||||
if board_with_io: return 'PWM AUX'
|
||||
return 'PWM MAIN'
|
||||
if '${' in module_name:
|
||||
raise Exception('unhandled variable in {:}'.format(module_name))
|
||||
return module_name
|
||||
|
||||
def process_param_prefix(param_prefix):
|
||||
if param_prefix == '${PWM_MAIN_OR_HIL}':
|
||||
if board == 'px4_sitl': return 'PWM_MAIN'
|
||||
|
@ -61,16 +69,19 @@ def process_param_prefix(param_prefix):
|
|||
raise Exception('unhandled variable in {:}'.format(param_prefix))
|
||||
return param_prefix
|
||||
|
||||
def process_channel_label(channel_label):
|
||||
def process_channel_label(module_name, channel_label, no_prefix):
|
||||
if channel_label == '${PWM_MAIN_OR_HIL}':
|
||||
if board == 'px4_sitl': return 'PWM Sim'
|
||||
return 'HIL actuator'
|
||||
if channel_label == '${PWM_MAIN_OR_AUX_CAP}':
|
||||
return 'PWM Capture'
|
||||
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
|
||||
if no_prefix: return channel_label
|
||||
return module_name + ' ' + channel_label
|
||||
|
||||
|
||||
def parse_yaml_parameters_config(yaml_config, ethernet_supported):
|
||||
|
@ -162,6 +173,7 @@ def get_actuator_output_params(yaml_config, output_functions,
|
|||
if not 'actuator_output' in yaml_config:
|
||||
return {}
|
||||
output_groups = yaml_config['actuator_output']['output_groups']
|
||||
module_name = process_module_name(yaml_config['module_name'])
|
||||
all_params = {}
|
||||
group_idx = 0
|
||||
|
||||
|
@ -183,7 +195,9 @@ def get_actuator_output_params(yaml_config, output_functions,
|
|||
if 'generator' in group:
|
||||
if group['generator'] == 'pwm':
|
||||
param_prefix = process_param_prefix(group['param_prefix'])
|
||||
channel_labels = [process_channel_label(label) for label in group['channel_labels']]
|
||||
no_prefix = not group.get('channel_label_module_name_prefix', True)
|
||||
channel_labels = [process_channel_label(module_name, label, no_prefix)
|
||||
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)
|
||||
|
@ -219,7 +233,8 @@ def get_actuator_output_params(yaml_config, output_functions,
|
|||
|
||||
num_channels = group['num_channels']
|
||||
param_prefix = process_param_prefix(group['param_prefix'])
|
||||
channel_label = process_channel_label(group['channel_label'])
|
||||
no_prefix = not group.get('channel_label_module_name_prefix', True)
|
||||
channel_label = process_channel_label(module_name, group['channel_label'], no_prefix)
|
||||
standard_params = group.get('standard_params', {})
|
||||
instance_start = group.get('instance_start', 1)
|
||||
instance_start_label = group.get('instance_start_label', instance_start)
|
||||
|
|
|
@ -2,7 +2,7 @@ module_name: PWM Output
|
|||
actuator_output:
|
||||
output_groups:
|
||||
- param_prefix: PWM
|
||||
channel_label: 'PWM Actuator'
|
||||
channel_label: 'Channel'
|
||||
standard_params:
|
||||
disarmed: { min: 800, max: 2200, default: 900 }
|
||||
min: { min: 800, max: 1400, default: 1000 }
|
||||
|
|
|
@ -2,7 +2,7 @@ module_name: PCA9685 Output
|
|||
actuator_output:
|
||||
output_groups:
|
||||
- param_prefix: PCA9685
|
||||
channel_label: 'PCA9685'
|
||||
channel_label: 'Channel'
|
||||
standard_params:
|
||||
disarmed: { min: 800, max: 2200, default: 900 }
|
||||
min: { min: 800, max: 1400, default: 1000 }
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
module_name: PWM Output
|
||||
module_name: '${PWM_MAIN_OR_AUX}'
|
||||
actuator_output:
|
||||
output_groups:
|
||||
- generator: pwm
|
||||
param_prefix: '${PWM_MAIN_OR_AUX}'
|
||||
channel_labels: ['${PWM_MAIN_OR_AUX}', 'PWM Capture']
|
||||
channel_labels: ['${PWM_MAIN_OR_AUX}', '${PWM_MAIN_OR_AUX_CAP}']
|
||||
standard_params:
|
||||
disarmed: { min: 800, max: 2200, default: 900 }
|
||||
min: { min: 800, max: 1400, default: 1000 }
|
||||
|
@ -30,3 +30,4 @@ actuator_output:
|
|||
200: PWM200
|
||||
400: PWM400
|
||||
reboot_required: true
|
||||
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
module_name: IO PWM Output
|
||||
module_name: PWM MAIN
|
||||
actuator_output:
|
||||
output_groups:
|
||||
- generator: pwm
|
||||
param_prefix: PWM_MAIN
|
||||
channel_labels: ['PWM Main', 'PWM Capture']
|
||||
channel_labels: ['MAIN', 'Capture']
|
||||
channel_label_module_name_prefix: false
|
||||
timer_config_file: "boards/px4/io-v2/src/timer_config.cpp"
|
||||
standard_params:
|
||||
disarmed: { min: 800, max: 2200, default: 900 }
|
||||
|
|
|
@ -2,5 +2,5 @@ module_name: TAP ESC Output
|
|||
actuator_output:
|
||||
output_groups:
|
||||
- param_prefix: TAP_ESC
|
||||
channel_label: 'TAP ESC'
|
||||
channel_label: 'ESC'
|
||||
num_channels: 8
|
||||
|
|
|
@ -3,14 +3,16 @@ module_name: UAVCAN
|
|||
actuator_output:
|
||||
output_groups:
|
||||
- param_prefix: UAVCAN_EC
|
||||
channel_label: 'UAVCAN ESC'
|
||||
group_label: 'ESCs'
|
||||
channel_label: 'ESC'
|
||||
standard_params:
|
||||
min: { min: 0, max: 8191, default: 1 }
|
||||
max: { min: 0, max: 8191, default: 8191 }
|
||||
failsafe: { min: 0, max: 8191 }
|
||||
num_channels: 8
|
||||
- param_prefix: UAVCAN_SV
|
||||
channel_label: 'UAVCAN Servo'
|
||||
group_label: 'Servos'
|
||||
channel_label: 'Servo'
|
||||
standard_params:
|
||||
disarmed: { min: 0, max: 1000, default: 500 }
|
||||
min: { min: 0, max: 1000, default: 0 }
|
||||
|
|
|
@ -2,7 +2,7 @@ module_name: UAVCANv1
|
|||
actuator_output:
|
||||
output_groups:
|
||||
- param_prefix: UCAN1_ESC
|
||||
channel_label: 'UAVCAN ESC'
|
||||
channel_label: 'ESC'
|
||||
standard_params:
|
||||
min: { min: 0, max: 8191, default: 1 }
|
||||
max: { min: 0, max: 8191, default: 8191 }
|
||||
|
|
|
@ -248,6 +248,11 @@ actuator_output:
|
|||
channel_label:
|
||||
# Human-readable per-channel label (index will be added), e.g. 'PWM Main'
|
||||
type: string
|
||||
channel_label_module_name_prefix:
|
||||
# by default, the module_name is prefixed to the
|
||||
# channel_label as part of the param description. Set
|
||||
# this to false to turn it off
|
||||
type: boolean
|
||||
num_channels:
|
||||
# (maximum) number of channels
|
||||
type: integer
|
||||
|
|
Loading…
Reference in New Issue