mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-11 05:23:35 +08:00
move center after standard params
This commit is contained in:
@@ -180,6 +180,7 @@ def get_actuator_output(yaml_config, output_functions, timer_config_file, verbos
|
||||
channel_labels = [process_channel_label(module_name, label, no_prefix)
|
||||
for label in group['channel_labels']]
|
||||
standard_params = group.get('standard_params', [])
|
||||
center = group.get('center', None)
|
||||
extra_function_groups = group.get('extra_function_groups', [])
|
||||
pwm_timer_param = group.get('pwm_timer_param', None)
|
||||
if 'timer_config_file' in group:
|
||||
@@ -189,7 +190,7 @@ def get_actuator_output(yaml_config, output_functions, timer_config_file, verbos
|
||||
timer_groups = get_timer_groups(timer_config_file, verbose)
|
||||
timer_output_groups, timer_params = get_output_groups(timer_groups,
|
||||
param_prefix, channel_labels,
|
||||
standard_params, extra_function_groups, pwm_timer_param,
|
||||
standard_params, center, extra_function_groups, pwm_timer_param,
|
||||
verbose=verbose)
|
||||
output_groups.extend(timer_output_groups)
|
||||
else:
|
||||
@@ -233,6 +234,7 @@ def get_actuator_output(yaml_config, output_functions, timer_config_file, verbos
|
||||
per_channel_params = []
|
||||
param_prefix = process_param_prefix(group['param_prefix'])
|
||||
standard_params = group.get('standard_params', {})
|
||||
center = group.get('center', None)
|
||||
standard_params_array = [
|
||||
( 'function', 'Function', 'FUNC', False ),
|
||||
( 'disarmed', 'Disarmed', 'DIS', False ),
|
||||
@@ -255,11 +257,12 @@ def get_actuator_output(yaml_config, output_functions, timer_config_file, verbos
|
||||
if show_if: param['show-if'] = show_if
|
||||
per_channel_params.append(param)
|
||||
|
||||
center = {
|
||||
'label': 'Center\n(for Servos)',
|
||||
'name': param_prefix+'_CENT${i}',
|
||||
}
|
||||
per_channel_params.append(center)
|
||||
if center is not None:
|
||||
center_param = {
|
||||
'label': 'Center\n(for Servos)',
|
||||
'name': param_prefix+'_CENT${i}',
|
||||
}
|
||||
per_channel_params.append(center_param)
|
||||
param = {
|
||||
'label': 'Rev Range\n(for Servos)',
|
||||
'name': param_prefix+'_REV',
|
||||
|
||||
@@ -202,6 +202,7 @@ def get_actuator_output_params(yaml_config, output_functions,
|
||||
channel_labels = [process_channel_label(module_name, label, no_prefix)
|
||||
for label in group['channel_labels']]
|
||||
standard_params = group.get('standard_params', [])
|
||||
center = group.get('center', None)
|
||||
extra_function_groups = group.get('extra_function_groups', [])
|
||||
pwm_timer_param = group.get('pwm_timer_param', None)
|
||||
if 'timer_config_file' in group:
|
||||
@@ -211,7 +212,7 @@ def get_actuator_output_params(yaml_config, output_functions,
|
||||
timer_groups = get_timer_groups(timer_config_file, verbose)
|
||||
timer_output_groups, timer_params = get_output_groups(timer_groups,
|
||||
param_prefix, channel_labels,
|
||||
standard_params, extra_function_groups, pwm_timer_param,
|
||||
standard_params, center, extra_function_groups, pwm_timer_param,
|
||||
verbose=verbose)
|
||||
all_params.update(timer_params)
|
||||
output_groups.extend(timer_output_groups)
|
||||
@@ -225,6 +226,7 @@ def get_actuator_output_params(yaml_config, output_functions,
|
||||
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', {})
|
||||
center_param = group.get('center', None)
|
||||
instance_start = group.get('instance_start', 1)
|
||||
instance_start_label = group.get('instance_start_label', instance_start)
|
||||
if len(param_prefix) > 9: # 16 - len('_FAIL') - 2 (2 digits for index)
|
||||
@@ -299,7 +301,6 @@ When set to -1 (default), the value depends on the function (see {:}).
|
||||
standard_params_array = [
|
||||
( 'disarmed', 'Disarmed', 'DIS', disarmed_description ),
|
||||
( 'min', 'Minimum', 'MIN', minimum_description ),
|
||||
( 'center', 'Center', 'CENT', center_description ),
|
||||
( 'max', 'Maximum', 'MAX', maximum_description ),
|
||||
( 'failsafe', 'Failsafe', 'FAIL', failsafe_description ),
|
||||
]
|
||||
@@ -316,10 +317,6 @@ When set to -1 (default), the value depends on the function (see {:}).
|
||||
standard_params[key]['default'] = -1
|
||||
standard_params[key]['min'] = -1
|
||||
|
||||
if key == 'center':
|
||||
standard_params[key]['default'] = -1
|
||||
standard_params[key]['min'] = -1
|
||||
|
||||
param = {
|
||||
'description': {
|
||||
'short': channel_label+' ${i} '+label+' Value',
|
||||
@@ -335,6 +332,33 @@ When set to -1 (default), the value depends on the function (see {:}).
|
||||
}
|
||||
add_local_param(param_prefix+'_'+param_suffix+'${i}', param)
|
||||
|
||||
# center param is handled after standard params
|
||||
if center_param is not None:
|
||||
|
||||
# values must be in range of an uint16_t
|
||||
if center_param['min'] < 0:
|
||||
raise Exception('minimum value for center expected >= 0 (got {:})'.format(center_param['min']))
|
||||
if center_param['max'] >= 1<<16:
|
||||
raise Exception('maximum value for center expected <= {:} (got {:})'.format(1<<16, center_param['max']))
|
||||
|
||||
center_param['default'] = -1
|
||||
center_param['min'] = -1
|
||||
|
||||
param = {
|
||||
'description': {
|
||||
'short': channel_label+' ${i} Center Value',
|
||||
'long': center_description
|
||||
},
|
||||
'type': 'int32',
|
||||
'instance_start': instance_start,
|
||||
'instance_start_label': instance_start_label,
|
||||
'num_instances': num_channels,
|
||||
'min': center_param['min'],
|
||||
'max': center_param['max'],
|
||||
'default': center_param['default'],
|
||||
}
|
||||
add_local_param(param_prefix+'_CENT${i}', param)
|
||||
|
||||
# add reverse range param
|
||||
for param_prefix in all_param_prefixes:
|
||||
groups = all_param_prefixes[param_prefix]
|
||||
|
||||
@@ -141,6 +141,7 @@ def get_timer_groups(timer_config_file, verbose=False):
|
||||
def get_output_groups(timer_groups, param_prefix="PWM_MAIN",
|
||||
channel_labels=["PWM Main", "PWM Capture"],
|
||||
standard_params=[],
|
||||
center=None,
|
||||
extra_function_groups=[], pwm_timer_param=None,
|
||||
verbose=False):
|
||||
""" convert the timer groups into an output_groups section of module.yaml
|
||||
@@ -182,6 +183,9 @@ def get_output_groups(timer_groups, param_prefix="PWM_MAIN",
|
||||
'channel_label_module_name_prefix': False,
|
||||
}
|
||||
|
||||
if center is not None:
|
||||
group['center'] = deepcopy(center)
|
||||
|
||||
if pwm_timer_param is not None:
|
||||
pwm_timer_param_cp = deepcopy(pwm_timer_param)
|
||||
timer_param_name = param_prefix+'_TIM'+str(timer_index)
|
||||
@@ -199,6 +203,9 @@ def get_output_groups(timer_groups, param_prefix="PWM_MAIN",
|
||||
for standard_param in group['standard_params']:
|
||||
group['standard_params'][standard_param]['show_if'] = timer_param_name + '>=-1'
|
||||
|
||||
if 'center' in group:
|
||||
group['center']['show_if'] = timer_param_name + '>=-1'
|
||||
|
||||
# indicate support for changing motor spin direction
|
||||
group['supported_actions'] = {
|
||||
'set_spin_direction1': {
|
||||
|
||||
@@ -8,8 +8,8 @@ actuator_output:
|
||||
disarmed: { min: 800, max: 2200, default: 1000 }
|
||||
min: { min: 800, max: 1400, default: 1000 }
|
||||
max: { min: 1600, max: 2200, default: 2000 }
|
||||
center: { min: 800, max: 2200}
|
||||
failsafe: { min: 800, max: 2200 }
|
||||
center: { min: 800, max: 2200}
|
||||
extra_function_groups: [ pwm_fmu ]
|
||||
pwm_timer_param:
|
||||
description:
|
||||
|
||||
Reference in New Issue
Block a user